Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 "
|
| 194 |
-
st.session_state
|
| 195 |
-
if "
|
| 196 |
-
st.session_state
|
| 197 |
-
|
| 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 |
-
|
| 308 |
-
|
| 309 |
-
st.session_state
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
|
| 325 |
-
# π Methodology Recommender
|
| 326 |
st.subheader("π§ͺ Methodology Recommender")
|
| 327 |
-
|
| 328 |
if st.button("π§ Suggest Research Methodologies"):
|
| 329 |
-
if st.session_state
|
| 330 |
try:
|
| 331 |
method_prompt = [
|
| 332 |
-
{"role": "system", "content": "You are a research advisor. Based on the report, suggest
|
| 333 |
-
{"role": "user", "content": st.session_state
|
| 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
|
|
|
|
| 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:
|