diff options
| author | Jeff Carr <[email protected]> | 2025-08-30 14:42:57 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-08-30 14:42:57 -0500 |
| commit | 7f8f5e3b9b37fccbb357b70e6490823a8b22ae7e (patch) | |
| tree | 11b6f74e8d3f33b3fdb82421cb79653f65685fe8 /stats.go | |
| parent | c971bfddf74d48d87f10f5f050b1eef3fd12bf20 (diff) | |
basic JSON parsing into genai struc
Diffstat (limited to 'stats.go')
| -rw-r--r-- | stats.go | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/stats.go b/stats.go new file mode 100644 index 0000000..ae0d2c1 --- /dev/null +++ b/stats.go @@ -0,0 +1,69 @@ +package main + +/* + // The following are the Go equivalents of the gemini-cli's TypeScript + // interfaces for session statistics. You can use these to collect and + // store metrics in your application. + + // ToolCallDecision represents the user's decision on a tool call. + type ToolCallDecision string + + const ( + Accept ToolCallDecision = "accept" + Reject ToolCallDecision = "reject" + Modify ToolCallDecision = "modify" + AutoAccept ToolCallDecision = "auto_accept" + ) + + // ToolCallStats holds the statistics for a single tool. + type ToolCallStats struct { + Count int + Success int + Fail int + DurationMs int + Decisions map[ToolCallDecision]int + } + + // ModelMetrics holds the statistics for a single model. + type ModelMetrics struct { + API struct { + TotalRequests int + TotalErrors int + TotalLatencyMs int + } + Tokens struct { + Prompt int + Candidates int + Total int + Cached int + Thoughts int + Tool int + } + } + + // SessionMetrics holds all the statistics for a session. + type SessionMetrics struct { + Models map[string]ModelMetrics + Tools struct { + TotalCalls int + TotalSuccess int + TotalFail int + TotalDurationMs int + TotalDecisions map[ToolCallDecision]int + ByName map[string]ToolCallStats + } + Files struct { + TotalLinesAdded int + TotalLinesRemoved int + } + } + + // You will need to initialize and update this struct as your application + // makes API calls and runs tools. + var sessionMetrics SessionMetrics + + // Example of how you might update the metrics after an API call: + // modelMetrics := sessionMetrics.Models["gemini-pro"] + // modelMetrics.API.TotalRequests++ + // ... and so on. +*/ |
