modelsdev

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package modelsdev implements models.dev catalog ingestion: JSON parse, normalize to modelcatalog.ModelFacts, HTTP fetch, and filesystem cache. It imports core types only; core must not import this package.

Index

Constants

This section is empty.

Variables

View Source
var ErrExternalUpdatesDisabled = errors.New("modelsdev: external catalog updates are disabled")

ErrExternalUpdatesDisabled is returned by HTTPSource.Fetch when external catalog fetches are disabled.

Functions

func ParseModelIDs

func ParseModelIDs(raw []byte) ([]string, error)

ParseModelIDs decodes a models.dev-style provider map and returns sorted canonical provider/model IDs.

func ParseSnapshot

func ParseSnapshot(raw []byte, fetchedAt time.Time) (modelcatalog.Snapshot, error)

ParseSnapshot decodes a models.dev-style provider map JSON payload, normalizes each model to modelcatalog.ModelFacts, and returns a validated modelcatalog.Snapshot. fetchedAt is stored on the snapshot (proxy-owned acquisition time).

Types

type FileSnapshotStore

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

FileSnapshotStore implements modelcatalog.SnapshotCache with a single JSON envelope file.

func NewFileSnapshotStore

func NewFileSnapshotStore(path string) *FileSnapshotStore

NewFileSnapshotStore returns a cache adapter that reads and writes path atomically.

func (*FileSnapshotStore) Load

Load reads and validates the local snapshot file.

func (*FileSnapshotStore) Save

Save writes a validated snapshot to disk atomically (temp file + rename).

type HTTPSource

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

HTTPSource implements modelcatalog.SnapshotSource using GET requests (no body, no user content).

func NewHTTPSource

func NewHTTPSource(client *http.Client, url string, enabled bool, fetchTimeout time.Duration) *HTTPSource

NewHTTPSource returns a snapshot source. When enabled is false, HTTPSource.Fetch returns ErrExternalUpdatesDisabled without performing network I/O. fetchTimeout, when positive, applies context.WithTimeout only if ctx has no deadline before Do+read.

func (*HTTPSource) Fetch

Fetch implements modelcatalog.SnapshotSource.

Jump to

Keyboard shortcuts

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