Open RogerBarreto opened 2 months ago
The problem seems to be that the SDK assumes that first "Choices" object always have a not-null Delta, while for content_filter_offsets
this is not true.
Propagating null should help to not throw in this case: Choices[0].Delta.FunctionCall
=> Choices[0].Delta?.FunctionCall
Thank you for reaching out, @RogerBarreto ! We have merged and released a fix for this issue. It is available starting with version 2.0.0-beta.12.
Confirm this is not an issue with the underlying OpenAI API
Confirm this is not an issue with Azure OpenAI
Describe the bug
When using
StreamingChatCompletionUpdate
with Asynchronous Filter enabled in azure, this class breaks.https://github.com/openai/openai-dotnet/blob/583e9f6f519feeee0e2907e80bf7d5bf8302d93f/src/Custom/Chat/StreamingChatCompletionUpdate.cs#L83
When a SSE
data:
doesn't have adelta
(null) theChoice[0].Delta
line throwsNullReferenceException
.Final 3 streaming chunks of an
Asynchornous Filter
response.This issue was reported in our Semantic Kernel Issues Here but actually seems to be a problem when Azure tries to use the
OpenAI SDK
for those chunks, this potentially can be handled byAzure SDK
library in a non-ideal (try catch block) or in the back-end (providing always an empty delta) but I wonder would be quicker/simple getting a fix in here.The problem also happen for other properties of the class as below:
To Reproduce
Role
property of the last 2 chunksSince the property is a pointer, we are unable to test it for null.
Code snippets
No response
OS
Windows 11
.NET version
.net 8
Library version
beta.10