[Bug]: AGS throws error when api_key is configured with os.environ["AZURE_OPENAI_API_KEY"]
Describe the bug
Configuring for Azure OpenAI with the environment variable AZURE_OPENAI_API_KEY throws ValueError
"api_key is not present in llm_config or OPENAI_API_KEY env variable for agent..."
This is due to logic that checks for OPENAI_API_KEY but doesn't include a check for the AZURE_OPENAI_KEY configuration. https://github.com/microsoft/autogen/blob/autogenstudio/samples/apps/autogen-studio/autogenstudio/workflowmanager.py#L239-L242
Completely removing the check block allows support of the AZURE_OPENAI_API_KEY configuration and improves the error message
OpenAIError: Missing credentials. Please pass one of
api_key,azure_ad_token,azure_ad_token_provider, or theAZURE_OPENAI_API_KEYorAZURE_OPENAI_AD_TOKENenvironment variables.
Steps to reproduce
- Set the environment variables for Azure OpenAI:
export AZURE_OPENAI_API_KEY="<key>"
export AZURE_OPENAI_API_BASE="<base>"
export OPENAI_API_VERSION="<version>"
#export DEFAULT_AZURE_API_VERSION="<version>" #See Additional Information:Related Issue
- Validate the OAI_CONFIG_LIST doesn't contain any keys.
- Fire up the AGS: autogenstudio ui
- Create new azure model without entering key/base/version
- Test Model
Model Used
gpt-4
Expected Behavior
AGS should allow same azure environmental variable configuration as Autogen.
Screenshots and logs
No response
Additional Information
Related Issue
Using the proper 'DEFAULT_AZURE_API_VERSION' results in error message: