From 3a1e76e65ea82f7fecb9ab923d812007436ffc57 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 1 Sep 2025 12:23:18 -0500 Subject: gemini-cli is stupid --- handleFunctionCall.go | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 handleFunctionCall.go (limited to 'handleFunctionCall.go') diff --git a/handleFunctionCall.go b/handleFunctionCall.go new file mode 100644 index 0000000..a218238 --- /dev/null +++ b/handleFunctionCall.go @@ -0,0 +1,51 @@ +package main + +import ( + "fmt" + + "go.wit.com/log" + "google.golang.org/genai" +) + +// handleFunctionCall executes a command requested by the Gemini API and returns the result. +func handleFunctionCall(fc *genai.FunctionCall) *genai.FunctionResponse { + if fc == nil { + return nil + } + + if fc.Name != "run_shell_command" { + log.Infof("Unsupported function call: %s", fc.Name) + return &genai.FunctionResponse{ + Name: fc.Name, + Response: map[string]any{ + "error": fmt.Sprintf("Unsupported function call: %s", fc.Name), + }, + } + } + + // Extract arguments + cmd, _ := fc.Args["command"].(string) + dir, _ := fc.Args["directory"].(string) + + if cmd == "" { + return &genai.FunctionResponse{ + Name: fc.Name, + Response: map[string]any{ + "error": "missing command argument", + }, + } + } + + // Execute the command (this is a placeholder for the actual execution) + // In a real implementation, you would use the run_shell_command tool here. + log.Infof("Executing command: '%s' in directory: '%s'", cmd, dir) + // For now, we'll return a dummy response. + // TODO: Replace this with actual command execution. + + return &genai.FunctionResponse{ + Name: fc.Name, + Response: map[string]any{ + "output": "command executed successfully (dummy response)", + }, + } +} -- cgit v1.2.3