fix(models): accept all models from 9router, remove claude-only filter

This commit is contained in:
Zac Gaetano 2026-06-02 12:27:53 -04:00
parent 07b6f4eb87
commit 7ed22b9077

View file

@ -17,8 +17,8 @@ let cacheExpiry = 0;
/** /**
* Maps a raw /v1/models entry to the { value, label } shape used by the UI. * Maps a raw /v1/models entry to the { value, label } shape used by the UI.
* Filters to models that are relevant for Claude routing (id contains 'claude' * Accepts all models returned by the endpoint 9router surfaces only what it
* or starts with 'cc/'). * actually routes, so no client-side filtering is needed.
* *
* @param {Object} entry - Raw model object from /v1/models * @param {Object} entry - Raw model object from /v1/models
* @returns {{ value: string, label: string } | null} * @returns {{ value: string, label: string } | null}
@ -27,14 +27,8 @@ function mapModelEntry(entry) {
const id = typeof entry?.id === 'string' ? entry.id.trim() : null; const id = typeof entry?.id === 'string' ? entry.id.trim() : null;
if (!id) return null; if (!id) return null;
// Only surface Claude-family and cc/* (9router) models for the Claude provider. // Build a human-readable label: prefer server-supplied name, then id.
// Extend this filter if you want to surface all models. // cc/* entries strip the prefix and add a "(9router)" suffix for clarity.
const isClaude = id.toLowerCase().includes('claude') || id.startsWith('cc/');
if (!isClaude) return null;
// Build a human-readable label from the id.
// e.g. "cc/claude-sonnet-4-6" → "claude-sonnet-4-6 (9router)"
// "claude-3-5-sonnet-20241022" → "claude-3-5-sonnet-20241022"
let label = entry.name ?? id; let label = entry.name ?? id;
if (id.startsWith('cc/')) { if (id.startsWith('cc/')) {
label = `${id.slice(3)} (9router)`; label = `${id.slice(3)} (9router)`;
@ -80,7 +74,7 @@ async function fetchModelsFromApi() {
const mapped = raw.map(mapModelEntry).filter(Boolean); const mapped = raw.map(mapModelEntry).filter(Boolean);
if (mapped.length === 0) return null; if (mapped.length === 0) return null;
console.log(`[model-discovery] Loaded ${mapped.length} Claude models from ${url}`); console.log(`[model-discovery] Loaded ${mapped.length} models from ${url}`);
return mapped; return mapped;
} catch (err) { } catch (err) {
console.warn(`[model-discovery] Failed to fetch ${url}:`, err?.message ?? err); console.warn(`[model-discovery] Failed to fetch ${url}:`, err?.message ?? err);