mirror of
https://github.com/ollama/ollama.git
synced 2025-11-10 23:07:24 +01:00
types: send index for tool calls (#12625)
This commit is contained in:
@@ -204,7 +204,7 @@ type ToolCall struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ToolCallFunction struct {
|
type ToolCallFunction struct {
|
||||||
Index int `json:"index,omitempty"`
|
Index int `json:"index"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Arguments ToolCallFunctionArguments `json:"arguments"`
|
Arguments ToolCallFunctionArguments `json:"arguments"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
func TestPropertyType_UnmarshalJSON(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
Reference in New Issue
Block a user