Skip to content

Commit 8b6bbce

Browse files
Dixie Flatlinedaniel-lxs
authored andcommitted
fixup! Manually specify openai-compat format and parse it
Improve comment
1 parent 670cbe3 commit 8b6bbce

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/services/code-index/embedders/openai-compatible.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ export class OpenAICompatibleEmbedder implements IEmbedder {
111111
const response = await this.embeddingsClient.embeddings.create({
112112
input: batchTexts,
113113
model: model,
114-
encoding_format: "base64", // Use base64 to protect embedding dimensions from openai sabotage
114+
// The OpenAI package has custom parsing that truncates embedding dimension to 256,
115+
// which destroys accuracy.
116+
// If we pass `encoding_format: "base64"`, it does not perform any parsing,
117+
// leaving parsing up to us. This is likely a bug in the OpenAI package, possibly
118+
// addressed by https://github.com/openai/openai-node/pull/1448 (but maybe not)
119+
encoding_format: "base64",
115120
})
116121

117122
// Convert base64 embeddings to float32 arrays

0 commit comments

Comments
 (0)