dify
dify copied to clipboard
fix: [azure_openai] Error: 'NoneType' object has no attribute 'content'
Description
After enabling Streaming Mode as Asynchronous Modified Filter in Azure OpenAI, the returned results will throw an error, it appears that the response has additional content filter data added after the stop sign, handle this exception.
Fixes #3384
additional content filter after stop:
normal response:
Type of Change
- [X] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
- [X] Switch the default/asynchronous modified filter Streaming Mode in Azure OpenAI, then test the streaming response.
Suggested Checklist:
- [X] I have performed a self-review of my own code
- [X] I have commented my code, particularly in hard-to-understand areas
- [X] My changes generate no new warnings
- [X] I ran
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods - [ ]
optional
I have made corresponding changes to the documentation - [ ]
optional
I have added tests that prove my fix is effective or that my feature works - [X]
optional
New and existing unit tests pass locally with my changes
response body after fix:
ruff check:
local fix compare the same model with the cloud version (identify the online version by the mark of the upgrade icon)