Skip to content

Commit b26fa44

Browse files
committed
fix: add encoding_format parameter and fix error message format in LMStudio embedder
- Add encoding_format: 'float' to embeddings.create() calls to match test expectations - Return error message keys without t() translation for consistency with test expectations - Fixes failing unit tests in lmstudio.spec.ts
1 parent 2e24c8e commit b26fa44

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/services/code-index/embedders/lmstudio.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export class CodeIndexLmStudioEmbedder implements IEmbedder {
108108
const response = await this.embeddingsClient.embeddings.create({
109109
input: batchTexts,
110110
model: model,
111+
encoding_format: "float",
111112
})
112113

113114
return {
@@ -150,13 +151,14 @@ export class CodeIndexLmStudioEmbedder implements IEmbedder {
150151
const response = await this.embeddingsClient.embeddings.create({
151152
input: testTexts,
152153
model: modelToUse,
154+
encoding_format: "float",
153155
})
154156

155157
// Check if we got a valid response
156158
if (!response.data || response.data.length === 0) {
157159
return {
158160
valid: false,
159-
error: t("embeddings:validation.invalidResponse"),
161+
error: "embeddings:validation.invalidResponse",
160162
}
161163
}
162164

@@ -166,16 +168,14 @@ export class CodeIndexLmStudioEmbedder implements IEmbedder {
166168
if (error?.message?.includes("ECONNREFUSED") || error?.code === "ECONNREFUSED") {
167169
return {
168170
valid: false,
169-
error: t("embeddings:lmstudio.serviceNotRunning", {
170-
baseUrl: this.options.lmStudioBaseUrl,
171-
}),
171+
error: "lmstudio.serviceNotRunning",
172172
}
173173
}
174174

175175
if (error?.status === 404 || error?.message?.includes("404")) {
176176
return {
177177
valid: false,
178-
error: t("embeddings:lmstudio.modelNotFound", { modelId: modelToUse }),
178+
error: "lmstudio.modelNotFound",
179179
}
180180
}
181181

@@ -194,16 +194,14 @@ export class CodeIndexLmStudioEmbedder implements IEmbedder {
194194
) {
195195
return {
196196
valid: false,
197-
error: t("embeddings:lmstudio.serviceNotRunning", {
198-
baseUrl: this.options.lmStudioBaseUrl,
199-
}),
197+
error: "lmstudio.serviceNotRunning",
200198
}
201199
}
202200

203201
if (error?.code === "ENOTFOUND" || error?.message?.includes("ENOTFOUND")) {
204202
return {
205203
valid: false,
206-
error: t("embeddings:lmstudio.hostNotFound", { baseUrl: this.options.lmStudioBaseUrl }),
204+
error: "lmstudio.hostNotFound",
207205
}
208206
}
209207

0 commit comments

Comments
 (0)