MCPcopy Create free account
hub / github.com/docker/docker-agent / embeddedSnapshot

Function embeddedSnapshot

pkg/modelsdev/snapshot.go:40–51  ·  view source on GitHub ↗

embeddedSnapshot returns the catalog baked into the binary at build time. The JSON is parsed once and cached. A malformed snapshot yields an empty (non-nil) database rather than a panic, so a bad embed degrades to "provider not found" instead of crashing the process. The parse failure is logged beca

()

Source from the content-addressed store, hash-verified

38// logged because, with the hardcoded context-limit fallback gone, a corrupt
39// snapshot would otherwise silently clamp large-context models with no signal.
40func embeddedSnapshot() *Database {
41 snapshotOnce.Do(func() {
42 var providers map[string]Provider
43 if err := json.Unmarshal(snapshotJSON, &providers); err != nil {
44 slog.Warn("embedded models.dev snapshot is malformed; context-window limits will be wrong", "error", err)
45 snapshotDB = &Database{}
46 return
47 }
48 snapshotDB = &Database{Providers: providers}
49 })
50 return snapshotDB
51}
52
53// SnapshotDate returns the time the embedded models.dev snapshot was
54// generated. The zero value is returned when the recorded date can't be

Callers 2

loadDatabaseFunction · 0.85

Calls 2

WarnMethod · 0.80
DoMethod · 0.65

Tested by 1