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"
|
||||
"strconv"
|
||||
|
||||
@@ -13,6 +14,7 @@ var _ Type = basic{}
|
||||
|
||||
type basic struct {
|
||||
jsonschema.DataType
|
||||
typeName string
|
||||
|
||||
// index is the position of the parameter in the StructField of the function's parameter struct
|
||||
index int
|
||||
@@ -29,6 +31,13 @@ func (b basic) SchemaType() jsonschema.DataType {
|
||||
return b.DataType
|
||||
}
|
||||
|
||||
func (b basic) FunctionParameters() openai.FunctionParameters {
|
||||
return openai.FunctionParameters{
|
||||
"type": b.typeName,
|
||||
"description": b.description,
|
||||
}
|
||||
}
|
||||
|
||||
func (b basic) Definition() jsonschema.Definition {
|
||||
return jsonschema.Definition{
|
||||
Type: b.DataType,
|
||||
|
Reference in New Issue
Block a user