Skip to content

Commit

Permalink
move to manual sync and chunk file uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
lassejaco committed Oct 29, 2024
1 parent 4a26ec7 commit e0dcb99
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions devcon-api/src/services/ai/open-ai/open-ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,19 @@ export const api = (() => {
// }
})

// Upload all sessions in a single batch
const response = await openai.beta.vectorStores.fileBatches.uploadAndPoll(vectorStore.id, { files: sessionFiles })
// Split files into batches of 50
const batchSize = 100
const batches = []
for (let i = 0; i < sessionFiles.length; i += batchSize) {
batches.push(sessionFiles.slice(i, i + batchSize))
}

console.log(response, 'response')
// Upload each batch sequentially
for (const batch of batches) {
const response = await openai.beta.vectorStores.fileBatches.uploadAndPoll(vectorStore.id, { files: batch })
console.log(`Uploaded batch of ${batch.length} files`)
console.log(response, 'response')
}

// Update assistant to use our new vector store
await openai.beta.assistants.update(assistantID, {
Expand Down

0 comments on commit e0dcb99

Please sign in to comment.