Documentation
¶
Overview ¶
Package observations tracks per-(provider,model) speed samples for use by routing strategies.
Index ¶
- func DefaultStorePath() string
- func PopulateFromLogs(store *Store, logDir string) error
- type Key
- type Ring
- type Sample
- type Store
- func (s *Store) Add(key Key, sample Sample)
- func (s *Store) AllKeys() []Key
- func (s *Store) MarshalYAML() (interface{}, error)
- func (s *Store) MeanSpeed(key Key) (float64, bool)
- func (s *Store) RingFor(key Key) *Ring
- func (s *Store) Save(path string) error
- func (s *Store) UnmarshalYAML(value *yaml.Node) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultStorePath ¶
func DefaultStorePath() string
DefaultStorePath returns the path for the observations file, respecting XDG. If the DDX_OBSERVATIONS_FILE environment variable is set, it takes precedence.
func PopulateFromLogs ¶
PopulateFromLogs reads all JSONL session files in logDir and adds speed observations to the store for successful sessions.
Types ¶
type Ring ¶
type Ring struct {
Capacity int `yaml:"capacity"`
Samples []Sample `yaml:"samples"`
// contains filtered or unexported fields
}
Ring is a fixed-capacity circular buffer of Samples.
type Sample ¶
type Sample struct {
OutputTokensPerSec float64 `yaml:"output_tokens_per_sec"`
DurationMs int64 `yaml:"duration_ms"`
RecordedAt time.Time `yaml:"recorded_at"`
}
Sample is one speed observation.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds one Ring per Key. Internally uses a flat "providerSystem:model" string key for simplicity.
func LoadStore ¶
LoadStore reads a Store from path. Returns an empty store on not-found. If the DDX_OBSERVATIONS_FILE env var is set and path is DefaultStorePath(), the env var value takes precedence (handled by DefaultStorePath).
func (*Store) Add ¶
Add records a sample for the given key, auto-creating a Ring(cap=200) if needed.
func (*Store) MarshalYAML ¶
MarshalYAML serializes the store as a sequence of entries.