Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -384,6 +384,7 @@ st.markdown("""
|
|
384 |
</style>
|
385 |
""", unsafe_allow_html=True)
|
386 |
|
|
|
387 |
# Streamlit interface
|
388 |
st.title("π PDF Reading Assistant")
|
389 |
st.markdown("### Extract tables, figures, summaries, and answers from your PDF files easily.")
|
@@ -391,6 +392,14 @@ st.markdown("### Extract tables, figures, summaries, and answers from your PDF f
|
|
391 |
uploaded_file = st.file_uploader("Upload a PDF", type="pdf")
|
392 |
if uploaded_file:
|
393 |
file_path = save_uploaded_file(uploaded_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
with st.container():
|
395 |
st.markdown("<div class='section-header'>Extract Tables and Figures</div>", unsafe_allow_html=True)
|
396 |
with st.expander("Click to Extract Tables and Figures", expanded=True):
|
@@ -398,21 +407,21 @@ if uploaded_file:
|
|
398 |
extract_button = st.button("Extract")
|
399 |
if extract_button:
|
400 |
figures, tables = process_pdf(file_path)
|
|
|
|
|
|
|
|
|
401 |
col1, col2 = st.columns(2)
|
402 |
with col1:
|
403 |
st.write("### Figures")
|
404 |
-
|
405 |
-
|
406 |
-
st.image(figure, use_column_width=True)
|
407 |
-
else:
|
408 |
-
st.write("No figures found.")
|
409 |
with col2:
|
410 |
st.write("### Tables")
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
st.write("No tables found.")
|
416 |
|
417 |
with st.container():
|
418 |
st.markdown("<div class='section-header'>Get Summary</div>", unsafe_allow_html=True)
|
@@ -421,7 +430,10 @@ if uploaded_file:
|
|
421 |
summary_button = st.button("Generate Summary")
|
422 |
if summary_button:
|
423 |
summary = summarize_pdf(file_path)
|
424 |
-
st.
|
|
|
|
|
|
|
425 |
|
426 |
with st.container():
|
427 |
st.markdown("<div class='section-header'>Chat with your PDF</div>", unsafe_allow_html=True)
|
|
|
384 |
</style>
|
385 |
""", unsafe_allow_html=True)
|
386 |
|
387 |
+
# Streamlit interface
|
388 |
# Streamlit interface
|
389 |
st.title("π PDF Reading Assistant")
|
390 |
st.markdown("### Extract tables, figures, summaries, and answers from your PDF files easily.")
|
|
|
392 |
uploaded_file = st.file_uploader("Upload a PDF", type="pdf")
|
393 |
if uploaded_file:
|
394 |
file_path = save_uploaded_file(uploaded_file)
|
395 |
+
|
396 |
+
if 'figures' not in st.session_state:
|
397 |
+
st.session_state['figures'] = None
|
398 |
+
if 'tables' not in st.session_state:
|
399 |
+
st.session_state['tables'] = None
|
400 |
+
if 'summary' not in st.session_state:
|
401 |
+
st.session_state['summary'] = None
|
402 |
+
|
403 |
with st.container():
|
404 |
st.markdown("<div class='section-header'>Extract Tables and Figures</div>", unsafe_allow_html=True)
|
405 |
with st.expander("Click to Extract Tables and Figures", expanded=True):
|
|
|
407 |
extract_button = st.button("Extract")
|
408 |
if extract_button:
|
409 |
figures, tables = process_pdf(file_path)
|
410 |
+
st.session_state['figures'] = figures
|
411 |
+
st.session_state['tables'] = tables
|
412 |
+
|
413 |
+
if st.session_state['figures']:
|
414 |
col1, col2 = st.columns(2)
|
415 |
with col1:
|
416 |
st.write("### Figures")
|
417 |
+
for figure in st.session_state['figures']:
|
418 |
+
st.image(figure, use_column_width=True)
|
|
|
|
|
|
|
419 |
with col2:
|
420 |
st.write("### Tables")
|
421 |
+
for table in st.session_state['tables']:
|
422 |
+
st.image(table, use_column_width=True)
|
423 |
+
else:
|
424 |
+
st.write("No figures or tables found.")
|
|
|
425 |
|
426 |
with st.container():
|
427 |
st.markdown("<div class='section-header'>Get Summary</div>", unsafe_allow_html=True)
|
|
|
430 |
summary_button = st.button("Generate Summary")
|
431 |
if summary_button:
|
432 |
summary = summarize_pdf(file_path)
|
433 |
+
st.session_state['summary'] = summary
|
434 |
+
|
435 |
+
if st.session_state['summary']:
|
436 |
+
st.markdown(st.session_state['summary'], unsafe_allow_html=True)
|
437 |
|
438 |
with st.container():
|
439 |
st.markdown("<div class='section-header'>Chat with your PDF</div>", unsafe_allow_html=True)
|