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

@@ -28,22 +28,27 @@ func getFromType(t reflect.Type, b basic) Type {
switch t.Kind() {
case reflect.String:
b.DataType = jsonschema.String
b.typeName = "string"
return b
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
b.DataType = jsonschema.Integer
b.typeName = "integer"
return b
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
b.DataType = jsonschema.Integer
b.typeName = "integer"
return b
case reflect.Float32, reflect.Float64:
b.DataType = jsonschema.Number
b.typeName = "number"
return b
case reflect.Bool:
b.DataType = jsonschema.Boolean
b.typeName = "boolean"
return b
case reflect.Struct:
@@ -107,7 +112,7 @@ func getObject(t reflect.Type) object {
}
return object{
basic: basic{DataType: jsonschema.Object},
basic: basic{DataType: jsonschema.Object, typeName: "object"},
fields: fields,
}
}
@@ -116,6 +121,7 @@ func getArray(t reflect.Type) array {
res := array{
basic: basic{
DataType: jsonschema.Array,
typeName: "array",
},
}