-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Azure Annotation Message in API response breaks streaming #6465
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
Comments
Additional information: This appears to be a content filtering annotation chunk as documented here: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/content-filter?tabs=warning%2Cuser-prompt%2Cpython-new The message is in the form of: data: {
"id": "",
"object": "",
"created": 0,
"model": "",
"choices": [
{
"index": 0,
"finish_reason": null,
"content_filter_results": { ... },
"content_filter_raw": [ ... ],
"content_filter_offsets": {
"check_offset": 44,
"start_offset": 44,
"end_offset": 198
}
}
],
"usage": null
} It can be seen directly via curl if annotations are turned on. As the message does not have a delta attribute, an exception is raised and the stream breaks.
|
What happened?
Describe the bug
When streaming is enabled and using Azure hosted OpenAI models, we are often seeing a chunk at the end of the stream like the one below (actual chunk, not edited. Note the missing id value, the lack of
delta
in choices, etc.This is causing this block of code in _openai_client.py to raise AttributeError as there is no
delta
in choices.To Reproduce
We can reproduce this pretty consistently in our environment - content filtering annotations need to be enabled. The messages can be seen directly via curl (see my reply to this message)
Expected behavior
Exception should not be raised and streaming should continue.
Which packages was the bug in?
Python Extensions (autogen-ext)
AutoGen library version.
Python 0.5.6
Other library version.
No response
Model used
gpt-4.1
Model provider
Azure OpenAI
Other model provider
No response
Python version
3.11
.NET version
None
Operating system
Ubuntu
edit: more information
The text was updated successfully, but these errors were encountered: