Refactor Toolbox handling in Google LLM integration.

Implemented a nil check for Toolbox to prevent potential nil pointer dereferences. Cleaned up and reorganized code for better readability and maintainability while keeping placeholder functionality intact.
This commit is contained in:
Steve Dudenhoeffer 2025-01-22 19:49:37 -05:00
parent 0d70ec46de
commit e7b7aab62e

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/google/generative-ai-go/genai" "github.com/google/generative-ai-go/genai"
"google.golang.org/api/option" "google.golang.org/api/option"
) )
@ -31,17 +32,19 @@ func (g google) requestToGoogleRequest(in Request, model *genai.GenerativeModel)
res = append(res, genai.Text(c.Text)) res = append(res, genai.Text(c.Text))
} }
for _, tool := range in.Toolbox.funcs { if in.Toolbox != nil {
panic("google ToolBox is todo" + tool.Name) for _, tool := range in.Toolbox.funcs {
panic("google ToolBox is todo" + tool.Name)
/* /*
t := genai.Tool{} t := genai.Tool{}
t.FunctionDeclarations = append(t.FunctionDeclarations, &genai.FunctionDeclaration{ t.FunctionDeclarations = append(t.FunctionDeclarations, &genai.FunctionDeclaration{
Name: tool.Name, Name: tool.Name,
Description: tool.Description, Description: tool.Description,
Parameters: nil, //tool.Parameters, Parameters: nil, //tool.Parameters,
}) })
*/ */
}
} }
return res return res