Ani14 commited on
Commit
99bfafd
Β·
verified Β·
1 Parent(s): 377f206

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -28
app.py CHANGED
@@ -190,12 +190,11 @@ def generate_download_button(file, label, mime_type):
190
  # --- Streamlit UI ---
191
  st.set_page_config("Deep Research Assistant", layout="centered")
192
  # 🧠 Initialize session state
193
- if "last_report" not in st.session_state:
194
- st.session_state.last_report = ""
195
- if "mindmap_triggered" not in st.session_state:
196
- st.session_state.mindmap_triggered = False
197
- if "followup_question" not in st.session_state:
198
- st.session_state.followup_question = ""
199
 
200
  # Mermaid.js for mind map rendering
201
  st.markdown("""
@@ -304,33 +303,37 @@ APA Citations:
304
  st.success("βœ… No major overlaps found.")
305
 
306
  st.subheader("πŸ’¬ Ask a Follow-Up")
307
- follow_input = st.text_input("Ask a question about the report:")
308
- if st.button("πŸ”„ Submit Follow-Up") and follow_input:
309
- st.session_state.followup_question = follow_input
310
-
311
- if st.session_state.followup_question and st.session_state.last_report:
312
- follow_prompt = [
313
- {"role": "system", "content": "You are a helpful academic assistant."},
314
- {"role": "user", "content": st.session_state.last_report},
315
- {"role": "user", "content": st.session_state.followup_question}
316
- ]
317
- follow_output = ""
318
- follow_box = st.empty()
319
- for chunk in call_llm(follow_prompt):
320
- follow_output += chunk
321
- follow_box.markdown(follow_output, unsafe_allow_html=True)
322
 
323
- st.session_state.followup_question = ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
 
325
- # πŸ“Œ Methodology Recommender
326
  st.subheader("πŸ§ͺ Methodology Recommender")
327
-
328
  if st.button("🧠 Suggest Research Methodologies"):
329
- if st.session_state.last_report:
330
  try:
331
  method_prompt = [
332
- {"role": "system", "content": "You are a research advisor. Based on the report, suggest appropriate research methodologies or experimental frameworks (qualitative, quantitative, statistical models, AI/ML techniques, etc.). Provide concise and specific recommendations in bullet points."},
333
- {"role": "user", "content": st.session_state.last_report}
334
  ]
335
  method_output = ""
336
  method_box = st.empty()
@@ -340,7 +343,8 @@ APA Citations:
340
  except Exception as e:
341
  st.error(f"❌ Methodology suggestion failed: {e}")
342
  else:
343
- st.warning("⚠️ Generate the research report first to get methodology suggestions.")
 
344
 
345
 
346
  except Exception as e:
 
190
  # --- Streamlit UI ---
191
  st.set_page_config("Deep Research Assistant", layout="centered")
192
  # 🧠 Initialize session state
193
+ if "follow_up_input" not in st.session_state:
194
+ st.session_state["follow_up_input"] = ""
195
+ if "methodology_recommended" not in st.session_state:
196
+ st.session_state["methodology_recommended"] = False
197
+
 
198
 
199
  # Mermaid.js for mind map rendering
200
  st.markdown("""
 
303
  st.success("βœ… No major overlaps found.")
304
 
305
  st.subheader("πŸ’¬ Ask a Follow-Up")
306
+
307
+ st.session_state["follow_up_input"] = st.text_input(
308
+ "Ask a question about the report:", value=st.session_state["follow_up_input"]
309
+ )
 
 
 
 
 
 
 
 
 
 
 
310
 
311
+ if st.button("πŸ”„ Submit Follow-Up") and st.session_state["follow_up_input"]:
312
+ if st.session_state["last_report"]:
313
+ try:
314
+ follow_prompt = [
315
+ {"role": "system", "content": "You are a helpful academic assistant."},
316
+ {"role": "user", "content": st.session_state["last_report"]},
317
+ {"role": "user", "content": st.session_state["follow_up_input"]}
318
+ ]
319
+ follow_output = ""
320
+ follow_box = st.empty()
321
+ for chunk in call_llm(follow_prompt):
322
+ follow_output += chunk
323
+ follow_box.markdown(follow_output, unsafe_allow_html=True)
324
+ except Exception as e:
325
+ st.error(f"❌ Follow-up failed: {e}")
326
+ else:
327
+ st.warning("⚠️ Generate the research report first.")
328
 
 
329
  st.subheader("πŸ§ͺ Methodology Recommender")
330
+
331
  if st.button("🧠 Suggest Research Methodologies"):
332
+ if st.session_state["last_report"]:
333
  try:
334
  method_prompt = [
335
+ {"role": "system", "content": "You are a research advisor. Based on the following research report, suggest suitable research methodologies (quantitative, qualitative, ML/AI techniques, etc.). Be concise and give bullet-point suggestions."},
336
+ {"role": "user", "content": st.session_state["last_report"]}
337
  ]
338
  method_output = ""
339
  method_box = st.empty()
 
343
  except Exception as e:
344
  st.error(f"❌ Methodology suggestion failed: {e}")
345
  else:
346
+ st.warning("⚠️ Generate the research report first.")
347
+
348
 
349
 
350
  except Exception as e: