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:
2025-04-06 01:23:10 -04:00
parent ff5e4ca7b0
commit 7c9eb08cb4
13 changed files with 267 additions and 96 deletions

View File

@@ -2,6 +2,7 @@ package schema
import (
"errors"
"github.com/openai/openai-go"
"reflect"
"golang.org/x/exp/slices"
@@ -19,6 +20,14 @@ func (e enum) SchemaType() jsonschema.DataType {
return jsonschema.String
}
func (e enum) FunctionParameters() openai.FunctionParameters {
return openai.FunctionParameters{
"type": "string",
"description": e.Description(),
"enum": e.values,
}
}
func (e enum) Definition() jsonschema.Definition {
def := e.basic.Definition()
def.Enum = e.values