Documentation
¶
Index ¶
- func WithCallMeta(ctx context.Context, meta CallMeta) context.Context
- type Analytics
- type AnalyticsDailyRow
- type AnalyticsModelRow
- type AnalyticsSkillRow
- type AnalyticsTotals
- type CallMeta
- type DailyTokenSummary
- type Entry
- type LimitStatus
- type Limits
- type ModelPrice
- type SignalEntry
- type SignalSummary
- type SignalSummaryRow
- type Summary
- type SummaryRow
- type TrackedClient
- func (c *TrackedClient) Ask(ctx context.Context, prompt string) (string, error)
- func (c *TrackedClient) Chat(ctx context.Context, messages []llm.ChatMessage, opts llm.ChatOptions) (llm.ChatResponse, error)
- func (c *TrackedClient) Inner() llm.Client
- func (c *TrackedClient) LastCodexRateLimit() (llm.CodexRateLimitSnapshot, bool)
- func (c *TrackedClient) SetNotifier(notifier WarningNotifier)
- type Tracker
- func (t *Tracker) Analytics(days int) (Analytics, error)
- func (t *Tracker) CheckLimitStatus() (LimitStatus, error)
- func (t *Tracker) EstimateCost(provider, model string, u llm.Usage) (float64, bool)
- func (t *Tracker) Limits() Limits
- func (t *Tracker) Record(entry Entry) error
- func (t *Tracker) RecordSignal(entry SignalEntry) error
- func (t *Tracker) Signals(period string) (SignalSummary, error)
- func (t *Tracker) Summary(period, groupBy string) (Summary, error)
- func (t *Tracker) TodayTokens() (DailyTokenSummary, error)
- func (t *Tracker) UpdateLimits(next Limits) (Limits, error)
- type TrackerOptions
- type WarningNotifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Analytics ¶ added in v0.31.87
type Analytics struct {
Days int `json:"days"`
Totals AnalyticsTotals `json:"totals"`
Daily []AnalyticsDailyRow `json:"daily"`
Models []AnalyticsModelRow `json:"models"`
Skills []AnalyticsSkillRow `json:"skills"`
}
type AnalyticsDailyRow ¶ added in v0.31.87
type AnalyticsModelRow ¶ added in v0.31.87
type AnalyticsModelRow struct {
Provider string `json:"provider"`
Model string `json:"model"`
Calls int `json:"calls"`
Sessions int `json:"sessions"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
TotalTokens int `json:"total_tokens"`
CostUSD float64 `json:"cost_usd"`
}
type AnalyticsSkillRow ¶ added in v0.31.87
type AnalyticsTotals ¶ added in v0.31.87
type CallMeta ¶
func CallMetaFromContext ¶
type DailyTokenSummary ¶ added in v0.31.79
type DailyTokenSummary struct {
Date string `json:"date"`
ResetAt string `json:"reset_at"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
TotalTokens int `json:"total_tokens"`
BudgetTokens int `json:"budget_tokens"`
BudgetEnabled bool `json:"budget_enabled"`
UsagePercent float64 `json:"usage_percent"`
Level string `json:"level"`
}
type Entry ¶
type Entry struct {
Timestamp time.Time `json:"timestamp"`
Provider string `json:"provider"`
Model string `json:"model"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CachedTokens int `json:"cached_tokens,omitempty"`
CacheReadTokens int `json:"cache_read_tokens,omitempty"`
CacheWriteTokens int `json:"cache_write_tokens,omitempty"`
EstimatedCostUSD float64 `json:"estimated_cost_usd"`
Source string `json:"source"`
SessionID string `json:"session_id,omitempty"`
RunID string `json:"run_id,omitempty"`
PricingKnown bool `json:"pricing_known"`
}
type LimitStatus ¶
type ModelPrice ¶
type SignalEntry ¶ added in v0.31.6
type SignalEntry struct {
Timestamp time.Time `json:"timestamp"`
Name string `json:"name"`
Count int `json:"count"`
Source string `json:"source,omitempty"`
SessionID string `json:"session_id,omitempty"`
RunID string `json:"run_id,omitempty"`
Dimensions map[string]string `json:"dimensions,omitempty"`
}
type SignalSummary ¶ added in v0.31.6
type SignalSummary struct {
Period string `json:"period"`
TotalCount int `json:"total_count"`
Rows []SignalSummaryRow `json:"rows"`
}
type SignalSummaryRow ¶ added in v0.31.6
type Summary ¶
type Summary struct {
Period string `json:"period"`
GroupBy string `json:"group_by"`
TotalCalls int `json:"total_calls"`
TotalCostUSD float64 `json:"total_cost_usd"`
TotalInput int `json:"total_input_tokens"`
TotalOutput int `json:"total_output_tokens"`
TotalCached int `json:"total_cached_tokens"`
TotalCacheRead int `json:"total_cache_read_tokens"`
TotalCacheWrite int `json:"total_cache_write_tokens"`
Rows []SummaryRow `json:"rows"`
}
type SummaryRow ¶
type SummaryRow struct {
Key string `json:"key"`
Calls int `json:"calls"`
CostUSD float64 `json:"cost_usd"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CachedTokens int `json:"cached_tokens"`
CacheReadTokens int `json:"cache_read_tokens"`
CacheWriteTokens int `json:"cache_write_tokens"`
}
type TrackedClient ¶
type TrackedClient struct {
// contains filtered or unexported fields
}
func NewTrackedClient ¶
func (*TrackedClient) Chat ¶
func (c *TrackedClient) Chat(ctx context.Context, messages []llm.ChatMessage, opts llm.ChatOptions) (llm.ChatResponse, error)
func (*TrackedClient) Inner ¶ added in v0.32.28
func (c *TrackedClient) Inner() llm.Client
Inner returns the wrapped llm.Client. Lets server-side wiring unwrap the concrete provider client (e.g. OpenAICodexClient) when it needs to attach provider-specific callbacks like rate-limit observers.
func (*TrackedClient) LastCodexRateLimit ¶ added in v0.32.27
func (c *TrackedClient) LastCodexRateLimit() (llm.CodexRateLimitSnapshot, bool)
LastCodexRateLimit forwards to the inner client when it implements llm.CodexRateLimitSource. Lets admin handlers fish a Codex rate-limit snapshot out of the router without unwrapping the TrackedClient manually.
func (*TrackedClient) SetNotifier ¶
func (c *TrackedClient) SetNotifier(notifier WarningNotifier)
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
func NewTracker ¶
func NewTracker(workspaceDir string, opts TrackerOptions) (*Tracker, error)
func (*Tracker) CheckLimitStatus ¶
func (t *Tracker) CheckLimitStatus() (LimitStatus, error)
func (*Tracker) EstimateCost ¶
func (*Tracker) RecordSignal ¶ added in v0.31.6
func (t *Tracker) RecordSignal(entry SignalEntry) error
func (*Tracker) Signals ¶ added in v0.31.6
func (t *Tracker) Signals(period string) (SignalSummary, error)
func (*Tracker) TodayTokens ¶ added in v0.31.79
func (t *Tracker) TodayTokens() (DailyTokenSummary, error)
type TrackerOptions ¶
type TrackerOptions struct {
Now func() time.Time
InitialLimits Limits
PriceOverrides map[string]ModelPrice
}
type WarningNotifier ¶
Click to show internal directories.
Click to hide internal directories.