Spaces:
Sleeping
Sleeping
# ------------------ Right Column: Structured Summary + FAQ (with Buttons) ------------------ | |
with right: | |
st.subheader("π Summary & FAQ (from Structured Data)") | |
# Controls | |
col1, col2 = st.columns(2) | |
show_summary = col1.button("π Load Summary") | |
show_faq = col2.button("β Load FAQ") | |
summary_text = "Click the button to load summary." | |
faq_list = [] | |
if st.session_state.image_url: | |
match = re.search(r'/(\d{3})\.png', st.session_state.image_url) | |
if match: | |
page_number = int(match.group(1)) | |
page_entry = next((entry for entry in structured_data if entry.get("page_number") == page_number), None) | |
if page_entry: | |
if show_summary: | |
summary_text = page_entry.get("summary", "No summary available.") | |
if show_faq: | |
faq_list = page_entry.get("faqs", []) or page_entry.get("questions", []) | |
# Display Summary | |
if show_summary: | |
st.subheader("π Summary") | |
st.markdown(summary_text) | |
# Display FAQs | |
if show_faq: | |
st.subheader("β Auto-Generated FAQ") | |
if faq_list: | |
for faq in faq_list: | |
if isinstance(faq, dict): | |
st.markdown(f"**Q:** {faq.get('question', '')}\n\n**A:** {faq.get('answer', '')}") | |
else: | |
st.markdown(f"**Q:** {faq}") | |
else: | |
st.info("No FAQs available for this page.") | |