From 6cd571fba462dda391c7f6ae3f7b440370b98f8b Mon Sep 17 00:00:00 2001 From: orkhank <118054233+orkhank@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:38:14 +0300 Subject: [PATCH] feat(add_texts): ensure index readiness --- libs/partners/pinecone/langchain_pinecone/vectorstores.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/partners/pinecone/langchain_pinecone/vectorstores.py b/libs/partners/pinecone/langchain_pinecone/vectorstores.py index eeb8450a47e88..e4548f0852541 100644 --- a/libs/partners/pinecone/langchain_pinecone/vectorstores.py +++ b/libs/partners/pinecone/langchain_pinecone/vectorstores.py @@ -294,6 +294,8 @@ def add_texts( for metadata, text in zip(metadatas, texts): metadata[self._text_key] = text + initial_vector_count = self._get_vector_count() + # For loops to avoid memory issues and optimize when using HTTP based embeddings # The first loop runs the embeddings, it benefits when using OpenAI embeddings # The second loops runs the pinecone upsert asynchronously. @@ -323,6 +325,8 @@ def add_texts( **kwargs, ) + asyncio.run(self._wait_on_index(len(texts) + initial_vector_count)) + return ids def similarity_search_with_score(