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:
@@ -2,10 +2,10 @@ package schema
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/openai/openai-go"
|
||||
"reflect"
|
||||
|
||||
"github.com/sashabaranov/go-openai/jsonschema"
|
||||
"github.com/google/generative-ai-go/genai"
|
||||
"github.com/openai/openai-go"
|
||||
)
|
||||
|
||||
type array struct {
|
||||
@@ -15,25 +15,20 @@ type array struct {
|
||||
items Type
|
||||
}
|
||||
|
||||
func (a array) SchemaType() jsonschema.DataType {
|
||||
return jsonschema.Array
|
||||
}
|
||||
|
||||
func (a array) FunctionParameters() openai.FunctionParameters {
|
||||
func (a array) OpenAIParameters() openai.FunctionParameters {
|
||||
return openai.FunctionParameters{
|
||||
"type": "array",
|
||||
"description": a.Description(),
|
||||
"items": a.items.FunctionParameters(),
|
||||
"items": a.items.OpenAIParameters(),
|
||||
}
|
||||
}
|
||||
|
||||
func (a array) Definition() jsonschema.Definition {
|
||||
def := a.basic.Definition()
|
||||
def.Type = jsonschema.Array
|
||||
i := a.items.Definition()
|
||||
def.Items = &i
|
||||
def.AdditionalProperties = false
|
||||
return def
|
||||
func (a array) GoogleParameters() *genai.Schema {
|
||||
return &genai.Schema{
|
||||
Type: genai.TypeArray,
|
||||
Description: a.Description(),
|
||||
Items: a.items.GoogleParameters(),
|
||||
}
|
||||
}
|
||||
|
||||
func (a array) FromAny(val any) (reflect.Value, error) {
|
||||
|
Reference in New Issue
Block a user