diff --git a/google.go b/google.go index 59e723f..59c0883 100644 --- a/google.go +++ b/google.go @@ -4,10 +4,10 @@ import ( "context" "encoding/json" "fmt" - - "github.com/sashabaranov/go-openai/jsonschema" + "log/slog" "github.com/google/generative-ai-go/genai" + "github.com/sashabaranov/go-openai/jsonschema" "google.golang.org/api/option" ) @@ -39,6 +39,9 @@ func (g google) requestToChatHistory(in Request, model *genai.GenerativeModel) ( case jsonschema.String: res.Type = genai.TypeString + case jsonschema.Integer: + res.Type = genai.TypeInteger + case jsonschema.Number: res.Type = genai.TypeNumber @@ -47,6 +50,11 @@ func (g google) requestToChatHistory(in Request, model *genai.GenerativeModel) ( default: res.Type = genai.TypeUnspecified + slog.Error("unknown type in go_llm/google.go!requestToChatHistory", "type", in.Type) + } + + if in.Items != nil { + res.Items = openAiSchemaToGenAISchema(*in.Items) } res.Description = in.Description @@ -77,6 +85,12 @@ func (g google) requestToChatHistory(in Request, model *genai.GenerativeModel) ( }, }) } + + if !in.Toolbox.dontRequireTool { + res.ToolConfig = &genai.ToolConfig{FunctionCallingConfig: &genai.FunctionCallingConfig{ + Mode: genai.FunctionCallingAny, + }} + } } cs := res.StartChat()