Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -320,17 +320,25 @@ APA Citations:
|
|
| 320 |
# Mind Map Generator (Visual)
|
| 321 |
st.markdown("---")
|
| 322 |
st.subheader("🧭 Visual Mind Map")
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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("---")
|