catalog

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 Catalog

type Catalog struct {
	Models map[string]Model
}

Catalog is a parsed /models body.

func LoadCache

func LoadCache(path string) (Catalog, error)

LoadCache reads a models_cache.json. A missing file yields an empty catalog, not an error. The file is never written.

func Parse

func Parse(body []byte) (Catalog, error)

Parse decodes a /models response body.

func (Catalog) Compatible

func (c Catalog) Compatible(a, b string) bool

Compatible reports whether both models are known and share a Group.

func (Catalog) GroupOf

func (c Catalog) GroupOf(slug string) (Group, bool)

GroupOf returns the compatibility group of slug.

func (Catalog) Window

func (c Catalog) Window(slug string) (int, bool)

Window is the usable context in tokens: context_window x percent / 100. A missing model, or a non-positive window or percent, is unknown.

type Group

type Group struct {
	CompHash string
	Lite     bool
	ToolMode string
}

Group is the compatibility key: a per-step rewrite is safe only between models with an equal Group (research §1.2, spikes 3-5).

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"`
}

Model is one catalog entry. Only the fields the router reads are decoded.

func (*Model) UnmarshalJSON

func (m *Model) UnmarshalJSON(b []byte) error

UnmarshalJSON applies Codex's default for an absent effective_context_window_percent; an explicit 0 stays 0.

type ReasoningLevel

type ReasoningLevel struct {
	Effort config.Effort `json:"effort"`
}

ReasoningLevel is one entry of supported_reasoning_levels.

type Source

type Source interface {
	Current() Catalog
}

Source is what consumers read the current catalog through.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store holds the current catalog for concurrent readers and writers.

func (*Store) Current

func (s *Store) Current() Catalog

Current returns the latest catalog; the zero Catalog before the first Set.

func (*Store) Set

func (s *Store) Set(c Catalog)

Set replaces the catalog.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL