Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: create_app: Exception in /api/conversation cannot access local variable ' answer' where it is not associated with a value #1302

Open
3 tasks
yaowilli opened this issue Sep 9, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@yaowilli
Copy link

yaowilli commented Sep 9, 2024

Describe the bug

This issue is observed when simply chatting with the chat App
ERROR: create_app: Exception in /api/conversation cannot access local variable ' answer' where it is not associated with a value
UnboundLoca1Error: cannot access local variable 'answer' where it is not associated with a value

Expected behavior

I would expect a clear answer with no error

Debugging information

Steps to reproduce

Steps to reproduce the behavior:

  1. by simply chatting with the App

Screenshots

image
image

Logs

ERROR: create_app: Exception in /api/conversation cannot access local variable ' answer' where it is not associated with a value
UnboundLoca1Error: cannot access local variable 'answer' where it is not associated with a value


Tasks

To be filled in by the engineer picking up the issue

  • Task 1
  • Task 2
  • ...
@yaowilli yaowilli added the bug Something isn't working label Sep 9, 2024
@Prasanjeet-Microsoft
Copy link
Contributor

Hello @yaowilli , Could you let us know about any other changes you made to the app settings before or after deployment?

FYI @Roopan-Microsoft

@yaowilli
Copy link
Author

@Prasanjeet-Microsoft I made the following before :

1/ disabled all public all public access
2/ request for VNETs and 3 subnets
3/ configure private end point s and the VNET integration ( is only for App service, function App/backend)
No end point for Key Vault
4/ register DNS for private end point with intel cloud
--> after records added to DNS : do "nslookup " on each PE IP addresses to see if they resolve correctly
5/ Roles assignment (Authenticate using RBAC) roles based access
6/

@Prasanjeet-Microsoft
Copy link
Contributor

Hello @yaowilli , Did you change the GPT model or make any other configuration changes in the application?

@yaowilli
Copy link
Author

@Prasanjeet-Microsoft yes I changed the GPT to gpt-4o and embedding to text-embedding-ada-002
the settings are showing below
image
image

USE_KEY_VAULT set to true

@Prasanjeet-Microsoft
Copy link
Contributor

Prasanjeet-Microsoft commented Sep 16, 2024

Hello @yaowilli , This is to inform you that text-embedding-ada-002 is the default value of Azure Open AI Embedding Model for this accelerator. However, we have tried to deploy this accelerator with gpt-4o model and have not been able to reproduce the issue so far.

Could you please provide the value of the AZURE_AUTH_TYPE environment variable from the app settings?

@yaowilli
Copy link
Author

The issue is sporadic it occurs when you do not expect it
AZURE_AUTH_TYPE = keys

@Prasanjeet-Microsoft
Copy link
Contributor

Hello @yaowilli , Could you please investigate further using Application Insights to check for any exceptions or additional details? I believe there might be some relevant information that could help us diagnose the issue more precisely. Could you please follow the steps outlined below as an example.

Go to Application Insights resource:

Screenshot 2024-09-18 153822

In the Application Insights resource menu on the left, under Investigate, select the Failures option:

Screenshot 2024-09-18 153919

Select the time range as Last 7 days or 30 days and click on Apply:

Screenshot 2024-09-18 153947

Click on 500 response code:

Screenshot 2024-09-18 154244

Click on suggested view details:

Screenshot 2024-09-18 154325

Click on each exception and provide a screenshot for each one:

Screenshot 2024-09-18 154521

@yaowilli
Copy link
Author

ok will do I am out of office at moment

@strudel0209
Copy link

getting the same error after switching from Azure OpenAI model gpt-4 to gpt-4o - error is intermitent:

ERROR:create_app:Exception in /api/conversation/custom | cannot access local variable 'answer' where it is not associated with a value 2024-09-18T10:27:45.8196501Z Traceback (most recent call last): 2024-09-18T10:27:45.8196724Z File "/usr/src/app/create_app.py", line 371, in conversation_custom 2024-09-18T10:27:45.8196849Z messages = await message_orchestrator.handle_message( 2024-09-18T10:27:45.8196989Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-18T10:27:45.8197100Z File "/usr/src/app/backend/batch/utilities/helpers/orchestrator_helper.py", line 27, in handle_message 2024-09-18T10:27:45.8197233Z return await orchestrator.handle_message( 2024-09-18T10:27:45.8197359Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-18T10:27:45.8197464Z File "/usr/src/app/backend/batch/utilities/orchestrator/orchestrator_base.py", line 72, in handle_message 2024-09-18T10:27:45.8197608Z result = await self.orchestrate(user_message, chat_history, **kwargs) 2024-09-18T10:27:45.8197713Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-18T10:27:45.8197818Z File "/usr/src/app/backend/batch/utilities/orchestrator/open_ai_functions.py", line 133, in orchestrate 2024-09-18T10:27:45.8197962Z if response := self.call_content_safety_output(user_message, answer.answer): 2024-09-18T10:27:45.8198074Z ^^^^^^^^^^^^ 2024-09-18T10:27:45.8198211Z UnboundLocalError: cannot access local variable 'answer' where it is not associated with a value 2024-09-18T10:27:45.8318921Z [pid: 1|app: 0|req: 25/25] 169.254.131.1 () {100 vars in 9602 bytes} [Wed Sep 18 10:27:43 2024] POST /api/conversation/custom => generated 77 bytes in 1870 msecs (HTTP/1.1 500) 2 headers in 90 bytes (2 switches on core 0) 2024-09-18 10:27:43.946 +00:00 [Information] Microsoft.AspNetCore.Hosting.Diagnostics: Request starting HTTP/1.1 POST http://omnicorechat.robotics.abb.com/api/conversation/custom - application/json 44300 2024-09-18 10:27:43.948 +00:00 [Information] MiddlewareConsoleLogs: {"Timestamp":"2024-09-18T10:27:43.9483332Z","SiteName":"web-gqbv7fgkgycfg-docker","TaskName":"TraceIO","Message":"Starting","ProviderName":"Microsoft-Azure-AppService-Middleware-Authentication","Level":4,"EventId":201,"ActivityId":"9ec2f6af-0cc6-40fe-853f-f43dddc06efd","ActionTaken":"TokenStore ReadContainer","Location":"FileSystem","TimeTaken":-1} 2024-09-18 10:27:43.959 +00:00 [Information] MiddlewareConsoleLogs: {"Timestamp":"2024-09-18T10:27:43.9594266Z","SiteName":"web-gqbv7fgkgycfg-docker","TaskName":"TraceIO","Message":"Completed","ProviderName":"Microsoft-Azure-AppService-Middleware-Authentication","Level":4,"EventId":201,"ActivityId":"9ec2f6af-0cc6-40fe-853f-f43dddc06efd","ActionTaken":"TokenStore ReadContainer","Location":"FileSystem","TimeTaken":11} 2024-09-18 10:27:43.959 +00:00 [Trace] Middleware: Request came in on normal port, sending to normal target http://169.254.131.3:80/api/conversation/custom 2024-09-18 10:27:43.959 +00:00 [Trace] Middleware: Forwarding request to http://169.254.131.3/api/conversation/custom 2024-09-18 10:27:43.960 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HN6NPEEJVC93", Request id "0HN6NPEEJVC93:00000016": started reading request body. 2024-09-18 10:27:43.960 +00:00 [Debug] Microsoft.AspNetCore.Server.Kestrel: Connection id "0HN6NPEEJVC93", Request id "0HN6NPEEJVC93:00000016": done reading request body. 2024-09-18 10:27:45.832 +00:00 [Trace] Middleware: Forwarded request finished in 1872.279ms 200 INTERNAL SERVER ERROR

@Prasanjeet-Microsoft
Copy link
Contributor

@yaowilli We are already working on this, and the issue has been resolved. We will update you once it is published.
Thank you.

@Prasanjeet-Microsoft
Copy link
Contributor

Hello @yaowilli , We would like to inform you that the code fix has been published. You can now redeploy the accelerator and run your tests. Please inform us once you’ve completed the testing so we can close this GitHub issue.

@yaowilli
Copy link
Author

Hi @Prasanjeet-Microsoft is there a way I could obtain the code fixes via container deployment ?
my accelerator is already deployed and provisioned in Azure

@Prasanjeet-Microsoft
Copy link
Contributor

Hi @yaowilli, apologies for the delayed response. This accelerator already has container deployment in place, so there's no need to redeploy it. You can go ahead and run the test in your deployed accelerator.
Please inform us once you’ve completed the testing, so we can close this issue.

Thank you.

@Prasanjeet-Microsoft
Copy link
Contributor

Hi @yaowilli, just wanted to check if you’ve had a chance to run the tests on your deployed accelerator. Please update us on your progress when you can, so we can move forward and close this issue.

Thank you!

@yaowilli
Copy link
Author

yaowilli commented Oct 1, 2024

I am sorry it seems to be working now thanks I was waiting to perform more testing

@Prasanjeet-Microsoft
Copy link
Contributor

I am sorry it seems to be working now thanks I was waiting to perform more testing

@yaowilli Thank you for your confirmation. If your issue has been resolved, can we go ahead and close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants