From 4106720c8e38405e2806c4192ab36ffc554fc375 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:30:23 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: pallavi jaini --- comps/dataprep/pinecone/prepare_doc_pinecone.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/comps/dataprep/pinecone/prepare_doc_pinecone.py b/comps/dataprep/pinecone/prepare_doc_pinecone.py index a0018b91fd..ec0e200a20 100644 --- a/comps/dataprep/pinecone/prepare_doc_pinecone.py +++ b/comps/dataprep/pinecone/prepare_doc_pinecone.py @@ -44,6 +44,7 @@ def check_index_existance(): else: return True + def create_index(client): print(f"[ create index ] creating index {PINECONE_INDEX_NAME}") try: @@ -59,6 +60,7 @@ def create_index(client): return False return True + def drop_index(index_name): print(f"[ drop index ] dropping index {index_name}") pc = Pinecone(api_key=PINECONE_API_KEY) @@ -70,6 +72,7 @@ def drop_index(index_name): return False return True + def ingest_data_to_pinecone(doc_path: DocPath): """Ingest document to Pinecone.""" path = doc_path.path @@ -107,12 +110,11 @@ def ingest_data_to_pinecone(doc_path: DocPath): pc = Pinecone(api_key=PINECONE_API_KEY) - #Checking Index existance - if (not check_index_existance()): + # Checking Index existence + if not check_index_existance(): # Creating the index create_index(pc) print("Successfully created the index", PINECONE_INDEX_NAME) - # Batch size batch_size = 32 @@ -145,8 +147,8 @@ async def ingest_link_to_pinecone(link_list: List[str]): pc = Pinecone(api_key=PINECONE_API_KEY) - #Checking Index existance - if (not check_index_existance()): + # Checking Index existence + if not check_index_existance(): # Creating the index create_index(pc) print("Successfully created the index", PINECONE_INDEX_NAME) @@ -254,7 +256,7 @@ async def delete_all(file_path: str = Body(..., embed=True)): else: raise HTTPException(status_code=404, detail="Single file deletion is not implemented yet") - + if __name__ == "__main__": create_upload_folder(upload_folder) opea_microservices["opea_service@prepare_doc_pinecone"].start()