From 7f8f5e3b9b37fccbb357b70e6490823a8b22ae7e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 30 Aug 2025 14:42:57 -0500 Subject: basic JSON parsing into genai struc --- stats.go | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 stats.go (limited to 'stats.go') 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. +*/ -- cgit v1.2.3