Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import PyPDF2
|
|
|
|
|
|
|
| 3 |
import io
|
| 4 |
from typing import List, Dict
|
| 5 |
from groq import Groq
|
|
@@ -106,7 +108,37 @@ class PDFChatAssistant:
|
|
| 106 |
"role": "user",
|
| 107 |
"content": "Extract the most important key points from this PDF"
|
| 108 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
|
|
|
| 110 |
# Main chat area
|
| 111 |
st.header("Chat with Your PDF")
|
| 112 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import PyPDF2
|
| 3 |
+
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
| 4 |
+
from streamlit.source_util import get_pages
|
| 5 |
import io
|
| 6 |
from typing import List, Dict
|
| 7 |
from groq import Groq
|
|
|
|
| 108 |
"role": "user",
|
| 109 |
"content": "Extract the most important key points from this PDF"
|
| 110 |
})
|
| 111 |
+
def show_full_text():
|
| 112 |
+
st.title("📄 Full PDF Text")
|
| 113 |
+
|
| 114 |
+
# Try to retrieve the PDF text from the main page's session state
|
| 115 |
+
ctx = get_script_run_ctx()
|
| 116 |
+
session_info = get_pages('app.py')
|
| 117 |
+
|
| 118 |
+
if 'pdf_text' in st.session_state and st.session_state.pdf_text:
|
| 119 |
+
st.text_area(
|
| 120 |
+
"Complete Extracted Text",
|
| 121 |
+
value=st.session_state.pdf_text,
|
| 122 |
+
height=600,
|
| 123 |
+
disabled=True
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
# Additional buttons
|
| 127 |
+
col1, col2 = st.columns(2)
|
| 128 |
+
with col1:
|
| 129 |
+
if st.button("Copy to Clipboard"):
|
| 130 |
+
st.code(st.session_state.pdf_text)
|
| 131 |
+
st.success("Text copied to clipboard!")
|
| 132 |
+
|
| 133 |
+
with col2:
|
| 134 |
+
if st.button("Back to Chat"):
|
| 135 |
+
st.switch_page("app.py")
|
| 136 |
+
else:
|
| 137 |
+
st.warning("No PDF text available. Please upload a PDF first.")
|
| 138 |
+
if st.button("Back to Chat"):
|
| 139 |
+
st.switch_page("app.py")
|
| 140 |
|
| 141 |
+
|
| 142 |
# Main chat area
|
| 143 |
st.header("Chat with Your PDF")
|
| 144 |
|