Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
types: send index for tool calls (#12625)
Parth Sareenc4c5a4a01e05
diff --git a/api/types.go b/api/types.goindex 85a488776..1483c844f 100644--- a/api/types.go+++ b/api/types.go@@ -204,7 +204,7 @@ type ToolCall struct {}type ToolCallFunction struct {- Index int `json:"index,omitempty"`+ Index int `json:"index"`Name string `json:"name"`Arguments ToolCallFunctionArguments `json:"arguments"`}diff --git a/api/types_test.go b/api/types_test.goindex 5393b4623..5053c1621 100644--- a/api/types_test.go+++ b/api/types_test.go@@ -298,6 +298,30 @@ func TestToolFunction_UnmarshalJSON(t *testing.T) {}}+func TestToolCallFunction_IndexAlwaysMarshals(t *testing.T) {+ fn := ToolCallFunction{+ Name: "echo",+ Arguments: ToolCallFunctionArguments{"message": "hi"},+ }++ data, err := json.Marshal(fn)+ require.NoError(t, err)++ raw := map[string]any{}+ require.NoError(t, json.Unmarshal(data, &raw))+ require.Contains(t, raw, "index")+ assert.Equal(t, float64(0), raw["index"])++ fn.Index = 3+ data, err = json.Marshal(fn)+ require.NoError(t, err)++ raw = map[string]any{}+ require.NoError(t, json.Unmarshal(data, &raw))+ require.Contains(t, raw, "index")+ assert.Equal(t, float64(3), raw["index"])+}+func TestPropertyType_UnmarshalJSON(t *testing.T) {tests := []struct {name string