Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheng26 committed Apr 4, 2024
1 parent eab0eba commit 41d17c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions 02-household-queries/chainlit-household-bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion 02-household-queries/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41d17c4

Please sign in to comment.