Open JoseManuelGA opened 11 months ago
It sounds like one of your OpenAI related environment variables is incorrect. I suggest printing them out and confirming they are correct.
For example, here are my OpenAI env variables:
AZURE_OPENAI_CHATGPT_DEPLOYMENT="chat" AZURE_OPENAI_CHATGPT_MODEL="gpt-35-turbo" AZURE_OPENAI_EMB_DEPLOYMENT="embedding" AZURE_OPENAI_RESOURCE_GROUP="rg-eastusgpt" AZURE_OPENAI_SERVICE="cog-4jejzjaszakvs"
You can also enable debug logging in the app to see what URL the OpenAI API tries to call. Add this to create_app:
logging.basicConfig(level=logging.DEBUG)
What should be the OpenAI path? I mean I don't really know from where I need to take the AZURE_OPENAI_CHATGPT_DEPLOYMENT and this one AZURE_OPENAI_EMB_DEPLOYMENT
AZURE_OPENAI_CHATGPT_DEPLOYMENT is the name of the chatgpt deployment in your Azure OpenAI account, AZURE_OPENAI_EMB_DEPLOYMENT is the name of the ada deployment. You will also need to set up permissions for you to be able to access those locally and from the App Service app. You can check infra/main.bicep to see all the infrastructure that is setup. I strongly recommend using "azd up" if possible, since there's a lot of setup that needs to happen.
The problem is that if I put my AZURE_OPENAI_EMB_DEPLOYMENT I got this error: Error: The embeddings operation does not work with the specified model, gpt-35-turbo. Please choose different model and try again. You can learn more about which models can be used with each operation here: https://go.microsoft.com/fwlink/?linkid=2197993.
If you look at the source code, the default value of AZURE_OPENAI_EMB_DEPLOYMENT is embedding. You need to have both models for you to point to the services to consume, or you might already have the custom gpt deployments by using your own deployment names.
In my case, the AZURE_OPENAI_CHATGPT_DEPLOYMENT is chat, and AZURE_OPENAI_EMB_DEPLOYMENT is embedding.
What about this:
Error: Invalid response object from API: '{ "statusCode": 401, "message": "Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.com), or have expired." }' (HTTP response code was 401)
To debug issues like that, I first enable debug logging to see what URL the OpenAI API tries to call.
Add this to create_app or prepdocs.py, wherever you're getting the error:
logging.basicConfig(level=logging.DEBUG)
Re-run the script or app and look for the call to OpenAI right before the error. You should see a URL starting with https://{AZURE_OPENAI_SERVICE}.openai.azure.com
Make sure that URL matches what you see in the studio when you click the generate code button and open up the curl tab.
If it matches, then you really do have an authentication problem. Make sure youre logged in locally with the same account that ran azd up
. Open the resource group, click IAM, click Role assignments, filter by resource group, and confirm you see Cognitive Services OpenAI user roles, one for you, one for your app.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this issue will be closed.
This issue is for a: (mark with an
x
)I'm trying to do a test with the demo and my own resources, I change the values for each resource but nothing works, I want to lunch the demo in local without creating any new resource, I have all that I need.
Error I get: raise self.handle_error_response( openai.error.InvalidRequestError: The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.