Update verifier.py
Browse files- verifier.py +32 -35
verifier.py
CHANGED
|
@@ -28,46 +28,15 @@ def verifier_page():
|
|
| 28 |
|
| 29 |
# Initialize session state variables if not present
|
| 30 |
if 'selected_file' not in st.session_state:
|
| 31 |
-
st.session_state.selected_file =
|
| 32 |
-
if 'selected_text' not in st.session_state:
|
| 33 |
-
|
| 34 |
#if 'selected_ai' not in st.session_state:
|
| 35 |
# st.session_state.selected_ai = ""
|
| 36 |
|
| 37 |
-
# Check if a file has already been selected and displayed
|
| 38 |
-
if st.session_state.selected_file:
|
| 39 |
-
# When a file is selected, clear everything and display the details only
|
| 40 |
-
st.empty() # Clear all content before displaying details
|
| 41 |
-
st.write(f"Selected File: {st.session_state.selected_file}")
|
| 42 |
-
#st.write(f"AI Response: {st.session_state.selected_ai}")
|
| 43 |
-
else:
|
| 44 |
-
# Automatically load and display the data table on page load
|
| 45 |
-
data = fetch_data(fields_to_fetch)
|
| 46 |
-
|
| 47 |
-
if data:
|
| 48 |
-
df = pd.DataFrame(data)
|
| 49 |
-
|
| 50 |
-
# Display the DataFrame
|
| 51 |
-
st.dataframe(df)
|
| 52 |
-
|
| 53 |
-
# Add buttons for each row in the DataFrame
|
| 54 |
-
for index, row in df.iterrows():
|
| 55 |
-
col1, col2 = st.columns([4, 1])
|
| 56 |
-
with col1:
|
| 57 |
-
st.write(row['filename'])
|
| 58 |
-
|
| 59 |
-
with col2:
|
| 60 |
-
# Button to view details of each row
|
| 61 |
-
button_key = f"view_{index}"
|
| 62 |
-
if st.button("See details", key=button_key):
|
| 63 |
-
# Update the session state with the selected file details
|
| 64 |
-
st.session_state.selected_file = row['text']
|
| 65 |
-
#st.session_state.selected_text = row['text']
|
| 66 |
|
| 67 |
-
# Clear existing content on button click
|
| 68 |
-
st.rerun()
|
| 69 |
|
| 70 |
-
|
| 71 |
# Process the selected file and generate AI response
|
| 72 |
pdf_path = 'VCS-Standard.pdf'
|
| 73 |
start_page = 0 # Start extracting from the first page (0-based index)
|
|
@@ -102,6 +71,34 @@ def verifier_page():
|
|
| 102 |
st.write(f"Selected File: {st.session_state.selected_file}")
|
| 103 |
#st.write(f"AI Response: {st.session_state.selected_ai}")
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
# Helper function to extract text from PDF
|
| 106 |
def extract_text_from_pdf(uploaded_file, start_page, end_page):
|
| 107 |
if uploaded_file is None:
|
|
|
|
| 28 |
|
| 29 |
# Initialize session state variables if not present
|
| 30 |
if 'selected_file' not in st.session_state:
|
| 31 |
+
st.session_state.selected_file = ""
|
| 32 |
+
#if 'selected_text' not in st.session_state:
|
| 33 |
+
# st.session_state.selected_text = ""
|
| 34 |
#if 'selected_ai' not in st.session_state:
|
| 35 |
# st.session_state.selected_ai = ""
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
if st.session_state.selected_file:
|
| 40 |
# Process the selected file and generate AI response
|
| 41 |
pdf_path = 'VCS-Standard.pdf'
|
| 42 |
start_page = 0 # Start extracting from the first page (0-based index)
|
|
|
|
| 71 |
st.write(f"Selected File: {st.session_state.selected_file}")
|
| 72 |
#st.write(f"AI Response: {st.session_state.selected_ai}")
|
| 73 |
|
| 74 |
+
|
| 75 |
+
else:
|
| 76 |
+
# Automatically load and display the data table on page load
|
| 77 |
+
data = fetch_data(fields_to_fetch)
|
| 78 |
+
if data:
|
| 79 |
+
df = pd.DataFrame(data)
|
| 80 |
+
|
| 81 |
+
# Display the DataFrame
|
| 82 |
+
st.dataframe(df)
|
| 83 |
+
|
| 84 |
+
# Add buttons for each row in the DataFrame
|
| 85 |
+
for index, row in df.iterrows():
|
| 86 |
+
col1, col2 = st.columns([4, 1])
|
| 87 |
+
with col1:
|
| 88 |
+
st.write(row['filename'])
|
| 89 |
+
|
| 90 |
+
with col2:
|
| 91 |
+
# Button to view details of each row
|
| 92 |
+
button_key = f"view_{index}"
|
| 93 |
+
if st.button("See details", key=button_key):
|
| 94 |
+
# Update the session state with the selected file details
|
| 95 |
+
st.session_state.selected_file = row['text']
|
| 96 |
+
#st.session_state.selected_text = row['text']
|
| 97 |
+
|
| 98 |
+
# Clear existing content on button click
|
| 99 |
+
st.rerun()
|
| 100 |
+
|
| 101 |
+
|
| 102 |
# Helper function to extract text from PDF
|
| 103 |
def extract_text_from_pdf(uploaded_file, start_page, end_page):
|
| 104 |
if uploaded_file is None:
|