AutoGPT is an extension of ChatGPT to automatically run an agent to complete a solution without human intervention.
Normally, an OpenAI API key is used.
For Azure OpenAI, you must use either an API token or an Azure Active Directory account.
-
Download and install Azure CLI.
pip install azure-cli azure-functions azure-identity
-
Login to Azure.
az login
-
Obtain an API key or modify your run.sh script to automate.
export accessToken=$(az account get-access-token --resource https://cognitiveservices.azure.com | jq -r .accessToken) echo $accessToken
-
Copy and paste the
accessToken
contents into your AutoGPT env file.OPENAI_API_KEY=<accessToken contents go here> USE_AZURE=True
-
Create a file named azure.yaml with the following contents, adjust for your Azure account:
azure_api_type: azure_ad azure_api_base: https://your-domain.openai.azure.com azure_api_version: 2023-03-01-preview azure_model_map: fast_llm_model_deployment_id: gpt-4 smart_llm_model_deployment_id: gpt-4 embedding_model_deployment_id: text-embedding-ada-002
You can setup run.sh
to automatically extract the accessToken
each time you run AutoGPT by editing the script as follows:
#!/bin/bash
python3 scripts/check_requirements.py requirements.txt
if [ $? -eq 1 ]
then
echo Installing missing packages...
pip install -r requirements.txt
fi
export accessToken=$(az account get-access-token --resource https://cognitiveservices.azure.com | jq -r .accessToken)
sed -i "s/OPENAI_API_KEY=.*/OPENAI_API_KEY=$accessToken/" ./.env
python3 -m autogpt $@
read -p "Press any key to continue..."
Specifically, note the lines to export the token and run sed.
Is it necessary to add OPENAI_API_KEY= too?
after adding azure openai ai?