catalog

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package catalog is yottacode's source of truth for the set of cloud LLMs the wizard and TUI offer. The data lives in catalog.gen.json, regenerated by `go run ./cmd/yotta-models refresh` against each provider's list-models endpoint. Embedding the JSON keeps the binary self-contained and the user-facing flows offline-friendly.

The schema is the union of fields any provider exposes — Anthropic and Gemini populate most of it, OpenAI's list endpoint is sparse so most fields are zero-valued for OpenAI rows. Capabilities use a tristate (*bool) so renderers can distinguish "not supported" from "not reported." Picker UI shows only known-true capabilities; a verbose details view shows the full tristate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratedAt

func GeneratedAt() time.Time

GeneratedAt returns the timestamp the embedded catalog was last refreshed. Zero when the catalog is empty or pre-dates the field.

func IsCurated

func IsCurated(p config.Provider) bool

IsCurated reports whether p's kind is sourced from the embedded catalog. Useful when callers want to render different empty-state hints ("run `yotta-models refresh`" vs "couldn't reach API").

func IsCuratedKind

func IsCuratedKind(kind string) bool

IsCuratedKind is the kind-only flavor of IsCurated, for callers that have a kind string but no full config.Provider in scope (e.g. the wizard, where models live in CatalogEntry, not config.Provider).

func LoadError

func LoadError() error

LoadError returns any parse error that occurred when loading the embedded catalog. nil on success or when the catalog is empty by design.

Types

type Capabilities

type Capabilities struct {
	Thinking          *bool `json:"thinking,omitempty"`
	Vision            *bool `json:"vision,omitempty"`
	PDF               *bool `json:"pdf,omitempty"`
	StructuredOutputs *bool `json:"structured_outputs,omitempty"`
	Tools             *bool `json:"tools,omitempty"`
}

Capabilities is the small flag set we surface in the picker. *bool is intentional: nil means the provider didn't tell us, true means supported, false means explicitly not supported. Renderers should distinguish — chip rows show only true; details view shows all three states.

type File

type File struct {
	GeneratedAt time.Time `json:"generated_at,omitempty"`
	Models      []Model   `json:"models"`
}

File is the on-disk shape of catalog.gen.json. Keeping the wrapper (rather than a top-level array) gives us room to add metadata (refresh timestamp, schema version) without breaking older binaries.

type Model

type Model struct {
	ID            string       `json:"id"`
	DisplayName   string       `json:"display_name,omitempty"`
	Provider      string       `json:"provider"`
	ContextWindow int          `json:"context_window,omitempty"`
	MaxOutput     int          `json:"max_output,omitempty"`
	ReleasedAt    time.Time    `json:"released_at,omitempty"`
	Description   string       `json:"description,omitempty"`
	Capabilities  Capabilities `json:"capabilities,omitempty"`
}

Model is one entry in the catalog. Provider is always populated; every other field may be empty/zero when the source API doesn't surface that information. ID is the canonical model identifier the API will accept in subsequent calls.

func All

func All() []Model

All returns every model across every provider. Useful for the debug `/doctor` view; not used by the picker (which is always scoped to one provider). The returned slice is shared — callers must not mutate it.

func Get

func Get(provider string) []Model

Get returns the catalog entries for one provider, sorted newest- first by ReleasedAt with ID as tiebreak. Returns an empty slice when the catalog is empty or the provider isn't known. Never returns nil. The returned slice is shared — callers must not mutate it.

openai-auth is special-cased here (not just in List) because callers across the wizard / TUI / picker historically reach for Get directly. The result for openai-auth comes from the runtime per-user models file written by post-login scans, not from catalog.gen.json — see openAIAuthModels in list.go.

func List

func List(ctx context.Context, p config.Provider, apiKey string) ([]Model, error)

List returns the model list a picker should display for one provider profile. Curated providers are read out of the embedded catalog (or, for openai-auth, the runtime allow-list) and never touch the network; non-curated providers are fetched live each call. The signature is the same in both cases so callers don't branch.

Errors are returned only for live fetches — curated reads are in-memory and infallible. An empty catalog (initial state, before the maintainer runs the refresh command) returns an empty slice with no error.

func Live

func Live(ctx context.Context, kind, baseURL, apiKey string) ([]Model, error)

Live queries a provider's list-models endpoint at runtime. Used for non-curated providers — Ollama (lists locally-installed models, genuinely runtime state) and openai-compatible endpoints (xAI, NVIDIA NIM, custom proxies — too varied to script-curate).

The response is mapped onto our common Model schema, but most fields stay zero/nil because these list endpoints return only the model id. The picker shows "—" for missing fields.

Errors surface so callers can render "couldn't reach API"; they should not silently fall back, since for Ollama a failed probe usually means the daemon isn't running and the user needs to know.

func (Model) Label

func (m Model) Label() string

Label returns DisplayName when set, otherwise ID. Use this for any user-facing string; the picker should never render the bare ID when a friendlier name is available.

Jump to

Keyboard shortcuts

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