[v1] Allow upsert to support batchSize for batched vector upserts #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
In v0 there was a utility called
chunkedUpsert()
which allowed users to upsert vectors in chunks:pinecone-ts-client/src/v0/utils.ts
Lines 58 to 65 in 6fbc502
We want to offer this functionality in v1 as well to ease usage around the 1000 vector limit for upserting, and give end users more control over their upserts.
Solution
batchUpsert()
andsliceArrayToBatches()
helper functions to/data/upsert.ts
. Because of how tightly coupled these helpers are to upsert specifically it felt like it made sense to keep them close to the file itself and test the inherent functionality in the existing test file.vectors
andbatchSize
.upsert()
to handle checking whether we've received an array vs. object, and branching depending on the arguments.upsert.test.ts
to validate batching behavior making the appropriate calls to upsert API.Type of Change
Test Plan
Make sure to manually test both cases:
index.upsert( ... )
directly.batchSize
:{ vectors: [ ... ], batchSize: 10}
Note: For easing testing I generated a set of 100 vectors. You can find them in the gist here if it's helpful: https://gist.github.com/austin-denoble/41cfd5c8857bac314435bb21f6caa25d