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

Function resolveBaseModel

packages/core/src/sync/index.ts:474–505  ·  view source on GitHub ↗
(
  authored: ExistingModel,
  modelMetadata: Record<string, Record<string, unknown>>,
  modelPath: string,
)

Source from the content-addressed store, hash-verified

472}
473
474function resolveBaseModel(
475 authored: ExistingModel,
476 modelMetadata: Record<string, Record<string, unknown>>,
477 modelPath: string,
478) {
479 const baseModelID = authored.base_model;
480 if (baseModelID === undefined) return authored;
481
482 const base = modelMetadata[baseModelID];
483 if (base === undefined) {
484 throw new Error(`Unable to resolve base_model: ${baseModelID}`, {
485 cause: { modelPath, toml: authored },
486 });
487 }
488
489 const merged = structuredClone(
490 mergeDeep(
491 base,
492 Object.fromEntries(
493 Object.entries(authored).filter(([, value]) => value !== undefined),
494 ),
495 ),
496 ) as Record<string, unknown>;
497 applyOmit(merged, authored.base_model_omit ?? []);
498
499 const parsed = ExistingModel.safeParse(merged);
500 if (!parsed.success) {
501 parsed.error.cause = { modelPath, toml: merged };
502 throw parsed.error;
503 }
504 return parsed.data as ExistingModel;
505}
506
507function inheritableModelMetadata(model: Record<string, unknown>) {
508 const {

Callers 1

readExistingFunction · 0.70

Calls 1

applyOmitFunction · 0.70

Tested by

no test coverage detected