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

@@ -2,12 +2,11 @@ package schema
import (
"errors"
"github.com/openai/openai-go"
"reflect"
"slices"
"golang.org/x/exp/slices"
"github.com/sashabaranov/go-openai/jsonschema"
"github.com/google/generative-ai-go/genai"
"github.com/openai/openai-go"
)
type enum struct {
@@ -16,10 +15,6 @@ type enum struct {
values []string
}
func (e enum) SchemaType() jsonschema.DataType {
return jsonschema.String
}
func (e enum) FunctionParameters() openai.FunctionParameters {
return openai.FunctionParameters{
"type": "string",
@@ -28,10 +23,12 @@ func (e enum) FunctionParameters() openai.FunctionParameters {
}
}
func (e enum) Definition() jsonschema.Definition {
def := e.basic.Definition()
def.Enum = e.values
return def
func (e enum) GoogleParameters() *genai.Schema {
return &genai.Schema{
Type: genai.TypeString,
Description: e.Description(),
Enum: e.values,
}
}
func (e enum) FromAny(val any) (reflect.Value, error) {