Documentation
¶
Index ¶
- type ActivityRecord
- type BudgetStatus
- type Calculator
- type CommandStats
- type ForecastStats
- type Manager
- func (m *Manager) CheckBudget(estimatedCost float64) (*BudgetStatus, error)
- func (m *Manager) GetBreakdownByCommand() (*StatsBreakdown, error)
- func (m *Manager) GetCacheStats() (hitRate float64, totalSaved float64, err error)
- func (m *Manager) GetDailyTotal() (float64, error)
- func (m *Manager) GetForecast() (*ForecastStats, error)
- func (m *Manager) GetHistory() ([]ActivityRecord, error)
- func (m *Manager) GetMonthlyTotal() (float64, error)
- func (m *Manager) SaveActivity(record ActivityRecord) error
- type PricingTable
- type ProviderPricing
- type StatsBreakdown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivityRecord ¶
type ActivityRecord struct {
Timestamp time.Time `json:"timestamp"`
Command string `json:"command"`
Provider string `json:"provider"`
Model string `json:"model"`
TokensInput int `json:"tokens_input"`
TokensOutput int `json:"tokens_output"`
CostUSD float64 `json:"cost_usd"`
DurationMs int64 `json:"duration_ms"`
CacheHit bool `json:"cache_hit"`
Hash string `json:"hash"`
}
type BudgetStatus ¶
type Calculator ¶
type Calculator struct{}
func NewCalculator ¶
func NewCalculator() *Calculator
func (*Calculator) AddPricing ¶
func (c *Calculator) AddPricing(provider, model string, table PricingTable)
AddPricing allows adding pricing dynamically (useful for testing or new models)
func (*Calculator) EstimateCost ¶
func (c *Calculator) EstimateCost(provider, model string, inputTokens, outputTokens int) (float64, bool)
EstimateCost calculates the estimated cost based on provider, model, and tokens. The second return value is false when no pricing entry could be found for the given provider/model, in which case the cost is not zero — it's simply unknown.
func (*Calculator) GetPricing ¶
func (c *Calculator) GetPricing(provider, model string) (PricingTable, error)
GetPricing returns the pricing table for a provider and model
type CommandStats ¶ added in v1.6.0
type ForecastStats ¶ added in v1.6.0
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) CheckBudget ¶
func (m *Manager) CheckBudget(estimatedCost float64) (*BudgetStatus, error)
CheckBudget checks if the estimated cost exceeds the daily budget
func (*Manager) GetBreakdownByCommand ¶ added in v1.6.0
func (m *Manager) GetBreakdownByCommand() (*StatsBreakdown, error)
GetBreakdownByCommand returns usage statistics grouped by command
func (*Manager) GetCacheStats ¶ added in v1.6.0
GetCacheStats returns cache hit statistics
func (*Manager) GetDailyTotal ¶
GetDailyTotal gets the total spent today
func (*Manager) GetForecast ¶ added in v1.6.0
func (m *Manager) GetForecast() (*ForecastStats, error)
GetForecast calculates projected monthly spending
func (*Manager) GetHistory ¶
func (m *Manager) GetHistory() ([]ActivityRecord, error)
GetHistory gets all records
func (*Manager) GetMonthlyTotal ¶
GetMonthlyTotal gets the total spent this month
func (*Manager) SaveActivity ¶
func (m *Manager) SaveActivity(record ActivityRecord) error
SaveActivity saves an activity record, pruning entries older than historyRetentionDays so the history file doesn't grow unbounded.
type PricingTable ¶
type ProviderPricing ¶
type ProviderPricing map[string]map[string]PricingTable
type StatsBreakdown ¶ added in v1.6.0
type StatsBreakdown struct {
ByCommand []CommandStats
TotalCalls int
TotalCost float64
}