From 9731ebb27def92f4c25a165d6ca7060f040fd81f Mon Sep 17 00:00:00 2001 From: Sai Pavan Kumar Date: Mon, 22 Jul 2024 18:06:49 +0530 Subject: [PATCH] fix: bug where the pinecone component was inserting embeddings three times instead of once. (#2826) fixed the bug where pinecone component inserts embeddings 3 times When we send the chunks with the embedding component to the Pinecone component, the generated embeddings are being saved three times instead of once. --- .../base/langflow/components/vectorstores/Pinecone.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/base/langflow/components/vectorstores/Pinecone.py b/src/backend/base/langflow/components/vectorstores/Pinecone.py index e09711d08..51c201fa8 100644 --- a/src/backend/base/langflow/components/vectorstores/Pinecone.py +++ b/src/backend/base/langflow/components/vectorstores/Pinecone.py @@ -22,6 +22,7 @@ class PineconeVectorStoreComponent(LCVectorStoreComponent): documentation = "https://python.langchain.com/v0.2/docs/integrations/vectorstores/pinecone/" name = "Pinecone" icon = "Pinecone" + pinecone_instance = None inputs = [ StrInput(name="index_name", display_name="Index Name", required=True), @@ -61,6 +62,8 @@ class PineconeVectorStoreComponent(LCVectorStoreComponent): return self._build_pinecone() def _build_pinecone(self) -> Pinecone: + if self.pinecone_instance is not None: + return self.pinecone_instance from langchain_pinecone._utilities import DistanceStrategy from langchain_pinecone.vectorstores import Pinecone @@ -85,7 +88,7 @@ class PineconeVectorStoreComponent(LCVectorStoreComponent): if documents: pinecone.add_documents(documents) - + self.pinecone_instance = pinecone return pinecone def search_documents(self) -> List[Data]: