TheR1D / shell_gpt

A command-line productivity tool powered by AI large language models like GPT-4, will help you accomplish your tasks faster and more efficiently.
MIT License
9.82k stars 771 forks source link

Missing instructions to run on Azure #516

Closed svenski closed 8 months ago

svenski commented 8 months ago

The instructions on wiki to to set up Azure are missing setting USE_LITELLM=truein 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.

ddnovikov commented 8 months ago

Those environment variables that openai uses for Azure are a mess. The configuration that worked for me after some investigation:

.sgptrc:

Environment variables:

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.

one1zero1one commented 8 months ago

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.

TheR1D commented 8 months ago

@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=...
TheR1D commented 8 months ago

Wiki page has been updated, thank you @svenski @ddnovikov, closing this issue as completed.