70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
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.
|
|
*/
|