mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-24 08:02:14 +03:00
fix(providers): filter Perplexity model import to the Sonar family (#11060)
Inherited base-red at merge time (discriminated against the pure base tip, both reproduce WITHOUT this diff): getTokenLimit test + Vietnamese i18n key parity (new UI strings merged untranslated) + No new ESLint warnings gate. Merge integrity, Docs Gates, Vitest, Fast Production Build: green.
This commit is contained in:
committed by
GitHub
parent
742ccb98a0
commit
9629693a3c
@@ -87,6 +87,22 @@ export function parseAlibabaModelStudioModelsForConnection(
|
||||
export function parseQwenCloudTextModels(data: any): any[] {
|
||||
return parseCuratedDashscopeModels(data, QWEN_CLOUD_TEXT_MODELS, QWEN_CLOUD_TEXT_MODEL_IDS);
|
||||
}
|
||||
|
||||
// Perplexity's /v1/models lists the Agent API catalog (vendor-prefixed ids like
|
||||
// "anthropic/claude-fable-5"), but chat requests always go to the classic
|
||||
// /chat/completions endpoint, which only accepts the Sonar family. Filter
|
||||
// discovery to Sonar-family ids so agent-style ids never surface as routable
|
||||
// chat models (#11060). Bounded pattern — no ReDoS-prone quantifiers.
|
||||
export function parsePerplexitySonarModels(data: any): any[] {
|
||||
const models = Array.isArray(data?.data)
|
||||
? data.data
|
||||
: Array.isArray(data?.models)
|
||||
? data.models
|
||||
: [];
|
||||
return models.filter(
|
||||
(model: any) => typeof model?.id === "string" && /^sonar(-|$)/.test(model.id)
|
||||
);
|
||||
}
|
||||
type ProviderModelsHeaderContext = {
|
||||
authType?: string;
|
||||
providerSpecificData?: unknown;
|
||||
@@ -659,6 +675,17 @@ export const PROVIDER_MODELS_CONFIG: Record<string, ProviderModelsConfigEntry> =
|
||||
headers: { Accept: "application/json" },
|
||||
parseResponse: parseClinepassRecommendedModels,
|
||||
},
|
||||
// Perplexity's /v1/models lists the Agent API catalog (vendor-prefixed agent
|
||||
// ids), but chat only accepts the Sonar family on /chat/completions. Import
|
||||
// must keep Sonar-family ids only (#11060).
|
||||
perplexity: {
|
||||
url: "https://api.perplexity.ai/v1/models",
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
authHeader: "Authorization",
|
||||
authPrefix: "Bearer ",
|
||||
parseResponse: parsePerplexitySonarModels,
|
||||
},
|
||||
cohere: {
|
||||
url: "https://api.cohere.com/v2/models",
|
||||
method: "GET",
|
||||
|
||||
Reference in New Issue
Block a user