Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/types/src/codebase-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const CODEBASE_INDEX_DEFAULTS = {
export const codebaseIndexConfigSchema = z.object({
codebaseIndexEnabled: z.boolean().optional(),
codebaseIndexQdrantUrl: z.string().optional(),
codebaseIndexEmbedderProvider: z.enum(["openai", "ollama", "openai-compatible", "gemini", "mistral"]).optional(),
codebaseIndexEmbedderProvider: z
.enum(["openai", "ollama", "openai-compatible", "gemini", "mistral", "vertex"])
.optional(),
codebaseIndexEmbedderBaseUrl: z.string().optional(),
codebaseIndexEmbedderModelId: z.string().optional(),
codebaseIndexEmbedderModelDimension: z.number().optional(),
Expand All @@ -34,6 +36,9 @@ export const codebaseIndexConfigSchema = z.object({
// OpenAI Compatible specific fields
codebaseIndexOpenAiCompatibleBaseUrl: z.string().optional(),
codebaseIndexOpenAiCompatibleModelDimension: z.number().optional(),
// Vertex AI specific fields
codebaseIndexVertexProjectId: z.string().optional(),
codebaseIndexVertexLocation: z.string().optional(),
})

export type CodebaseIndexConfig = z.infer<typeof codebaseIndexConfigSchema>
Expand All @@ -48,6 +53,7 @@ export const codebaseIndexModelsSchema = z.object({
"openai-compatible": z.record(z.string(), z.object({ dimension: z.number() })).optional(),
gemini: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
mistral: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
vertex: z.record(z.string(), z.object({ dimension: z.number() })).optional(),
})

export type CodebaseIndexModels = z.infer<typeof codebaseIndexModelsSchema>
Expand All @@ -64,6 +70,9 @@ export const codebaseIndexProviderSchema = z.object({
codebaseIndexOpenAiCompatibleModelDimension: z.number().optional(),
codebaseIndexGeminiApiKey: z.string().optional(),
codebaseIndexMistralApiKey: z.string().optional(),
codebaseIndexVertexApiKey: z.string().optional(),
codebaseIndexVertexJsonCredentials: z.string().optional(),
codebaseIndexVertexKeyFile: z.string().optional(),
})

export type CodebaseIndexProvider = z.infer<typeof codebaseIndexProviderSchema>
3 changes: 3 additions & 0 deletions packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ export const SECRET_STATE_KEYS = [
"codebaseIndexOpenAiCompatibleApiKey",
"codebaseIndexGeminiApiKey",
"codebaseIndexMistralApiKey",
"codebaseIndexVertexApiKey",
"codebaseIndexVertexJsonCredentials",
"codebaseIndexVertexKeyFile",
"huggingFaceApiKey",
] as const satisfies readonly (keyof ProviderSettings)[]
export type SecretState = Pick<ProviderSettings, (typeof SECRET_STATE_KEYS)[number]>
Expand Down
4 changes: 4 additions & 0 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,8 @@ export class ClineProvider
codebaseIndexOpenAiCompatibleBaseUrl: codebaseIndexConfig?.codebaseIndexOpenAiCompatibleBaseUrl,
codebaseIndexSearchMaxResults: codebaseIndexConfig?.codebaseIndexSearchMaxResults,
codebaseIndexSearchMinScore: codebaseIndexConfig?.codebaseIndexSearchMinScore,
codebaseIndexVertexProjectId: codebaseIndexConfig?.codebaseIndexVertexProjectId,
codebaseIndexVertexLocation: codebaseIndexConfig?.codebaseIndexVertexLocation,
},
mdmCompliant: this.checkMdmCompliance(),
profileThresholds: profileThresholds ?? {},
Expand Down Expand Up @@ -1726,6 +1728,8 @@ export class ClineProvider
stateValues.codebaseIndexConfig?.codebaseIndexOpenAiCompatibleBaseUrl,
codebaseIndexSearchMaxResults: stateValues.codebaseIndexConfig?.codebaseIndexSearchMaxResults,
codebaseIndexSearchMinScore: stateValues.codebaseIndexConfig?.codebaseIndexSearchMinScore,
codebaseIndexVertexProjectId: stateValues.codebaseIndexConfig?.codebaseIndexVertexProjectId,
codebaseIndexVertexLocation: stateValues.codebaseIndexConfig?.codebaseIndexVertexLocation,
},
profileThresholds: stateValues.profileThresholds ?? {},
// Add diagnostic message settings
Expand Down
28 changes: 28 additions & 0 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,8 @@ export const webviewMessageHandler = async (
codebaseIndexOpenAiCompatibleBaseUrl: settings.codebaseIndexOpenAiCompatibleBaseUrl,
codebaseIndexSearchMaxResults: settings.codebaseIndexSearchMaxResults,
codebaseIndexSearchMinScore: settings.codebaseIndexSearchMinScore,
codebaseIndexVertexProjectId: settings.codebaseIndexVertexProjectId,
codebaseIndexVertexLocation: settings.codebaseIndexVertexLocation,
}

// Save global state first
Expand Down Expand Up @@ -2028,6 +2030,24 @@ export const webviewMessageHandler = async (
settings.codebaseIndexMistralApiKey,
)
}
if (settings.codebaseIndexVertexApiKey !== undefined) {
await provider.contextProxy.storeSecret(
"codebaseIndexVertexApiKey",
settings.codebaseIndexVertexApiKey,
)
}
if (settings.codebaseIndexVertexJsonCredentials !== undefined) {
await provider.contextProxy.storeSecret(
"codebaseIndexVertexJsonCredentials",
settings.codebaseIndexVertexJsonCredentials,
)
}
if (settings.codebaseIndexVertexKeyFile !== undefined) {
await provider.contextProxy.storeSecret(
"codebaseIndexVertexKeyFile",
settings.codebaseIndexVertexKeyFile,
)
}

// Send success response first - settings are saved regardless of validation
await provider.postMessageToWebview({
Expand Down Expand Up @@ -2149,6 +2169,11 @@ export const webviewMessageHandler = async (
))
const hasGeminiApiKey = !!(await provider.context.secrets.get("codebaseIndexGeminiApiKey"))
const hasMistralApiKey = !!(await provider.context.secrets.get("codebaseIndexMistralApiKey"))
const hasVertexApiKey = !!(await provider.context.secrets.get("codebaseIndexVertexApiKey"))
const hasVertexJsonCredentials = !!(await provider.context.secrets.get(
"codebaseIndexVertexJsonCredentials",
))
const hasVertexKeyFile = !!(await provider.context.secrets.get("codebaseIndexVertexKeyFile"))

provider.postMessageToWebview({
type: "codeIndexSecretStatus",
Expand All @@ -2158,6 +2183,9 @@ export const webviewMessageHandler = async (
hasOpenAiCompatibleApiKey,
hasGeminiApiKey,
hasMistralApiKey,
hasVertexApiKey,
hasVertexJsonCredentials,
hasVertexKeyFile,
},
})
break
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en/embeddings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"openAiCompatibleConfigMissing": "OpenAI Compatible configuration missing for embedder creation",
"geminiConfigMissing": "Gemini configuration missing for embedder creation",
"mistralConfigMissing": "Mistral configuration missing for embedder creation",
"vertexConfigMissing": "Vertex AI configuration missing for embedder creation",
"invalidEmbedderType": "Invalid embedder type configured: {{embedderProvider}}",
"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.",
"vectorDimensionNotDetermined": "Could not determine vector dimension for model '{{modelId}}' with provider '{{provider}}'. Check model profiles or configuration.",
Expand Down
3 changes: 3 additions & 0 deletions src/services/code-index/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ export const BATCH_PROCESSING_CONCURRENCY = 10

/**Gemini Embedder */
export const GEMINI_MAX_ITEM_TOKENS = 2048

/**Vertex AI Embedder */
export const VERTEX_MAX_ITEM_TOKENS = 2048
Loading
Loading