sample-app-aoai-chatGPT icon indicating copy to clipboard operation
sample-app-aoai-chatGPT copied to clipboard

Must provide an 'engine' or 'deployment_id' parameter

Open Vayain opened this issue 1 year ago • 1 comments

Provided all the .env values but receive the following error when sending a question in the chat.

AZURE_OPENAI_KEY="123"
AZURE_OPENAI_MODEL="abc"
AZURE_OPENAI_MODEL_NAME="gpt-35-turbo"
AZURE_OPENAI_RESOURCE="abc"

The WebUI starts as expected, but after clicking the send button the following error occurs: openai.error.InvalidRequestError: Must provide an 'engine' or 'deployment_id' parameter to create a <class 'openai.api_resources.chat_completion.ChatCompletion'>

Vayain avatar Jun 22 '23 16:06 Vayain

The error you are facing indicates that you need to provide an 'engine' or 'deployment_id' parameter when creating an instance of 'ChatCompletion' in the OpenAI library.

Make sure you are correctly providing the values ​​for the environment variables 'AZURE_OPENAI_KEY', 'AZURE_OPENAI_MODEL' and 'AZURE_OPENAI_MODEL_NAME'.

Make sure these values ​​are correct and not missing or incorrect in your .env file. Also, make sure you are correctly passing the 'engine' or 'deployment_id' parameter when creating the 'ChatCompletion' instance in your code.

Depending on the OpenAI library version you are using, the method for creating an instance may vary. Make sure you follow the updated docs and use the correct syntax.

1a8jkf avatar Jun 22 '23 17:06 1a8jkf

When I provide the correct values in my .env file and test the app local, it works.

When I run az webapp up as indicated in the README, when I test the deployed web app, I get the same error as @Vayain, because the .env file is not included in the deploy.

Could we make a change in the repository to make it easier for users to include the .env file, or to provide guidance to users on how to make the web app get the env variables?

amenegola avatar Jun 23 '23 13:06 amenegola

Thanks all for raising this issue. We are working on improvements to the local development/deployment experience and will update the documentation accordingly when these are ready.

In the mean time, for @Vayain and @amenegola: after deploying with az webapp up you can set the environment variables on the deployed app service using az webapp config appsettings set. See more details here: https://learn.microsoft.com/en-us/cli/azure/webapp/config/appsettings?view=azure-cli-latest#az-webapp-config-appsettings-set

sarah-widder avatar Jun 27 '23 20:06 sarah-widder