Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -117,8 +117,23 @@ def main():
|
|
117 |
pdf_text = extract_text_from_pdf(uploaded_file)
|
118 |
st.success("Text extracted successfully!")
|
119 |
st.text_area("Extracted Text:", pdf_text, height=300)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
except Exception as e:
|
121 |
st.error(f"Error extracting text: {e}")
|
|
|
|
|
|
|
122 |
# if uploaded_file:
|
123 |
# st.write("Extracting text and populating the database...")
|
124 |
# pdf_text = extract_text_from_pdf(uploaded_file)
|
|
|
117 |
pdf_text = extract_text_from_pdf(uploaded_file)
|
118 |
st.success("Text extracted successfully!")
|
119 |
st.text_area("Extracted Text:", pdf_text, height=300)
|
120 |
+
add_pdf_text_to_db(collection, pdf_text)
|
121 |
+
st.success("PDF text has been added to the database. You can now query it!")
|
122 |
+
if query:
|
123 |
+
try:
|
124 |
+
answer, metadata = query_pdf_data(collection, query, retriever_model)
|
125 |
+
st.subheader("Answer:")
|
126 |
+
st.write(answer[0]['generated_text'])
|
127 |
+
st.subheader("Retrieved Context:")
|
128 |
+
for meta in metadata[0]:
|
129 |
+
st.write(meta)
|
130 |
+
except Exception as e:
|
131 |
+
st.error(f"An error occurred: {str(e)}")
|
132 |
except Exception as e:
|
133 |
st.error(f"Error extracting text: {e}")
|
134 |
+
|
135 |
+
|
136 |
+
|
137 |
# if uploaded_file:
|
138 |
# st.write("Extracting text and populating the database...")
|
139 |
# pdf_text = extract_text_from_pdf(uploaded_file)
|