From 137cf67f40965c5cc74f3a9d14df869f85f264c9 Mon Sep 17 00:00:00 2001 From: Marcus Schiesser <mail@marcusschiesser.de> Date: Thu, 14 Mar 2024 10:15:52 +0700 Subject: [PATCH] fix: Use Pinecone namespaces for all operations (#633) --- .changeset/fluffy-squids-play.md | 5 +++++ .../src/storage/vectorStore/PineconeVectorStore.ts | 12 +++++------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 .changeset/fluffy-squids-play.md diff --git a/.changeset/fluffy-squids-play.md b/.changeset/fluffy-squids-play.md new file mode 100644 index 000000000..bc72fbb04 --- /dev/null +++ b/.changeset/fluffy-squids-play.md @@ -0,0 +1,5 @@ +--- +"llamaindex": patch +--- + +Use Pinecone namespaces for all operations diff --git a/packages/core/src/storage/vectorStore/PineconeVectorStore.ts b/packages/core/src/storage/vectorStore/PineconeVectorStore.ts index 74c325529..515995469 100644 --- a/packages/core/src/storage/vectorStore/PineconeVectorStore.ts +++ b/packages/core/src/storage/vectorStore/PineconeVectorStore.ts @@ -73,7 +73,7 @@ export class PineconeVectorStore implements VectorStore { async index() { const db: Pinecone = await this.getDb(); - return await db.index(this.indexName); + return db.index(this.indexName).namespace(this.namespace); } /** @@ -82,8 +82,8 @@ export class PineconeVectorStore implements VectorStore { * @returns The result of the delete query. */ async clearIndex() { - const db: Pinecone = await this.getDb(); - return await db.index(this.indexName).deleteAll(); + const idx = await this.index(); + return await idx.deleteAll(); } /** @@ -155,12 +155,10 @@ export class PineconeVectorStore implements VectorStore { }; const idx = await this.index(); - const results = await idx.namespace(this.namespace).query(options); + const results = await idx.query(options); const idList = results.matches.map((row) => row.id); - const records: FetchResponse<any> = await idx - .namespace(this.namespace) - .fetch(idList); + const records: FetchResponse<any> = await idx.fetch(idList); const rows = Object.values(records.records); const nodes = rows.map((row) => { -- GitLab