Documentation
¶
Index ¶
- func PublishRecord(ctx context.Context, record Record)
- func RegisterPlugin(plugin Plugin)
- func RequestedModelAliasFromContext(ctx context.Context) string
- func StartDefault(ctx context.Context)
- func StopDefault()
- func WithRequestedModelAlias(ctx context.Context, alias string) context.Context
- type Detail
- type Manager
- type Plugin
- type Record
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PublishRecord ¶
PublishRecord publishes a record using the default manager.
func RegisterPlugin ¶
func RegisterPlugin(plugin Plugin)
RegisterPlugin registers a plugin on the default manager.
func RequestedModelAliasFromContext ¶ added in v6.10.7
RequestedModelAliasFromContext returns the client-requested model name stored in ctx.
func StartDefault ¶
StartDefault starts the default manager's dispatcher.
Types ¶
type Detail ¶
type Detail struct {
InputTokens int64
OutputTokens int64
ReasoningTokens int64
CachedTokens int64
TotalTokens int64
}
Detail holds the token usage breakdown.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager maintains a queue of usage records and delivers them to registered plugins.
func DefaultManager ¶
func DefaultManager() *Manager
DefaultManager returns the global usage manager instance.
func NewManager ¶
NewManager constructs a manager with a buffered queue.
func (*Manager) Publish ¶
Publish enqueues a usage record for processing. If no plugin is registered the record will be discarded downstream.
type Record ¶
type Record struct {
Provider string
Model string
Alias string
APIKey string
AuthID string
AuthIndex string
AuthType string
Source string
RequestedAt time.Time
Latency time.Duration
Failed bool
Detail Detail
}
Record contains the usage statistics captured for a single provider request.