def main():
folder_name = input("Enter the name of the folder: ")
if Path("./data").is_dir():
docs = process_pdf_files("./data/" + folder_name)
print(docs.keys())
if len(source_Docs) > 0:
res = processVectorStore_and_createQueryEngine(source_Docs, folder_name)
res.get("0x379a6f200")
query_engine_tools = [
QueryEngineTool(
query_engine=res[key].as_query_engine(),
metadata=ToolMetadata(
name=f"{key}",
description=f"Provides information {key} data",
),
)
for key in res
]
print("--------------------------------------------------------------")
# print("query engine tools array ",query_engine_tools)
# print("--------------------------------------------------------------")
sub_question_query_engine =SubQuestionQueryEngine.from_defaults(query_engine_tools=query_engine_tools)
# response = sub_question_query_engine.chat("why was Uber subject to a 4-year lock-up with respect to our shares in Aurora")
# print(response)
while True:
question = input("Enter your question: ")
if question == "exit":
break
query_engine = RouterQueryEngine(selector=LLMSingleSelector.from_defaults(), query_engine_tools=query_engine_tools)
response = query_engine.query(question)
print(response)
else:
print("No PDF files found in the folder.")
else:
print("Folder not found. Please enter a valid folder name.")
main()
i discovered a hacky way of doing this.. if there is anyway to improve this... then please let me know