mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-01 03:52:17 +03:00
fix(api): keep registry width and type on embedding models
This commit is contained in:
@@ -239,7 +239,7 @@ export const EMBEDDING_PROVIDERS: Record<string, EmbeddingProvider> = {
|
||||
{
|
||||
id: "google/gemini-embedding-001",
|
||||
name: "Gemini Embedding 001 (OpenRouter)",
|
||||
dimensions: 768,
|
||||
dimensions: 3072,
|
||||
},
|
||||
{
|
||||
id: "google/gemini-embedding-2",
|
||||
|
||||
@@ -1357,13 +1357,13 @@ async function buildUnifiedModelsResponseCore(
|
||||
return activeAliases.has(alias) || activeAliases.has(provider);
|
||||
};
|
||||
|
||||
const hasEquivalentSpecialtyModel = (
|
||||
const findEquivalentSpecialtyModel = (
|
||||
providerId: string,
|
||||
rawModelId: string,
|
||||
type: string,
|
||||
scopedModelId: string
|
||||
) =>
|
||||
models.some((model: any) => {
|
||||
models.find((model: any) => {
|
||||
if (model?.id === scopedModelId) return true;
|
||||
if (model?.owned_by !== providerId || model?.type !== type) return false;
|
||||
const existingRoot =
|
||||
@@ -1375,6 +1375,13 @@ async function buildUnifiedModelsResponseCore(
|
||||
return existingRoot === rawModelId;
|
||||
});
|
||||
|
||||
const hasEquivalentSpecialtyModel = (
|
||||
providerId: string,
|
||||
rawModelId: string,
|
||||
type: string,
|
||||
scopedModelId: string
|
||||
) => findEquivalentSpecialtyModel(providerId, rawModelId, type, scopedModelId) !== undefined;
|
||||
|
||||
// Helper: strip the provider prefix from a specialty model ID to get the
|
||||
// provider-relative path (e.g. "openrouter/google/chirp-3" -> "google/chirp-3").
|
||||
// This is the correct key used by the hidden-model lookup — using .split("/").pop()
|
||||
@@ -1389,7 +1396,22 @@ async function buildUnifiedModelsResponseCore(
|
||||
const rawModelId = getSpecialtyModelRelativeId(embModel.id, embModel.provider);
|
||||
if (!providerSupportsModel(embModel.provider, rawModelId)) continue;
|
||||
if (isModelHiddenBulk(embModel.provider, rawModelId)) continue;
|
||||
if (hasEquivalentSpecialtyModel(embModel.provider, rawModelId, "embedding", embModel.id)) {
|
||||
const existingEmbedding = findEquivalentSpecialtyModel(
|
||||
embModel.provider,
|
||||
rawModelId,
|
||||
"embedding",
|
||||
embModel.id
|
||||
);
|
||||
if (existingEmbedding) {
|
||||
// Discovery publishes no vector width, so the registry is the authority.
|
||||
if (embModel.dimensions !== undefined) {
|
||||
existingEmbedding.dimensions = embModel.dimensions;
|
||||
}
|
||||
// A provider that does not report its endpoints leaves the model unclassified. Being in
|
||||
// the embedding registry is that statement, so make it rather than leave it untyped.
|
||||
if (!existingEmbedding.type) {
|
||||
existingEmbedding.type = "embedding";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
models.push({
|
||||
|
||||
Reference in New Issue
Block a user