Refactor toolbox and function handling to support synthetic fields and improve type definitions
This commit is contained in:
31
google.go
31
google.go
@@ -23,25 +23,22 @@ func (g google) ModelVersion(modelVersion string) (ChatCompletion, error) {
|
||||
func (g google) requestToChatHistory(in Request, model *genai.GenerativeModel) (*genai.GenerativeModel, *genai.ChatSession, []genai.Part) {
|
||||
res := *model
|
||||
|
||||
if in.Toolbox != nil {
|
||||
for _, tool := range in.Toolbox.funcs {
|
||||
|
||||
res.Tools = append(res.Tools, &genai.Tool{
|
||||
FunctionDeclarations: []*genai.FunctionDeclaration{
|
||||
{
|
||||
Name: tool.Name,
|
||||
Description: tool.Description,
|
||||
Parameters: tool.Parameters.GoogleParameters(),
|
||||
},
|
||||
for _, tool := range in.Toolbox.functions {
|
||||
res.Tools = append(res.Tools, &genai.Tool{
|
||||
FunctionDeclarations: []*genai.FunctionDeclaration{
|
||||
{
|
||||
Name: tool.Name,
|
||||
Description: tool.Description,
|
||||
Parameters: tool.Parameters.GoogleParameters(),
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if !in.Toolbox.dontRequireTool {
|
||||
res.ToolConfig = &genai.ToolConfig{FunctionCallingConfig: &genai.FunctionCallingConfig{
|
||||
Mode: genai.FunctionCallingAny,
|
||||
}}
|
||||
}
|
||||
if !in.Toolbox.RequiresTool() {
|
||||
res.ToolConfig = &genai.ToolConfig{FunctionCallingConfig: &genai.FunctionCallingConfig{
|
||||
Mode: genai.FunctionCallingAny,
|
||||
}}
|
||||
}
|
||||
|
||||
cs := res.StartChat()
|
||||
|
Reference in New Issue
Block a user