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 ¶
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 ¶
ParseModelIDs decodes a models.dev-style provider map and returns sorted canonical provider/model IDs.
func ParseSnapshot ¶
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 ¶
func (f *FileSnapshotStore) Load(ctx context.Context) (modelcatalog.Snapshot, error)
Load reads and validates the local snapshot file.
func (*FileSnapshotStore) Save ¶
func (f *FileSnapshotStore) Save(ctx context.Context, snapshot modelcatalog.Snapshot) error
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 ¶
func (h *HTTPSource) Fetch(ctx context.Context) (modelcatalog.Snapshot, error)
Fetch implements modelcatalog.SnapshotSource.