-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: add OpenRouter as embedding provider for code indexing #8974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add OpenRouter to EmbedderProvider type and related interfaces - Create OpenRouterEmbedder class that extends OpenAICompatibleEmbedder - Add OpenRouter embedding models to EMBEDDING_MODEL_PROFILES - Update service factory to handle OpenRouter embedder creation - Configure OpenRouter to use existing API key from chat model settings - Support OpenRouter embedding models including OpenAI, Cohere, and Voyage models Closes #8972
|
Review complete. Found 3 issues to address. Issues to Resolve
Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request. |
| private readonly modelId: string | ||
|
|
||
| /** | ||
| * Creates a new OpenRouter embedder | ||
| * @param apiKey The OpenRouter API key for authentication | ||
| * @param modelId The model ID to use (defaults to openai/text-embedding-3-small) | ||
| * @param baseUrl Optional custom base URL for OpenRouter API (defaults to https://openrouter.ai/api/v1) | ||
| */ | ||
| constructor(apiKey?: string, modelId?: string, baseUrl?: string) { | ||
| if (!apiKey) { | ||
| throw new Error(t("embeddings:validation.apiKeyRequired")) | ||
| } | ||
|
|
||
| // Use the provided base URL or default to OpenRouter's API URL | ||
| const openRouterBaseUrl = baseUrl || OpenRouterEmbedder.OPENROUTER_BASE_URL | ||
|
|
||
| // Initialize the parent OpenAI Compatible embedder with OpenRouter configuration | ||
| super(openRouterBaseUrl, apiKey, modelId || OpenRouterEmbedder.DEFAULT_MODEL, MAX_ITEM_TOKENS) | ||
|
|
||
| this.modelId = modelId || getDefaultModelId("openrouter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modelId field is assigned but never used within this class. Other similar embedders (MistralEmbedder, VercelAiGatewayEmbedder) don't store this field since the parent class already handles it. Consider removing this unused field to reduce code complexity.
| * Supported models: | ||
| * - openai/text-embedding-3-small (dimension: 1536) | ||
| * - openai/text-embedding-3-large (dimension: 3072) | ||
| * - openai/text-embedding-ada-002 (dimension: 1536) | ||
| * - cohere/embed-english-v3.0 (dimension: 1024) | ||
| * - cohere/embed-multilingual-v3.0 (dimension: 1024) | ||
| * - voyage/voyage-3 (dimension: 1024) | ||
| * - voyage/voyage-3-lite (dimension: 512) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSDoc comment lists 7 supported models but the implementation in embeddingModels.ts includes 8 models. The comment is missing voyage/voyage-embeddings-v3 which is defined on line 89 of embeddingModels.ts. Update the documentation to include all supported models or remove the unlisted model from the implementation.
| "qdrantUrlMissing": "Falta l'URL de Qdrant per crear l'emmagatzematge de vectors", | ||
| "codeIndexingNotConfigured": "No es poden crear serveis: La indexació de codi no està configurada correctament" | ||
| "codeIndexingNotConfigured": "No es poden crear serveis: La indexació de codi no està configurada correctament", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All non-English locale files contain the English translation instead of translations in their respective languages. The value should be translated to match the locale (Catalan for ca, German for de, Spanish for es, etc.). This breaks the localization feature for users in these languages.
| "qdrantUrlMissing": "Falta l'URL de Qdrant per crear l'emmagatzematge de vectors", | ||
| "codeIndexingNotConfigured": "No es poden crear serveis: La indexació de codi no està configurada correctament" | ||
| "codeIndexingNotConfigured": "No es poden crear serveis: La indexació de codi no està configurada correctament", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New key openRouterConfigMissing is added with an English string. Consider providing a proper Catalan translation instead of the default English text.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "Falta la configuració d'OpenRouter per crear l'embedder" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| "qdrantUrlMissing": "Qdrant-URL fehlt für die Erstellung des Vektorspeichers", | ||
| "codeIndexingNotConfigured": "Kann keine Dienste erstellen: Code-Indizierung ist nicht richtig konfiguriert" | ||
| "codeIndexingNotConfigured": "Kann keine Dienste erstellen: Code-Indizierung ist nicht richtig konfiguriert", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new key openRouterConfigMissing remains in English. Please localize it into German.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "OpenRouter-Konfiguration fehlt für die Erstellung des Embedders" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| "qdrantUrlMissing": "Falta la URL de Qdrant para crear el almacén de vectores", | ||
| "codeIndexingNotConfigured": "No se pueden crear servicios: La indexación de código no está configurada correctamente" | ||
| "codeIndexingNotConfigured": "No se pueden crear servicios: La indexación de código no está configurada correctamente", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The translation for openRouterConfigMissing is still in English. It should be localized into Spanish.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "Falta la configuración de OpenRouter para crear el incrustador" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| "qdrantUrlMissing": "URL Qdrant manquante pour la création du stockage de vecteurs", | ||
| "codeIndexingNotConfigured": "Impossible de créer les services : L'indexation du code n'est pas correctement configurée" | ||
| "codeIndexingNotConfigured": "Impossible de créer les services : L'indexation du code n'est pas correctement configurée", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New key openRouterConfigMissing is not translated into French. Please update with a French translation.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "Configuration OpenRouter manquante pour la création de l'embedder" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| "qdrantUrlMissing": "वेक्टर स्टोर बनाने के लिए Qdrant URL गायब है", | ||
| "codeIndexingNotConfigured": "सेवाएं नहीं बना सकते: कोड इंडेक्सिंग ठीक से कॉन्फ़िगर नहीं है" | ||
| "codeIndexingNotConfigured": "सेवाएं नहीं बना सकते: कोड इंडेक्सिंग ठीक से कॉन्फ़िगर नहीं है", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new key openRouterConfigMissing remains in English. A proper Hindi translation is recommended.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "एम्बेडर निर्माण के लिए OpenRouter कॉन्फ़िगरेशन गायब है" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| "qdrantUrlMissing": "Отсутствует URL Qdrant для создания векторного хранилища", | ||
| "codeIndexingNotConfigured": "Невозможно создать сервисы: Индексация кода не настроена должным образом" | ||
| "codeIndexingNotConfigured": "Невозможно создать сервисы: Индексация кода не настроена должным образом", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new key openRouterConfigMissing remains untranslated in Russian. Please add a proper Russian translation.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "Отсутствует конфигурация OpenRouter для создания эмбеддера" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| "qdrantUrlMissing": "Vektör deposu oluşturmak için Qdrant URL'si eksik", | ||
| "codeIndexingNotConfigured": "Hizmetler oluşturulamıyor: Kod indeksleme düzgün yapılandırılmamış" | ||
| "codeIndexingNotConfigured": "Hizmetler oluşturulamıyor: Kod indeksleme düzgün yapılandırılmamış", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The openRouterConfigMissing key is added with an English value. Please consider localizing it into Turkish.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "Gömücü oluşturmak için OpenRouter yapılandırması eksik" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| "qdrantUrlMissing": "Thiếu URL Qdrant để tạo kho lưu trữ vector", | ||
| "codeIndexingNotConfigured": "Không thể tạo dịch vụ: Lập chỉ mục mã không được cấu hình đúng cách" | ||
| "codeIndexingNotConfigured": "Không thể tạo dịch vụ: Lập chỉ mục mã không được cấu hình đúng cách", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new key 'openRouterConfigMissing' remains in English in the Vietnamese locale. Please provide a proper translation.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "Thiếu cấu hình OpenRouter để tạo trình nhúng" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| "qdrantUrlMissing": "创建向量存储缺少 Qdrant URL", | ||
| "codeIndexingNotConfigured": "无法创建服务:代码索引未正确配置" | ||
| "codeIndexingNotConfigured": "无法创建服务:代码索引未正确配置", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key openRouterConfigMissing is added with an English string. Consider adding a Chinese translation.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "创建嵌入器缺少 OpenRouter 配置" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| "qdrantUrlMissing": "建立向量儲存缺少 Qdrant URL", | ||
| "codeIndexingNotConfigured": "無法建立服務:程式碼索引未正確設定" | ||
| "codeIndexingNotConfigured": "無法建立服務:程式碼索引未正確設定", | ||
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'openRouterConfigMissing' key remains in English in the Traditional Chinese file. Please update it with a proper translation.
| "openRouterConfigMissing": "OpenRouter configuration missing for embedder creation" | |
| "openRouterConfigMissing": "建立嵌入器缺少 OpenRouter 設定" |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
Description
This PR implements support for OpenRouter as an embedding provider for the code-indexing feature, addressing Issue #8972.
Changes
Benefits
Testing
Implementation Notes
The implementation leverages the existing OpenAI-compatible infrastructure since OpenRouter's embedding API follows the OpenAI format. This minimizes code duplication and ensures consistency with other providers.
Closes #8972
Important
This PR adds OpenRouter as a new embedding provider for code indexing, including configuration, model support, and tests.
OpenRouteras a new embedding provider incodebase-index.tsandWebviewMessage.ts.OpenRouterEmbedderclass inopenrouter.ts, extendingOpenAICompatibleEmbedder.CodeIndexConfigManagerinconfig-manager.tsto handle OpenRouter configuration.CodeIndexConfigandPreviousConfigSnapshotinconfig.ts.EMBEDDING_MODEL_PROFILESinembeddingModels.ts.OpenRouterEmbedderinopenrouter.spec.ts.openRouterConfigMissingtranslation key in multipleembeddings.jsonfiles.This description was created by
for 8d3c354. You can customize this summary. It will automatically update as commits are pushed.