Skip to content

Commit 7ddc4e6

Browse files
authored
feat: Add Mistral embedding provider (RooCodeInc#5932) (RooCodeInc#5946)
* feat: add Mistral embedding provider with OpenAI Compatible Wrapper - Implement MistralEmbedder class using OpenAI-compatible API - Add comprehensive unit tests with 100% coverage - Update type definitions for Mistral provider support - Integrate Mistral option in UI components and configuration - Add internationalization support for Mistral provider - Fix API key storage and retrieval for embedding providers - Update service factory to support Mistral embeddings - Add proper error handling and validation This implementation allows users to use Mistral's embedding models through the existing OpenAI-compatible wrapper approach, providing a seamless integration experience. * feat: add Mistral embedding provider support - Implement MistralEmbedder class with API integration - Add Mistral models to embedding model configurations - Update UI to include Mistral provider option - Add comprehensive unit tests for Mistral embedder - Update type definitions and interfaces - Add internationalization support for Mistral provider * fix: add missing translations for Mistral embedding provider * fix: address PR review feedback - improve translations and add clarifying comment
1 parent e297026 commit 7ddc4e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+513
-6
lines changed

packages/types/src/codebase-index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const CODEBASE_INDEX_DEFAULTS = {
2121
export const codebaseIndexConfigSchema = z.object({
2222
codebaseIndexEnabled: z.boolean().optional(),
2323
codebaseIndexQdrantUrl: z.string().optional(),
24-
codebaseIndexEmbedderProvider: z.enum(["openai", "ollama", "openai-compatible", "gemini"]).optional(),
24+
codebaseIndexEmbedderProvider: z.enum(["openai", "ollama", "openai-compatible", "gemini", "mistral"]).optional(),
2525
codebaseIndexEmbedderBaseUrl: z.string().optional(),
2626
codebaseIndexEmbedderModelId: z.string().optional(),
2727
codebaseIndexEmbedderModelDimension: z.number().optional(),
@@ -47,6 +47,7 @@ export const codebaseIndexModelsSchema = z.object({
4747
ollama: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
4848
"openai-compatible": z.record(z.string(), z.object({ dimension: z.number() })).optional(),
4949
gemini: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
50+
mistral: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
5051
})
5152

5253
export type CodebaseIndexModels = z.infer<typeof codebaseIndexModelsSchema>
@@ -62,6 +63,7 @@ export const codebaseIndexProviderSchema = z.object({
6263
codebaseIndexOpenAiCompatibleApiKey: z.string().optional(),
6364
codebaseIndexOpenAiCompatibleModelDimension: z.number().optional(),
6465
codebaseIndexGeminiApiKey: z.string().optional(),
66+
codebaseIndexMistralApiKey: z.string().optional(),
6567
})
6668

6769
export type CodebaseIndexProvider = z.infer<typeof codebaseIndexProviderSchema>

packages/types/src/global-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export const SECRET_STATE_KEYS = [
162162
"codeIndexQdrantApiKey",
163163
"codebaseIndexOpenAiCompatibleApiKey",
164164
"codebaseIndexGeminiApiKey",
165+
"codebaseIndexMistralApiKey",
165166
] as const satisfies readonly (keyof ProviderSettings)[]
166167
export type SecretState = Pick<ProviderSettings, (typeof SECRET_STATE_KEYS)[number]>
167168

src/core/webview/webviewMessageHandler.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,12 @@ export const webviewMessageHandler = async (
19701970
settings.codebaseIndexGeminiApiKey,
19711971
)
19721972
}
1973+
if (settings.codebaseIndexMistralApiKey !== undefined) {
1974+
await provider.contextProxy.storeSecret(
1975+
"codebaseIndexMistralApiKey",
1976+
settings.codebaseIndexMistralApiKey,
1977+
)
1978+
}
19731979

19741980
// Send success response first - settings are saved regardless of validation
19751981
await provider.postMessageToWebview({
@@ -2062,6 +2068,7 @@ export const webviewMessageHandler = async (
20622068
"codebaseIndexOpenAiCompatibleApiKey",
20632069
))
20642070
const hasGeminiApiKey = !!(await provider.context.secrets.get("codebaseIndexGeminiApiKey"))
2071+
const hasMistralApiKey = !!(await provider.context.secrets.get("codebaseIndexMistralApiKey"))
20652072

20662073
provider.postMessageToWebview({
20672074
type: "codeIndexSecretStatus",
@@ -2070,6 +2077,7 @@ export const webviewMessageHandler = async (
20702077
hasQdrantApiKey,
20712078
hasOpenAiCompatibleApiKey,
20722079
hasGeminiApiKey,
2080+
hasMistralApiKey,
20732081
},
20742082
})
20752083
break

src/i18n/locales/ca/embeddings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/de/embeddings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/en/embeddings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"ollamaConfigMissing": "Ollama configuration missing for embedder creation",
4747
"openAiCompatibleConfigMissing": "OpenAI Compatible configuration missing for embedder creation",
4848
"geminiConfigMissing": "Gemini configuration missing for embedder creation",
49+
"mistralConfigMissing": "Mistral configuration missing for embedder creation",
4950
"invalidEmbedderType": "Invalid embedder type configured: {{embedderProvider}}",
5051
"vectorDimensionNotDeterminedOpenAiCompatible": "Could not determine vector dimension for model '{{modelId}}' with provider '{{provider}}'. Please ensure the 'Embedding Dimension' is correctly set in the OpenAI-Compatible provider settings.",
5152
"vectorDimensionNotDetermined": "Could not determine vector dimension for model '{{modelId}}' with provider '{{provider}}'. Check model profiles or configuration.",

src/i18n/locales/es/embeddings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/fr/embeddings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/hi/embeddings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/id/embeddings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)