Unverified Commit ef65174d authored by Tom Sheffler's avatar Tom Sheffler Committed by GitHub
Browse files

types: include the 'items' and '$defs' fields to properly handle "array" types (#10091)




---------
Co-authored-by: default avatarParth Sareen <parth.sareen@ollama.com>
parent 42ecb9f1
...@@ -163,6 +163,7 @@ func (t *ToolCallFunctionArguments) String() string { ...@@ -163,6 +163,7 @@ func (t *ToolCallFunctionArguments) String() string {
type Tool struct { type Tool struct {
Type string `json:"type"` Type string `json:"type"`
Items any `json:"items,omitempty"`
Function ToolFunction `json:"function"` Function ToolFunction `json:"function"`
} }
...@@ -213,9 +214,12 @@ type ToolFunction struct { ...@@ -213,9 +214,12 @@ type ToolFunction struct {
Description string `json:"description"` Description string `json:"description"`
Parameters struct { Parameters struct {
Type string `json:"type"` Type string `json:"type"`
Defs any `json:"$defs,omitempty"`
Items any `json:"items,omitempty"`
Required []string `json:"required"` Required []string `json:"required"`
Properties map[string]struct { Properties map[string]struct {
Type PropertyType `json:"type"` Type PropertyType `json:"type"`
Items any `json:"items,omitempty"`
Description string `json:"description"` Description string `json:"description"`
Enum []any `json:"enum,omitempty"` Enum []any `json:"enum,omitempty"`
} `json:"properties"` } `json:"properties"`
......
...@@ -281,9 +281,12 @@ func TestChatMiddleware(t *testing.T) { ...@@ -281,9 +281,12 @@ func TestChatMiddleware(t *testing.T) {
Description: "Get the current weather", Description: "Get the current weather",
Parameters: struct { Parameters: struct {
Type string `json:"type"` Type string `json:"type"`
Defs any `json:"$defs,omitempty"`
Items any `json:"items,omitempty"`
Required []string `json:"required"` Required []string `json:"required"`
Properties map[string]struct { Properties map[string]struct {
Type api.PropertyType `json:"type"` Type api.PropertyType `json:"type"`
Items any `json:"items,omitempty"`
Description string `json:"description"` Description string `json:"description"`
Enum []any `json:"enum,omitempty"` Enum []any `json:"enum,omitempty"`
} `json:"properties"` } `json:"properties"`
...@@ -292,6 +295,7 @@ func TestChatMiddleware(t *testing.T) { ...@@ -292,6 +295,7 @@ func TestChatMiddleware(t *testing.T) {
Required: []string{"location"}, Required: []string{"location"},
Properties: map[string]struct { Properties: map[string]struct {
Type api.PropertyType `json:"type"` Type api.PropertyType `json:"type"`
Items any `json:"items,omitempty"`
Description string `json:"description"` Description string `json:"description"`
Enum []any `json:"enum,omitempty"` Enum []any `json:"enum,omitempty"`
}{ }{
......
...@@ -370,9 +370,12 @@ func TestGenerateChat(t *testing.T) { ...@@ -370,9 +370,12 @@ func TestGenerateChat(t *testing.T) {
Description: "Get the current weather", Description: "Get the current weather",
Parameters: struct { Parameters: struct {
Type string `json:"type"` Type string `json:"type"`
Defs any `json:"$defs,omitempty"`
Items any `json:"items,omitempty"`
Required []string `json:"required"` Required []string `json:"required"`
Properties map[string]struct { Properties map[string]struct {
Type api.PropertyType `json:"type"` Type api.PropertyType `json:"type"`
Items any `json:"items,omitempty"`
Description string `json:"description"` Description string `json:"description"`
Enum []any `json:"enum,omitempty"` Enum []any `json:"enum,omitempty"`
} `json:"properties"` } `json:"properties"`
...@@ -381,6 +384,7 @@ func TestGenerateChat(t *testing.T) { ...@@ -381,6 +384,7 @@ func TestGenerateChat(t *testing.T) {
Required: []string{"location"}, Required: []string{"location"},
Properties: map[string]struct { Properties: map[string]struct {
Type api.PropertyType `json:"type"` Type api.PropertyType `json:"type"`
Items any `json:"items,omitempty"`
Description string `json:"description"` Description string `json:"description"`
Enum []any `json:"enum,omitempty"` Enum []any `json:"enum,omitempty"`
}{ }{
...@@ -467,9 +471,12 @@ func TestGenerateChat(t *testing.T) { ...@@ -467,9 +471,12 @@ func TestGenerateChat(t *testing.T) {
Description: "Get the current weather", Description: "Get the current weather",
Parameters: struct { Parameters: struct {
Type string `json:"type"` Type string `json:"type"`
Defs any `json:"$defs,omitempty"`
Items any `json:"items,omitempty"`
Required []string `json:"required"` Required []string `json:"required"`
Properties map[string]struct { Properties map[string]struct {
Type api.PropertyType `json:"type"` Type api.PropertyType `json:"type"`
Items any `json:"items,omitempty"`
Description string `json:"description"` Description string `json:"description"`
Enum []any `json:"enum,omitempty"` Enum []any `json:"enum,omitempty"`
} `json:"properties"` } `json:"properties"`
...@@ -478,6 +485,7 @@ func TestGenerateChat(t *testing.T) { ...@@ -478,6 +485,7 @@ func TestGenerateChat(t *testing.T) {
Required: []string{"location"}, Required: []string{"location"},
Properties: map[string]struct { Properties: map[string]struct {
Type api.PropertyType `json:"type"` Type api.PropertyType `json:"type"`
Items any `json:"items,omitempty"`
Description string `json:"description"` Description string `json:"description"`
Enum []any `json:"enum,omitempty"` Enum []any `json:"enum,omitempty"`
}{ }{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment