Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregator ¶
Aggregator collects usage grouped by model name.
func FromContext ¶
func FromContext(ctx context.Context) *Aggregator
func WithAggregator ¶
func WithAggregator(ctx context.Context) (context.Context, *Aggregator)
WithAggregator injects Aggregator into context.
func (*Aggregator) Add ¶
func (a *Aggregator) Add(model string, prompt, completion, embed, cached int)
Add records token counts for a specific model. Add records token counts for a specific model. Cached tokens are optional – pass 0 when not applicable.
func (*Aggregator) Keys ¶
func (a *Aggregator) Keys() []string
Keys returns sorted list of model names.
func (*Aggregator) OnUsage ¶
func (a *Aggregator) OnUsage(model string, u *llm.Usage)
OnUsage satisfies provider/base.UsageListener interface allowing Aggregator to be passed directly to provider clients. It records the supplied usage figures under the given model name.
func (*Aggregator) Totals ¶ added in v0.2.25
func (a *Aggregator) Totals() (prompt, completion, embed, cached int)
Totals returns accumulated prompt, completion, embedding and cached tokens across all tracked models. It is primarily intended for tests and reporting.
Click to show internal directories.
Click to hide internal directories.