MCPcopy Index your code
hub / github.com/anomalyco/models.dev / loadProviderBaseModelRefs

Function loadProviderBaseModelRefs

packages/web/src/render.tsx:149–178  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

147}
148
149async function loadProviderBaseModelRefs(root: string) {
150 const refs = new Map<string, string>();
151 const providersDirectory = path.join(root, "providers");
152 if (!existsSync(providersDirectory)) return refs;
153
154 for await (const modelPath of new Bun.Glob("*/models/**/*.toml").scan({
155 cwd: providersDirectory,
156 absolute: true,
157 followSymlinks: true,
158 })) {
159 const parts = path.relative(providersDirectory, modelPath).split(path.sep);
160 const [providerId, modelsSegment, ...modelParts] = parts;
161 if (!providerId || modelsSegment !== "models" || modelParts.length === 0) {
162 continue;
163 }
164
165 const modelId = modelParts.join("/").slice(0, -5);
166 const toml = await import(modelPath, {
167 with: {
168 type: "toml",
169 },
170 }).then((mod) => mod.default as { base_model?: unknown });
171
172 if (typeof toml.base_model === "string") {
173 refs.set(`${providerId}/${modelId}`, toml.base_model);
174 }
175 }
176
177 return refs;
178}
179
180function buildModelEntries() {
181 const entries = new Map<string, ModelEntry>();

Callers 1

render.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected