Skip to content

Commit 2814145

Browse files
fix: address PR feedback
Co-authored-by: jmbish04 <26469722+jmbish04@users.noreply.github.com>
1 parent da34186 commit 2814145

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

backend/src/lib/vectorize/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Env } from "../../types";
22

3+
const BATCH_SIZE = 100;
4+
35
export interface CodeChunk {
46
id: string;
57
repo: string;
@@ -18,7 +20,7 @@ export async function generateEmbeddings(env: Env, texts: string[]) {
1820
});
1921

2022
// Type assertion since Workers AI types can be tricky
21-
return (response as any).data;
23+
return (response as { data: number[][] }).data;
2224
}
2325

2426
export function chunkCode(content: string, path: string, maxChunkSize = 1000, overlap = 200): CodeChunk[] {
@@ -67,8 +69,7 @@ export async function upsertChunks(env: Env, chunks: CodeChunk[], repoFullName:
6769
}
6870
}));
6971

70-
// Upsert in batches of 100 max
71-
const BATCH_SIZE = 100;
72+
// Upsert in batches
7273
for (let i = 0; i < vectorizeVectors.length; i += BATCH_SIZE) {
7374
const batch = vectorizeVectors.slice(i, i + BATCH_SIZE);
7475
await env.RESEARCH_INDEX.upsert(batch);

0 commit comments

Comments
 (0)