feat(model): fuzzy /model matching

This commit is contained in:
Peter Steinberger
2026-01-12 07:57:11 +00:00
parent e79cf5a8b1
commit 60823fd9bd
6 changed files with 270 additions and 23 deletions

View File

@@ -179,14 +179,23 @@ export function buildAllowedModelSet(params: {
}
const allowedKeys = new Set<string>();
const configuredProviders = (params.cfg.models?.providers ?? {}) as Record<
string,
unknown
>;
for (const raw of rawAllowlist) {
const parsed = parseModelRef(String(raw), params.defaultProvider);
if (!parsed) continue;
const key = modelKey(parsed.provider, parsed.model);
const providerKey = normalizeProviderId(parsed.provider);
if (isCliProvider(parsed.provider, params.cfg)) {
allowedKeys.add(key);
} else if (catalogKeys.has(key)) {
allowedKeys.add(key);
} else if (configuredProviders[providerKey] != null) {
// Explicitly configured providers should be allowlist-able even when
// they don't exist in the curated model catalog.
allowedKeys.add(key);
}
}