Closed svenski closed 8 months ago
Those environment variables that openai
uses for Azure are a mess. The configuration that worked for me after some investigation:
.sgptrc
:
OPENAI_API_KEY
containing your azure key - it's a primary source to read the key and you can't leave that empty like @svenski has already mentioned. AZURE_API_KEY
or even AZURE_OPENAI_API_KEY
are ignored both from .sgptrc
and environment variables.USE_LITELLM=true
(you can add it to environment as well, environment takes precedence over .sgptrc
, but I better keep it in one place, which is .sgptrc
).Environment variables:
OPENAI_API_VERSION
- actually your azure OpenAI API version;AZURE_API_BASE
- as is.Trying to use other names or put those variables in different places than what's mentioned here resulted in errors because the program stops seeing them in that case. This is python 3.12.2 and shell-gpt==1.4.0. Like I've mentioned above, openai's environment variables for Azure are a bit messy and this probably needs more investigation.
I couldn't get it to work, I get APIError: AzureException - argument of type 'NoneType' is not iterable
relevant part of .sgptrc
:
USE_LITELLM=true
AZURE_API_KEY]=<azure key>
OPENAI_API_KEY=<azure key> # it won't even try otherwise
AZURE_API_VERSION=2024-02-01
AZURE_API_BASE=https://xxx.api.cognitive.microsoft.com/
I made sure that litellm
works ok by running this with the above variables.
However I couldn't get sgpt to work.
@one1zero1one
As mentioned abouve .sgptrc
should contain USE_LITELLM=true
and OPENAI_API_KEY=your_key
.
AZURE_API_VERSION
and AZURE_API_BASE
should be set as ENV variables in your terminal:
export AZURE_API_BASE=...
export AZURE_API_BASE=...
Wiki page has been updated, thank you @svenski @ddnovikov, closing this issue as completed.
The instructions on wiki to to set up Azure are missing setting
USE_LITELLM=true
in the.sgptrc
file. I don't seem to be able to edit the wiki: https://github.com/TheR1D/shell_gpt/wiki/Azure . sgpt kept asking for an OPEN_AI_KEY until I changed that setting.Edit: The Ollama wiki instructions are correct.