diff options
Diffstat (limited to 'handleFunctionCall.go')
| -rw-r--r-- | handleFunctionCall.go | 51 |
1 files changed, 51 insertions, 0 deletions
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)", + }, + } +} |
