summaryrefslogtreecommitdiff
path: root/stats.go
blob: ae0d2c11f837efad557606ae14be90ea6bd0a904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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.
*/