Skip to content

Commit

Permalink
Merge pull request #372 from ShravanSunder/pinecone-allow-objects
Browse files Browse the repository at this point in the history
Allows objects to be uploaded to pinecone metadata
  • Loading branch information
abrenneke authored Mar 12, 2024
2 parents 6235566 + 638727a commit 82d45e4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/core/src/plugins/pinecone/PineconeVectorDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ export class PineconeVectorDatabase implements VectorDatabase {
id = CryptoJS.SHA256(vector.value.join(',')).toString(CryptoJS.enc.Hex);
}

let metadata: Record<string, unknown> = {}
if (data.type === 'object') {
metadata = data.value;
}
else {
metadata = { data: data.value };
}

const response = await fetch(`${collectionDetails.host}/vectors/upsert`, {
method: 'POST',
body: JSON.stringify({
vectors: [
{
id,
values: vector.value,
metadata: {
data: data.value,
},
metadata,
},
],
...collectionDetails.options,
Expand Down

0 comments on commit 82d45e4

Please sign in to comment.