Documentation
¶
Index ¶
- func WithCallMeta(ctx context.Context, meta CallMeta) context.Context
- type CallMeta
- type Entry
- type LimitStatus
- type Limits
- type ModelPrice
- type SignalEntry
- type SignalSummary
- type SignalSummaryRow
- type Summary
- type SummaryRow
- type TrackedClient
- type Tracker
- 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) UpdateLimits(next Limits) (Limits, error)
- type TrackerOptions
- type WarningNotifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CallMeta ¶
func CallMetaFromContext ¶
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) 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
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.