instead of having an openai => google translation layer, just add sister functions to the types that construct the google request just like openai's

This commit is contained in:
2025-04-07 01:57:02 -04:00
parent 58552ee226
commit 5ba0d5df7e
11 changed files with 175 additions and 232 deletions

View File

@@ -3,8 +3,6 @@ package schema
import (
"reflect"
"strings"
"github.com/sashabaranov/go-openai/jsonschema"
)
// GetType will, given an interface{} that is a struct (NOT a pointer to a struct), return the Type of the struct that
@@ -27,27 +25,27 @@ func getFromType(t reflect.Type, b basic) Type {
switch t.Kind() {
case reflect.String:
b.DataType = jsonschema.String
b.DataType = String
b.typeName = "string"
return b
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
b.DataType = jsonschema.Integer
b.DataType = Integer
b.typeName = "integer"
return b
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
b.DataType = jsonschema.Integer
b.DataType = Integer
b.typeName = "integer"
return b
case reflect.Float32, reflect.Float64:
b.DataType = jsonschema.Number
b.DataType = Number
b.typeName = "number"
return b
case reflect.Bool:
b.DataType = jsonschema.Boolean
b.DataType = Boolean
b.typeName = "boolean"
return b
@@ -94,7 +92,7 @@ func getField(f reflect.StructField, index int) Type {
}
}
b.DataType = jsonschema.String
b.DataType = String
b.typeName = "string"
return enum{
basic: b,
@@ -114,7 +112,7 @@ func getObject(t reflect.Type) object {
}
return object{
basic: basic{DataType: jsonschema.Object, typeName: "object"},
basic: basic{DataType: Object, typeName: "object"},
fields: fields,
}
}
@@ -122,7 +120,7 @@ func getObject(t reflect.Type) object {
func getArray(t reflect.Type) array {
res := array{
basic: basic{
DataType: jsonschema.Array,
DataType: Array,
typeName: "array",
},
}