models

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package models contains the generated model catalog and its persisted refresh overlay.

Package models contains the generated model catalog and runtime refresh layer.

Index

Constants

View Source
const ModelsDevURL = "https://models.dev/api.json"

Variables

This section is empty.

Functions

func BuiltinImages

func BuiltinImages(provider ai.ImagesProviderID) []ai.ImagesModel

func PiUserAgent

func PiUserAgent(version string) string

PiUserAgent formats the catalog-refresh User-Agent, mirroring upstream getPiUserAgent (pi-user-agent.ts).

Types

type Catalog

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

Catalog is an immutable-by-convention provider/model lookup.

func Builtin

func Builtin() (*Catalog, error)

Builtin loads the catalog generated from the committed models.dev snapshot.

func Decode

func Decode(data []byte) (*Catalog, error)

Decode loads the normalized provider-keyed catalog shape.

func LoadStore

func LoadStore(path string) (*Catalog, error)

LoadStore restores the provider-scoped models-store.json overlay. Entries for providers bundled in the builtin catalog lose to a newer builtin: the overlay only applies when its lastModified is newer than the bundled catalog build time (upstream remote-catalog-provider.ts remoteModels).

func Refresh

func Refresh(ctx context.Context, options RefreshOptions) (*Catalog, error)

Refresh fetches models.dev and replaces only fetched providers in the persisted dynamic overlay. A completed refresh within the last 4 hours skips the network and returns the stored overlay (upstream remote-catalog-provider.ts gates on checkedAt plus lastModified presence).

func (*Catalog) Find

func (catalog *Catalog) Find(provider, id string) (ai.Model, bool)

Find returns a detached model value.

func (*Catalog) MarshalJSON

func (catalog *Catalog) MarshalJSON() ([]byte, error)

func (*Catalog) Merge

func (catalog *Catalog) Merge(overlay *Catalog) *Catalog

Merge overlays models by provider and id.

func (*Catalog) Models

func (catalog *Catalog) Models(provider ...string) []ai.Model

Models returns detached model values sorted by provider and model id.

type RefreshOptions

type RefreshOptions struct {
	URL       string
	StorePath string
	Client    *http.Client
	Now       func() time.Time
	// UserAgent identifies the client on the catalog request (upstream sends a
	// pi User-Agent from remote-catalog-provider.ts).
	UserAgent string
	// Force bypasses the checkedAt refresh gate.
	Force bool
}

Directories

Path Synopsis
cmd
genmodels command
internal
cataloggen
Package cataloggen normalizes the models.dev api.json shape into pi models.
Package cataloggen normalizes the models.dev api.json shape into pi models.

Jump to

Keyboard shortcuts

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