diff --git a/src/Custom/Chat/Streaming/InternalCreateChatCompletionStreamResponseChoice.Serialization.cs b/src/Custom/Chat/Streaming/InternalCreateChatCompletionStreamResponseChoice.Serialization.cs index 5d3b87e6..58bc9265 100644 --- a/src/Custom/Chat/Streaming/InternalCreateChatCompletionStreamResponseChoice.Serialization.cs +++ b/src/Custom/Chat/Streaming/InternalCreateChatCompletionStreamResponseChoice.Serialization.cs @@ -81,12 +81,14 @@ internal static InternalCreateChatCompletionStreamResponseChoice DeserializeInte } if (property.NameEquals("finish_reason"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + var propertyValue = property.Value; + string propertyValueString; + if (propertyValue.ValueKind == JsonValueKind.Null||string.IsNullOrEmpty((propertyValueString=propertyValue.GetString())?.Trim())) { finishReason = null; continue; } - finishReason = property.Value.GetString().ToChatFinishReason(); + finishReason = propertyValueString.ToChatFinishReason(); continue; } if (property.NameEquals("index"u8))