Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 22 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions src/lib/server/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,17 @@ const buildModels = async (): Promise<ProcessedModel[]> => {
}
}

// Track which overrides matched existing models
const matchedOverrideKeys = new Set<string>();

modelsRaw = modelsRaw.map((model) => {
const override = overrideMap.get(model.id ?? "") ?? overrideMap.get(model.name ?? "");
if (!override) return model;

// Mark this override as matched
if (model.id) matchedOverrideKeys.add(model.id);
if (model.name) matchedOverrideKeys.add(model.name);

const { id, name, ...rest } = override;
void id;
void name;
Expand All @@ -391,6 +398,39 @@ const buildModels = async (): Promise<ProcessedModel[]> => {
...rest,
};
});

// Add models from MODELS that didn't match any discovered model (new models)
for (const override of overrides) {
const overrideId = override.id?.trim() || override.name?.trim();
if (!overrideId) continue;

// Skip if this override already matched an existing model
if (matchedOverrideKeys.has(overrideId)) continue;
if (override.id && matchedOverrideKeys.has(override.id)) continue;
if (override.name && matchedOverrideKeys.has(override.name)) continue;

// This is a new model - add it
// Ensure it has required fields and endpoints
if (override.endpoints && override.endpoints.length > 0) {
const newModel: ModelConfig = {
id: override.id || override.name || overrideId,
name: override.name || override.id || overrideId,
displayName: override.displayName,
description: override.description,
logoUrl: override.logoUrl,
endpoints: override.endpoints,
parameters: override.parameters,
multimodal: override.multimodal ?? false,
multimodalAcceptedMimetypes: override.multimodalAcceptedMimetypes,
supportsTools: override.supportsTools ?? false,
unlisted: override.unlisted ?? false,
preprompt: override.preprompt ?? "",
systemRoleSupported: override.systemRoleSupported ?? true,
};
modelsRaw.push(newModel);
logger.info({ modelId: newModel.id }, "[models] Added new model from MODELS env");
}
}
}

const builtModels = await Promise.all(
Expand Down
Loading