dify icon indicating copy to clipboard operation
dify copied to clipboard

fix: [azure_openai] Error: 'NoneType' object has no attribute 'content'

Open sagarey opened this issue 10 months ago • 0 comments

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: async_choice

normal response: default_choice

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) and cd 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: end

ruff check: image

local fix compare the same model with the cloud version (identify the online version by the mark of the upgrade icon) 线下与线上对比

sagarey avatar Apr 11 '24 18:04 sagarey