Skip to content

Commit 1ad2129

Browse files
mrubensdaniel-lxs
andauthored
Add support for Vercel embeddings (#7445)
Co-authored-by: daniel-lxs <[email protected]>
1 parent 33a8573 commit 1ad2129

Some content is hidden

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

50 files changed

+539
-7
lines changed

packages/types/src/codebase-index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ 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", "mistral"]).optional(),
24+
codebaseIndexEmbedderProvider: z
25+
.enum(["openai", "ollama", "openai-compatible", "gemini", "mistral", "vercel-ai-gateway"])
26+
.optional(),
2527
codebaseIndexEmbedderBaseUrl: z.string().optional(),
2628
codebaseIndexEmbedderModelId: z.string().optional(),
2729
codebaseIndexEmbedderModelDimension: z.number().optional(),
@@ -48,6 +50,7 @@ export const codebaseIndexModelsSchema = z.object({
4850
"openai-compatible": z.record(z.string(), z.object({ dimension: z.number() })).optional(),
4951
gemini: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
5052
mistral: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
53+
"vercel-ai-gateway": z.record(z.string(), z.object({ dimension: z.number() })).optional(),
5154
})
5255

5356
export type CodebaseIndexModels = z.infer<typeof codebaseIndexModelsSchema>
@@ -64,6 +67,7 @@ export const codebaseIndexProviderSchema = z.object({
6467
codebaseIndexOpenAiCompatibleModelDimension: z.number().optional(),
6568
codebaseIndexGeminiApiKey: z.string().optional(),
6669
codebaseIndexMistralApiKey: z.string().optional(),
70+
codebaseIndexVercelAiGatewayApiKey: z.string().optional(),
6771
})
6872

6973
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
@@ -192,6 +192,7 @@ export const SECRET_STATE_KEYS = [
192192
"codebaseIndexOpenAiCompatibleApiKey",
193193
"codebaseIndexGeminiApiKey",
194194
"codebaseIndexMistralApiKey",
195+
"codebaseIndexVercelAiGatewayApiKey",
195196
"huggingFaceApiKey",
196197
"sambaNovaApiKey",
197198
"zaiApiKey",

src/api/providers/fetchers/vercel-ai-gateway.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export async function getVercelAiGatewayModels(options?: ApiHandlerOptions): Pro
6868
for (const model of data) {
6969
const { id } = model
7070

71-
// Only include language models
71+
// Only include language models for chat inference
72+
// Embedding models are statically defined in embeddingModels.ts
7273
if (model.type !== "language") {
7374
continue
7475
}

src/core/webview/webviewMessageHandler.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,12 @@ export const webviewMessageHandler = async (
20952095
settings.codebaseIndexMistralApiKey,
20962096
)
20972097
}
2098+
if (settings.codebaseIndexVercelAiGatewayApiKey !== undefined) {
2099+
await provider.contextProxy.storeSecret(
2100+
"codebaseIndexVercelAiGatewayApiKey",
2101+
settings.codebaseIndexVercelAiGatewayApiKey,
2102+
)
2103+
}
20982104

20992105
// Send success response first - settings are saved regardless of validation
21002106
await provider.postMessageToWebview({
@@ -2229,6 +2235,9 @@ export const webviewMessageHandler = async (
22292235
))
22302236
const hasGeminiApiKey = !!(await provider.context.secrets.get("codebaseIndexGeminiApiKey"))
22312237
const hasMistralApiKey = !!(await provider.context.secrets.get("codebaseIndexMistralApiKey"))
2238+
const hasVercelAiGatewayApiKey = !!(await provider.context.secrets.get(
2239+
"codebaseIndexVercelAiGatewayApiKey",
2240+
))
22322241

22332242
provider.postMessageToWebview({
22342243
type: "codeIndexSecretStatus",
@@ -2238,6 +2247,7 @@ export const webviewMessageHandler = async (
22382247
hasOpenAiCompatibleApiKey,
22392248
hasGeminiApiKey,
22402249
hasMistralApiKey,
2250+
hasVercelAiGatewayApiKey,
22412251
},
22422252
})
22432253
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
@@ -47,6 +47,7 @@
4747
"openAiCompatibleConfigMissing": "OpenAI Compatible configuration missing for embedder creation",
4848
"geminiConfigMissing": "Gemini configuration missing for embedder creation",
4949
"mistralConfigMissing": "Mistral configuration missing for embedder creation",
50+
"vercelAiGatewayConfigMissing": "Vercel AI Gateway configuration missing for embedder creation",
5051
"invalidEmbedderType": "Invalid embedder type configured: {{embedderProvider}}",
5152
"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.",
5253
"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.

0 commit comments

Comments
 (0)