From b631adea55ae898d570a12efabdae9a09d3545f7 Mon Sep 17 00:00:00 2001 From: Tim Misiak Date: Thu, 5 Dec 2024 14:24:49 -0800 Subject: [PATCH] Fix ID field to be optional The ID field is not always present for streaming responses. Without omitempty, the entire ToolCall struct will be missing. --- chat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chat.go b/chat.go index 2b13f8dd..fcaf79cf 100644 --- a/chat.go +++ b/chat.go @@ -179,7 +179,7 @@ func (m *ChatCompletionMessage) UnmarshalJSON(bs []byte) error { type ToolCall struct { // Index is not nil only in chat completion chunk object Index *int `json:"index,omitempty"` - ID string `json:"id"` + ID string `json:"id,omitempty"` Type ToolType `json:"type"` Function FunctionCall `json:"function"` }