From 41d17c4e590b22c2c6ccacdceeb7e77e5fe93115 Mon Sep 17 00:00:00 2001 From: C Cheng Date: Thu, 4 Apr 2024 10:19:07 -0400 Subject: [PATCH] fix lint --- .../chainlit-household-bot.py | 21 ++++++++++--------- 02-household-queries/retrieval.py | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/02-household-queries/chainlit-household-bot.py b/02-household-queries/chainlit-household-bot.py index f49a29a..ee06cde 100755 --- a/02-household-queries/chainlit-household-bot.py +++ b/02-household-queries/chainlit-household-bot.py @@ -296,26 +296,27 @@ async def on_click_upload_default_files(action: cl.Action): async def on_click_upload_file_query(action: cl.Action): files = None # Wait for the user to upload a file - while files == None: + while files is None: files = await cl.AskFileMessage( content="Please upload a pdf or json file to begin!", accept=["text/plain", "application/pdf", "application/json"], max_size_mb=20, timeout=180, ).send() - file = files[0] + file = files[0] + if(file.type == "application/pdf"): + add_pdf_to_vector_db(vectordb=vectordb, file_path=file.path) + elif(file.type == "application/json"): + add_json_html_data_to_vector_db(vectordb=vectordb, file_path=file.path, content_key="content", index_key="preferredPhrase") + msg = cl.Message(content=f"Processing `{file.name}`...", disable_feedback=True) + await msg.send() + msg.content = f"Processing `{file.name}` done. You can now ask questions!" + await msg.update() # initialize db await set_vector_db() vectordb=cl.user_session.get("vectordb") - if(file.type == "application/pdf"): - add_pdf_to_vector_db(vectordb=vectordb, file_path=file.path) - elif(file.type == "application/json"): - add_json_html_data_to_vector_db(vectordb=vectordb, file_path=file.path, content_key="content", index_key="preferredPhrase") - msg = cl.Message(content=f"Processing `{file.name}`...", disable_feedback=True) - await msg.send() - msg.content = f"Processing `{file.name}` done. You can now ask questions!" - await msg.update() + async def retrieval_function(vectordb, llm): retriever = vectordb.as_retriever(search_kwargs={"k": 1}) diff --git a/02-household-queries/retrieval.py b/02-household-queries/retrieval.py index 7dc2790..46d91ea 100644 --- a/02-household-queries/retrieval.py +++ b/02-household-queries/retrieval.py @@ -24,7 +24,7 @@ def retrieval_call(llm, vectordb, question): ) # question = os.environ.get("USER_QUERY") - if question == None: + if question is None: print("Please state your question here: ") question = input() # Invoke the retrieval chain