mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
fix: custom provider prefix conflicts with built-in alias
When a custom OpenAI-compatible provider uses a prefix that matches a built-in alias (e.g. 'ark' -> 'volcengine-ark'), resolveProviderAlias() converts it to the built-in provider ID, causing the provider-node matching logic to be skipped. The request is then routed to the wrong provider, resulting in a 404 model_not_found error. Fix: always check provider-node prefix matching using the original user input (parsed.providerAlias) before falling back to the resolved alias, regardless of whether resolveProviderAlias() transformed it. Co-authored-by: H1d3rOne <H1d3rOne@users.noreply.github.com> Made-with: Cursor
This commit is contained in:
@@ -19,27 +19,23 @@ export async function getModelInfo(modelStr) {
|
|||||||
const parsed = parseModel(modelStr);
|
const parsed = parseModel(modelStr);
|
||||||
|
|
||||||
if (!parsed.isAlias) {
|
if (!parsed.isAlias) {
|
||||||
if (parsed.provider === parsed.providerAlias) {
|
// Always check provider-node prefix matching using original input first
|
||||||
// Check OpenAI Compatible nodes
|
const openaiNodes = await getProviderNodes({ type: "openai-compatible" });
|
||||||
const openaiNodes = await getProviderNodes({ type: "openai-compatible" });
|
const matchedOpenAI = openaiNodes.find((node) => node.prefix === parsed.providerAlias);
|
||||||
const matchedOpenAI = openaiNodes.find((node) => node.prefix === parsed.providerAlias);
|
if (matchedOpenAI) {
|
||||||
if (matchedOpenAI) {
|
return { provider: matchedOpenAI.id, model: parsed.model };
|
||||||
return { provider: matchedOpenAI.id, model: parsed.model };
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Check Anthropic Compatible nodes
|
const anthropicNodes = await getProviderNodes({ type: "anthropic-compatible" });
|
||||||
const anthropicNodes = await getProviderNodes({ type: "anthropic-compatible" });
|
const matchedAnthropic = anthropicNodes.find((node) => node.prefix === parsed.providerAlias);
|
||||||
const matchedAnthropic = anthropicNodes.find((node) => node.prefix === parsed.providerAlias);
|
if (matchedAnthropic) {
|
||||||
if (matchedAnthropic) {
|
return { provider: matchedAnthropic.id, model: parsed.model };
|
||||||
return { provider: matchedAnthropic.id, model: parsed.model };
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Check Custom Embedding nodes
|
const embeddingNodes = await getProviderNodes({ type: "custom-embedding" });
|
||||||
const embeddingNodes = await getProviderNodes({ type: "custom-embedding" });
|
const matchedEmbedding = embeddingNodes.find((node) => node.prefix === parsed.providerAlias);
|
||||||
const matchedEmbedding = embeddingNodes.find((node) => node.prefix === parsed.providerAlias);
|
if (matchedEmbedding) {
|
||||||
if (matchedEmbedding) {
|
return { provider: matchedEmbedding.id, model: parsed.model };
|
||||||
return { provider: matchedEmbedding.id, model: parsed.model };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
provider: parsed.provider,
|
provider: parsed.provider,
|
||||||
|
|||||||
Reference in New Issue
Block a user