summaryrefslogtreecommitdiff
path: root/handleFunctionCall.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-01 12:23:18 -0500
committerJeff Carr <[email protected]>2025-09-01 12:23:18 -0500
commit3a1e76e65ea82f7fecb9ab923d812007436ffc57 (patch)
tree9a6cbc102e429635734853a5b075688e4e5a6164 /handleFunctionCall.go
parentc84460eb65b1776c62119ad76c567dc128c2e5fd (diff)
gemini-cli is stupid
Diffstat (limited to 'handleFunctionCall.go')
-rw-r--r--handleFunctionCall.go51
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)",
+ },
+ }
+}