Spaces:
Runtime error
Runtime error
captain-awesome
commited on
Commit
•
c296508
1
Parent(s):
d5d564a
Update app.py
Browse files
app.py
CHANGED
@@ -351,73 +351,73 @@ def retrieve_bot_answer(query):
|
|
351 |
|
352 |
# from your_module import load_model, set_custom_prompt, set_custom_prompt_condense, create_vector_database, retrieve_bot_answer
|
353 |
|
354 |
-
|
355 |
-
|
356 |
|
357 |
-
#
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
#
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
#
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
#
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
|
388 |
-
|
389 |
-
|
390 |
|
391 |
|
392 |
|
393 |
-
def main():
|
394 |
-
|
395 |
-
|
396 |
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
|
403 |
-
|
404 |
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
|
420 |
-
|
421 |
|
422 |
-
if __name__ == "__main__":
|
423 |
-
|
|
|
351 |
|
352 |
# from your_module import load_model, set_custom_prompt, set_custom_prompt_condense, create_vector_database, retrieve_bot_answer
|
353 |
|
354 |
+
def main():
|
355 |
+
st.title("Docuverse")
|
356 |
|
357 |
+
# Upload files
|
358 |
+
uploaded_files = st.file_uploader("Upload your documents", type=["pdf", "md", "txt", "csv", "py", "epub", "html", "ppt", "pptx", "doc", "docx", "odt", "ipynb"], accept_multiple_files=True)
|
359 |
+
|
360 |
+
if uploaded_files:
|
361 |
+
# Process uploaded files
|
362 |
+
for uploaded_file in uploaded_files:
|
363 |
+
st.write(f"Uploaded: {uploaded_file.name}")
|
364 |
+
st.write(f"Uploaded: {type(uploaded_file)}")
|
365 |
+
|
366 |
+
st.write("Chat with the Document:")
|
367 |
+
query = st.text_input("Ask a question:")
|
368 |
+
|
369 |
+
if st.button("Get Answer"):
|
370 |
+
if query:
|
371 |
+
# Load model, set prompts, create vector database, and retrieve answer
|
372 |
+
try:
|
373 |
+
llm = load_model()
|
374 |
+
prompt = set_custom_prompt()
|
375 |
+
CONDENSE_QUESTION_PROMPT = set_custom_prompt_condense()
|
376 |
+
loaded_documents = load_document(uploaded_files)
|
377 |
+
db = create_vector_database(loaded_documents)
|
378 |
+
response = retrieve_bot_answer(query)
|
379 |
+
|
380 |
+
# Display bot response
|
381 |
+
st.write("Bot Response:")
|
382 |
+
st.write(response)
|
383 |
+
except Exception as e:
|
384 |
+
st.error(f"An error occurred: {str(e)}")
|
385 |
+
else:
|
386 |
+
st.warning("Please enter a question.")
|
387 |
|
388 |
+
if __name__ == "__main__":
|
389 |
+
main()
|
390 |
|
391 |
|
392 |
|
393 |
+
# def main():
|
394 |
+
# # Upload files
|
395 |
+
# file_uploader = gr.inputs.file_uploader(multiple=True, accept_multiple_files=True, types=["pdf", "md", "txt", "csv", "py", "epub", "html", "ppt", "pptx", "doc", "docx", "odt", "ipynb"])
|
396 |
|
397 |
+
# # Process uploaded files
|
398 |
+
# def process_files(files):
|
399 |
+
# for file in files:
|
400 |
+
# print(f"Uploaded: {file.name}")
|
401 |
+
# print(f"Uploaded: {type(file)}")
|
402 |
|
403 |
+
# query = gr.inputs.text(label="Ask a question:")
|
404 |
|
405 |
+
# # Load model, set prompts, create vector database, and retrieve answer
|
406 |
+
# def get_answer(query, files):
|
407 |
+
# try:
|
408 |
+
# llm = load_model()
|
409 |
+
# prompt = set_custom_prompt()
|
410 |
+
# CONDENSE_QUESTION_PROMPT = set_custom_prompt_condense()
|
411 |
+
# loaded_documents = load_document(files)
|
412 |
+
# db = create_vector_database(loaded_documents)
|
413 |
+
# response = retrieve_bot_answer(query)
|
414 |
|
415 |
+
# # Display bot response
|
416 |
+
# return response
|
417 |
+
# except Exception as e:
|
418 |
+
# return f"An error occurred: {str(e)}"
|
419 |
|
420 |
+
# gr.outputs.text(get_answer, query, file_uploader)
|
421 |
|
422 |
+
# if __name__ == "__main__":
|
423 |
+
# gr.Interface(main).launch()
|