Azure / aistudio-copilot-sample

Sample quickstart repo for getting started building an enterprise chat copilot in Azure AI Studio
MIT License
314 stars 194 forks source link

Conflict if OPENAI_API_KEY environment variable set for OpenAI (non-Azure) #75

Closed jhakulin closed 7 months ago

jhakulin commented 9 months ago

Running through the steps and I hit following problem when running python src/run.py --question "which tent is the most waterproof?"

Actual outcome: openai.error.AuthenticationError: Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.

This problem happened because I had OPENAI_API_KEY environment variable already set for non-Azure OpenAI. The copilot sample uses environment variables from .env file, and uses the same OPENAI_API_KEY key also for Azure, which causes the conflict.

By modifying run.py to override the existing env variables by load_dotenv(override=True), the scenario works.

luigiw commented 7 months ago

Discussed offline with the customer. The agreement is to depend more on explicit contracts than env variables for things.