MCPcopy
hub / github.com/marimo-team/marimo / parseExistingModels

Function parseExistingModels

packages/llm-info/src/sync-models.ts:76–113  ·  view source on GitHub ↗
(yamlText: string)

Source from the content-addressed store, hash-verified

74}
75
76function parseExistingModels(yamlText: string): ExistingByProvider {
77 const doc = parseDocument(yamlText);
78 if (doc.contents == null) {
79 return {};
80 }
81 if (!isMap(doc.contents)) {
82 throw new Error(
83 "Expected a map at the root of models.yml (keyed by provider)",
84 );
85 }
86 const result: Record<string, ExistingEntry[]> = {};
87 for (const pair of (doc.contents as YAMLMap).items) {
88 const provider = (pair.key as { value?: unknown })?.value;
89 if (typeof provider !== "string") {
90 continue;
91 }
92 if (!isSeq(pair.value)) {
93 result[provider] = [];
94 continue;
95 }
96 const entries: ExistingEntry[] = [];
97 for (const item of (pair.value as YAMLSeq).items) {
98 if (!isMap(item)) {
99 continue;
100 }
101 for (const subPair of (item as YAMLMap).items) {
102 const key = (subPair.key as { value?: unknown })?.value;
103 const value = (subPair.value as { value?: unknown })?.value;
104 if (key === "model" && typeof value === "string") {
105 entries.push({ model: value });
106 break;
107 }
108 }
109 }
110 result[provider] = entries;
111 }
112 return result;
113}
114
115/**
116 * Build a `YAMLMap` for one entry with the right flow-style array fields.

Callers 1

syncModelsFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…