Ani14 commited on
Commit
c12e13c
·
verified ·
1 Parent(s): 68d14e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -11
app.py CHANGED
@@ -320,17 +320,25 @@ APA Citations:
320
  # Mind Map Generator (Visual)
321
  st.markdown("---")
322
  st.subheader("🧭 Visual Mind Map")
323
- if st.button("🗺 Generate Mind Map"):
324
- mindmap_prompt = [
325
- {"role": "system", "content": "You are a researcher who converts reports into Mermaid.js mind maps."},
326
- {"role": "user", "content": f"Create a mermaid mind map for this research:\n{full_output}"}
327
- ]
328
- mindmap_code = ""
329
- for chunk in call_llm(mindmap_prompt):
330
- mindmap_code += chunk
331
-
332
- mindmap_code = mindmap_code.replace("```mermaid", "").replace("```", "").strip()
333
- st.markdown(f"<div class='mermaid'>{mindmap_code}</div>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
334
 
335
  # Follow-up Q&A
336
  st.markdown("---")
 
320
  # Mind Map Generator (Visual)
321
  st.markdown("---")
322
  st.subheader("🧭 Visual Mind Map")
323
+
324
+ if "last_report" not in st.session_state or not st.session_state["last_report"].strip():
325
+ st.warning("⚠️ Please generate a report first.")
326
+ else:
327
+ if st.button("🗺 Generate Mind Map"):
328
+ mindmap_prompt = [
329
+ {"role": "system", "content": "You are a researcher who converts reports into mermaid mind maps."},
330
+ {"role": "user", "content": f"Create a mermaid.js mind map of the following:\n\n{st.session_state['last_report']}"}
331
+ ]
332
+ mindmap_code = ""
333
+ for chunk in call_llm(mindmap_prompt):
334
+ mindmap_code += chunk
335
+
336
+ # Remove wrapping markdown if exists
337
+ mindmap_code = mindmap_code.replace("```mermaid", "").replace("```", "").strip()
338
+
339
+ # Render mermaid directly
340
+ st.markdown(f"<div class='mermaid'>{mindmap_code}</div>", unsafe_allow_html=True)
341
+
342
 
343
  # Follow-up Q&A
344
  st.markdown("---")