ashok2216 commited on
Commit
6580a7b
·
verified ·
1 Parent(s): 48010b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -70,19 +70,21 @@ def main():
70
  add_pdf_text_to_db(collection, pdf_text)
71
  st.success("PDF text has been added to the database. You can now query it!")
72
  query = st.text_input("Enter your query about the PDF:")
73
- if query:
74
- try:
75
- answer, metadata = query_pdf_data(collection, query, retriever_model)
76
- st.subheader("Answer:")
77
- st.write(answer[0]['generated_text'])
78
- st.subheader("Retrieved Context:")
79
- for meta in metadata[0]:
80
- st.write(meta)
81
- except Exception as e:
82
- st.error(f"An error occurred: {str(e)}")
83
  except Exception as e:
84
  st.error(f"Error extracting text: {e}")
85
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  if __name__ == "__main__":
88
  main()
 
70
  add_pdf_text_to_db(collection, pdf_text)
71
  st.success("PDF text has been added to the database. You can now query it!")
72
  query = st.text_input("Enter your query about the PDF:")
73
+
 
 
 
 
 
 
 
 
 
74
  except Exception as e:
75
  st.error(f"Error extracting text: {e}")
76
 
77
+ if query:
78
+ try:
79
+ answer, metadata = query_pdf_data(collection, query, retriever_model)
80
+ st.subheader("Answer:")
81
+ st.write(answer[0]['generated_text'])
82
+ st.subheader("Retrieved Context:")
83
+ for meta in metadata[0]:
84
+ st.write(meta)
85
+ except Exception as e:
86
+ st.error(f"An error occurred: {str(e)}")
87
+
88
 
89
  if __name__ == "__main__":
90
  main()