Documentation
¶
Overview ¶
Package catalog reads the Codex model catalog (GET {base_url}/models, or $CODEX_HOME/models_cache.json read-only) and answers two questions: which models share a compatibility group, and how large a model's usable context window is. Field names follow models_cache.json as fetched by codex 0.162.1.
Index ¶
Constants ¶
const CacheCheckEvery = 5 * time.Second
CacheCheckEvery is how often a CacheWatch looks at its file at most.
const CacheFile = "models_cache.json"
CacheFile is Codex's models cache in a Codex home.
const ToolModeNone = "none"
ToolModeNone is the tool_mode of an entry that has no tool_mode field.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheWatch ¶ added in v0.3.0
type CacheWatch struct {
// contains filtered or unexported fields
}
CacheWatch reloads a models_cache.json into a Store when Codex rewrites it, for a router that sees no /models replies and outlives Codex's model refreshes (the brain).
func NewCacheWatch ¶ added in v0.3.0
func NewCacheWatch(path string, store *Store, now func() time.Time) *CacheWatch
NewCacheWatch watches the cache at path for store; a nil now is time.Now.
func (*CacheWatch) Check ¶ added in v0.3.0
func (w *CacheWatch) Check() (reloaded bool, err error)
Check looks at the file, at most once per CacheCheckEvery, and when its modification time or size changed loads it into the store. A missing file changes nothing. A file that does not read or parse keeps the last catalog and is tried again once it changes. reloaded reports a new catalog.
type Catalog ¶
Catalog is a parsed /models body.
func LoadCache ¶
LoadCache reads a models_cache.json. A missing file yields an empty catalog, not an error. The file is never written.
func (Catalog) Compatible ¶
Compatible reports whether both models are known and share a Group.
type Group ¶
type Group struct {
CompHash string `json:"CompHash"`
Lite bool `json:"Lite"`
ToolMode string `json:"ToolMode"`
}
Group is the compatibility key: a per-step rewrite is safe only between models with an equal Group (research §1.2, spikes 3-5). A Snapshot carries it on the control wire, so its JSON names are spelled out and pinned by internal/control's protocol-v2 fixtures.
type Model ¶
type Model struct {
Slug string `json:"slug"`
Visibility string `json:"visibility"`
ContextWindow int `json:"context_window"`
MaxContextWindow int `json:"max_context_window"`
EffectivePercent int `json:"effective_context_window_percent"`
CompHash string `json:"comp_hash"`
ResponsesLite bool `json:"use_responses_lite"`
ToolMode string `json:"tool_mode"`
ReasoningLevels []ReasoningLevel `json:"supported_reasoning_levels"`
// DefaultEffort is the effort Codex runs the model at when its settings
// name none.
DefaultEffort config.Effort `json:"default_reasoning_level"`
}
Model is one catalog entry. Only the fields the router reads are decoded.
func (*Model) UnmarshalJSON ¶
UnmarshalJSON applies Codex's default for an absent effective_context_window_percent; an explicit 0 stays 0.
type ReasoningLevel ¶
ReasoningLevel is one entry of supported_reasoning_levels.
type Source ¶
type Source interface {
Current() Catalog
}
Source is what consumers read the current catalog through.