@@ -17,6 +17,7 @@ export class CodeIndexConfigManager {
1717 private ollamaOptions ?: ApiHandlerOptions
1818 private openAiCompatibleOptions ?: { baseUrl : string ; apiKey : string ; modelDimension ?: number }
1919 private geminiOptions ?: { apiKey : string }
20+ private lmStudioOptions ?: ApiHandlerOptions
2021 private qdrantUrl ?: string = "http://localhost:6333"
2122 private qdrantApiKey ?: string
2223 private searchMinScore ?: number
@@ -73,13 +74,15 @@ export class CodeIndexConfigManager {
7374 this . searchMinScore = codebaseIndexSearchMinScore
7475 this . openAiOptions = { openAiNativeApiKey : openAiKey }
7576
76- // Set embedder provider with support for openai-compatible
77+ // Set embedder provider with support for all providers
7778 if ( codebaseIndexEmbedderProvider === "ollama" ) {
7879 this . embedderProvider = "ollama"
7980 } else if ( codebaseIndexEmbedderProvider === "openai-compatible" ) {
8081 this . embedderProvider = "openai-compatible"
8182 } else if ( codebaseIndexEmbedderProvider === "gemini" ) {
8283 this . embedderProvider = "gemini"
84+ } else if ( codebaseIndexEmbedderProvider === "lmstudio" ) {
85+ this . embedderProvider = "lmstudio"
8386 } else {
8487 this . embedderProvider = "openai"
8588 }
@@ -100,6 +103,10 @@ export class CodeIndexConfigManager {
100103 : undefined
101104
102105 this . geminiOptions = geminiApiKey ? { apiKey : geminiApiKey } : undefined
106+
107+ this . lmStudioOptions = {
108+ lmStudioBaseUrl : codebaseIndexEmbedderBaseUrl ,
109+ }
103110 }
104111
105112 /**
@@ -116,6 +123,7 @@ export class CodeIndexConfigManager {
116123 ollamaOptions ?: ApiHandlerOptions
117124 openAiCompatibleOptions ?: { baseUrl : string ; apiKey : string }
118125 geminiOptions ?: { apiKey : string }
126+ lmStudioOptions ?: ApiHandlerOptions
119127 qdrantUrl ?: string
120128 qdrantApiKey ?: string
121129 searchMinScore ?: number
@@ -134,6 +142,7 @@ export class CodeIndexConfigManager {
134142 openAiCompatibleApiKey : this . openAiCompatibleOptions ?. apiKey ?? "" ,
135143 openAiCompatibleModelDimension : this . openAiCompatibleOptions ?. modelDimension ,
136144 geminiApiKey : this . geminiOptions ?. apiKey ?? "" ,
145+ lmStudioBaseUrl : this . lmStudioOptions ?. lmStudioBaseUrl ?? "" ,
137146 qdrantUrl : this . qdrantUrl ?? "" ,
138147 qdrantApiKey : this . qdrantApiKey ?? "" ,
139148 }
@@ -157,6 +166,7 @@ export class CodeIndexConfigManager {
157166 ollamaOptions : this . ollamaOptions ,
158167 openAiCompatibleOptions : this . openAiCompatibleOptions ,
159168 geminiOptions : this . geminiOptions ,
169+ lmStudioOptions : this . lmStudioOptions ,
160170 qdrantUrl : this . qdrantUrl ,
161171 qdrantApiKey : this . qdrantApiKey ,
162172 searchMinScore : this . currentSearchMinScore ,
@@ -189,6 +199,12 @@ export class CodeIndexConfigManager {
189199 const qdrantUrl = this . qdrantUrl
190200 const isConfigured = ! ! ( apiKey && qdrantUrl )
191201 return isConfigured
202+ } else if ( this . embedderProvider === "lmstudio" ) {
203+ // Lm Studio model ID has a default, so only base URL is strictly required for config
204+ const lmStudioBaseUrl = this . lmStudioOptions ?. lmStudioBaseUrl
205+ const qdrantUrl = this . qdrantUrl
206+ const isConfigured = ! ! ( lmStudioBaseUrl && qdrantUrl )
207+ return isConfigured
192208 }
193209 return false // Should not happen if embedderProvider is always set correctly
194210 }
@@ -222,6 +238,7 @@ export class CodeIndexConfigManager {
222238 const prevOpenAiCompatibleApiKey = prev ?. openAiCompatibleApiKey ?? ""
223239 const prevOpenAiCompatibleModelDimension = prev ?. openAiCompatibleModelDimension
224240 const prevGeminiApiKey = prev ?. geminiApiKey ?? ""
241+ const prevLmStudioBaseUrl = prev ?. lmStudioBaseUrl ?? ""
225242 const prevQdrantUrl = prev ?. qdrantUrl ?? ""
226243 const prevQdrantApiKey = prev ?. qdrantApiKey ?? ""
227244
@@ -254,6 +271,7 @@ export class CodeIndexConfigManager {
254271 const currentOpenAiCompatibleApiKey = this . openAiCompatibleOptions ?. apiKey ?? ""
255272 const currentOpenAiCompatibleModelDimension = this . openAiCompatibleOptions ?. modelDimension
256273 const currentGeminiApiKey = this . geminiOptions ?. apiKey ?? ""
274+ const currentLmStudioBaseUrl = this . lmStudioOptions ?. lmStudioBaseUrl ?? ""
257275 const currentQdrantUrl = this . qdrantUrl ?? ""
258276 const currentQdrantApiKey = this . qdrantApiKey ?? ""
259277
@@ -279,6 +297,14 @@ export class CodeIndexConfigManager {
279297 }
280298 }
281299
300+ if ( prevGeminiApiKey !== currentGeminiApiKey ) {
301+ return true
302+ }
303+
304+ if ( prevLmStudioBaseUrl !== currentLmStudioBaseUrl ) {
305+ return true
306+ }
307+
282308 if ( prevQdrantUrl !== currentQdrantUrl || prevQdrantApiKey !== currentQdrantApiKey ) {
283309 return true
284310 }
@@ -331,6 +357,7 @@ export class CodeIndexConfigManager {
331357 ollamaOptions : this . ollamaOptions ,
332358 openAiCompatibleOptions : this . openAiCompatibleOptions ,
333359 geminiOptions : this . geminiOptions ,
360+ lmStudioOptions : this . lmStudioOptions ,
334361 qdrantUrl : this . qdrantUrl ,
335362 qdrantApiKey : this . qdrantApiKey ,
336363 searchMinScore : this . currentSearchMinScore ,
0 commit comments