diff --git a/streamaccumulator.go b/streamaccumulator.go index 53b7069f..2fcda3c6 100644 --- a/streamaccumulator.go +++ b/streamaccumulator.go @@ -163,11 +163,11 @@ func (prev *chatCompletionResponseState) update(chunk ChatCompletionChunk) (just delta := chunk.Choices[0].Delta new := chatCompletionResponseState{} switch { - case delta.JSON.Content.Valid(): + case delta.Content != "": new.state = contentResponseState - case delta.JSON.Refusal.Valid(): + case delta.Refusal != "": new.state = refusalResponseState - case delta.JSON.ToolCalls.Valid(): + case len(delta.ToolCalls) > 0: new.state = toolResponseState new.index = int(delta.ToolCalls[0].Index) default: diff --git a/streamaccumulator_test.go b/streamaccumulator_test.go index 6c602842..db871f11 100644 --- a/streamaccumulator_test.go +++ b/streamaccumulator_test.go @@ -535,4 +535,4 @@ data: {"id":"chatcmpl-A3Tguz3LSXTHBTY2NAPBCSyfBltxF","object":"chat.completion.c data: [DONE] -` +` \ No newline at end of file