From 87060b75f6b6d8136eca3dcda0b2af1f0ae7879e Mon Sep 17 00:00:00 2001 From: Tarraann Date: Tue, 18 Jul 2023 13:57:04 +0530 Subject: [PATCH] Changes in existing flow --- superagi/vector_store/pinecone.py | 2 +- superagi/vector_store/qdrant.py | 21 +++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/superagi/vector_store/pinecone.py b/superagi/vector_store/pinecone.py index 4a37cdc63..5552afbc7 100644 --- a/superagi/vector_store/pinecone.py +++ b/superagi/vector_store/pinecone.py @@ -73,7 +73,7 @@ def add_texts( metadata[self.text_field] = text vectors.append((id, self.embedding_model.get_embedding(text), metadata)) - self.index.upsert(vectors, namespace=namespace, batch_size=batch_size) + self.add_embeddings_to_vector_db({"vectors": vectors}) return ids def get_matching_text(self, query: str, top_k: int = 5, metadata: Optional[dict] = {}, **kwargs: Any) -> List[Document]: diff --git a/superagi/vector_store/qdrant.py b/superagi/vector_store/qdrant.py index 7cb8bf421..c58cc74fd 100644 --- a/superagi/vector_store/qdrant.py +++ b/superagi/vector_store/qdrant.py @@ -84,21 +84,14 @@ def add_texts( text_batch = input_texts[i * batch_limit: (i + 1) * batch_limit] metadata_batch = metadata_list[i * batch_limit: (i + 1) * batch_limit] or None id_batch = id_list[i * batch_limit: (i + 1) * batch_limit] - - self.client.upsert( - collection_name=self.collection_name, - points=models.Batch.construct( - ids=id_batch, - vectors=self.__get_embeddings(text_batch), - payloads=self.__build_payloads( - text_batch, - metadata_batch, - self.text_field_payload_key, - self.metadata_payload_key, - ), - ), + vectors = self.__get_embeddings(text_batch) + payloads = self.__build_payloads( + text_batch, + metadata_batch, + self.text_field_payload_key, + self.metadata_payload_key, ) - + self.add_embeddings_to_vector_db({"ids": id_batch, "vectors": vectors, "payloads": payloads}) collected_ids.extend(id_batch) return collected_ids