2026-06-14 02:15:48 -04:00
|
|
|
import { deriveModelName } from "./namePatterns.js";
|
|
|
|
|
|
2026-06-13 10:13:37 -04:00
|
|
|
// Model defaults centralized (was scattered as `m.type || "llm"`, `quotaFamily || "normal"`, etc.)
|
2026-06-13 06:05:42 -04:00
|
|
|
export const MODEL_DEFAULTS = {
|
|
|
|
|
type: "llm",
|
|
|
|
|
quotaFamily: "normal",
|
|
|
|
|
strip: [],
|
2026-06-13 10:13:37 -04:00
|
|
|
targetFormat: null
|
2026-06-13 06:05:42 -04:00
|
|
|
};
|
|
|
|
|
|
2026-06-14 02:15:48 -04:00
|
|
|
// Normalize a registry model entry: accept terse "id" string, fill name via regex when omitted.
|
|
|
|
|
// Override always wins (raw spread last); name falls back to regex → id.
|
|
|
|
|
export function normalizeModel(raw) {
|
|
|
|
|
const model = typeof raw === "string" ? { id: raw } : raw;
|
|
|
|
|
if (model.name !== undefined) return model;
|
|
|
|
|
return { ...model, name: deriveModelName(model.id) };
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-13 10:13:37 -04:00
|
|
|
// Resolve a single field with its default (keeps accessor call-sites one-liners)
|
|
|
|
|
export function modelType(model) {
|
|
|
|
|
return model?.type || MODEL_DEFAULTS.type;
|
2026-06-13 06:05:42 -04:00
|
|
|
}
|
2026-06-13 10:13:37 -04:00
|
|
|
export function modelQuotaFamily(model) {
|
|
|
|
|
return model?.quotaFamily || MODEL_DEFAULTS.quotaFamily;
|
|
|
|
|
}
|
|
|
|
|
export function modelStrip(model) {
|
|
|
|
|
return model?.strip || [];
|
|
|
|
|
}
|
|
|
|
|
export function modelTargetFormat(model) {
|
|
|
|
|
return model?.targetFormat || MODEL_DEFAULTS.targetFormat;
|
2026-06-13 06:05:42 -04:00
|
|
|
}
|