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.
This commit is contained in:
Sai Pavan Kumar 2024-07-22 18:06:49 +05:30 committed by GitHub
commit 9731ebb27d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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]: