Skip to content

Commit 1b38421

Browse files
committed
Removes embedding queue
Removes the embedding queue implementation from the Gemini embedder. This simplifies the embedding process by directly executing embedding tasks without queuing, potentially improving responsiveness.
1 parent ee15d91 commit 1b38421

File tree

1 file changed

+8
-33
lines changed

1 file changed

+8
-33
lines changed

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

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,16 @@ export class CodeIndexGeminiEmbedder extends GeminiHandler implements IEmbedder
2828
* @returns A promise that resolves to an EmbeddingResponse containing the embeddings.
2929
*/
3030
async createEmbeddings(texts: string[], model?: string): Promise<EmbeddingResponse> {
31-
// This function will be executed when it's this task's turn in the queue.
32-
const taskExecution = async (): Promise<EmbeddingResponse> => {
33-
try {
34-
const modelId = model || this.defaultModelId
35-
// embedWithTokenLimit handles batching, internal delays, and retries for API calls.
36-
const result = await this.embedWithTokenLimit(texts, modelId, this.defaultTaskType)
37-
return {
38-
embeddings: result.embeddings,
39-
// If EmbeddingResponse is updated to include usage, and result.usage is reliable:
40-
// usage: result.usage,
41-
}
42-
} catch (error: any) {
43-
// Errors are logged within embedWithTokenLimit or _embedBatchWithRetries.
44-
// This re-throws the error to be caught by the specific caller of createEmbeddings.
45-
console.error("Error during Gemini embedding task execution in queue:", error.message)
46-
throw error
31+
try {
32+
const modelId = model || this.defaultModelId
33+
const result = await this.embedWithTokenLimit(texts, modelId, this.defaultTaskType)
34+
return {
35+
embeddings: result.embeddings,
4736
}
37+
} catch (error: any) {
38+
console.error("Error during Gemini embedding task execution in queue:", error.message)
39+
throw error
4840
}
49-
50-
// Chain this task onto the queue.
51-
// The actual execution of taskExecution() is deferred until the previous promise in the queue resolves.
52-
const taskPromise = this.embeddingQueue.then(taskExecution)
53-
54-
// Update the queue to wait for the current task to complete (or fail).
55-
// .catch(() => {}) ensures that an error in one task doesn't break the queue for subsequent tasks.
56-
// Each task's success/failure is handled by its own promise (taskPromise), which is returned to the caller.
57-
this.embeddingQueue = taskPromise
58-
.catch(() => {
59-
// This task failed, but the queue should proceed for the next one.
60-
// The error from taskPromise will be handled by its specific awaiter below.
61-
})
62-
.then(() => undefined) // Ensure the queue promise resolves to void for the next .then() in the chain.
63-
64-
// Return the promise for this specific task. The caller will await this.
65-
return taskPromise
6641
}
6742

6843
/**

0 commit comments

Comments
 (0)