Add support for integers and tool configuration in schema handling
This update introduces support for `jsonschema.Integer` types and updates the logic to handle nested items in schemas. Added a new default error log for unknown types using `slog.Error`. Also, integrated tool configuration with a `FunctionCallingConfig` when `dontRequireTool` is false.
This commit is contained in:
@@ -2,6 +2,7 @@ package schema
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/openai/openai-go"
|
||||
"reflect"
|
||||
|
||||
"github.com/sashabaranov/go-openai/jsonschema"
|
||||
@@ -19,6 +20,19 @@ func (o object) SchemaType() jsonschema.DataType {
|
||||
return jsonschema.Object
|
||||
}
|
||||
|
||||
func (o object) FunctionParameters() openai.FunctionParameters {
|
||||
var properties = map[string]openai.FunctionParameters{}
|
||||
for k, v := range o.fields {
|
||||
properties[k] = v.FunctionParameters()
|
||||
}
|
||||
|
||||
return openai.FunctionParameters{
|
||||
"type": "object",
|
||||
"description": o.Description(),
|
||||
"properties": properties,
|
||||
}
|
||||
}
|
||||
|
||||
func (o object) Definition() jsonschema.Definition {
|
||||
def := o.basic.Definition()
|
||||
def.Type = jsonschema.Object
|
||||
|
||||
Reference in New Issue
Block a user