Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -149,26 +149,26 @@ st.set_page_config("Deep Research Bot", layout="wide")
|
|
| 149 |
|
| 150 |
with st.sidebar:
|
| 151 |
st.title(" Deep Research Assistant")
|
| 152 |
-
topic = st.text_input("
|
| 153 |
-
report_type = st.selectbox("
|
| 154 |
"Summary - Short and fast (~2 min)",
|
| 155 |
"Detailed Report (~5 min)",
|
| 156 |
"Thorough Academic Research (~10 min)"
|
| 157 |
])
|
| 158 |
-
tone = st.selectbox("
|
| 159 |
"Objective - Impartial and unbiased presentation of facts and findings",
|
| 160 |
"Persuasive - Advocating a specific point of view",
|
| 161 |
"Narrative - Storytelling tone for layperson readers"
|
| 162 |
])
|
| 163 |
-
source_type = st.selectbox("
|
| 164 |
-
custom_domains = st.text_input("
|
| 165 |
-
research_button = st.button("
|
| 166 |
|
| 167 |
-
st.title("
|
| 168 |
|
| 169 |
if research_button and topic:
|
| 170 |
try:
|
| 171 |
-
with st.status("
|
| 172 |
st.info("Fetching from sources...")
|
| 173 |
|
| 174 |
all_sources = []
|
|
@@ -193,7 +193,7 @@ if research_button and topic:
|
|
| 193 |
combined_text += f"- [{m['title']}]({m['url']})\n> {m.get('snippet', m.get('summary', ''))[:300]}...\n\n"
|
| 194 |
citations.append(generate_apa_citation(m['title'], m['url'], m['source']))
|
| 195 |
|
| 196 |
-
with st.spinner("
|
| 197 |
prompt = f"""
|
| 198 |
# Research Topic: {topic}
|
| 199 |
Tone: {tone}
|
|
@@ -209,19 +209,19 @@ Write the report in academic markdown with paragraphs (use bullet points only wh
|
|
| 209 |
"""
|
| 210 |
final_output = call_llm([{"role": "user", "content": prompt}])
|
| 211 |
|
| 212 |
-
st.markdown(f"
|
| 213 |
st.markdown(final_output, unsafe_allow_html=True)
|
| 214 |
|
| 215 |
if report_type == "Thorough Academic Research (~10 min)":
|
| 216 |
image_url = fetch_related_image(topic)
|
| 217 |
st.image(image_url, caption="Related Image", use_column_width=True)
|
| 218 |
|
| 219 |
-
st.markdown("
|
| 220 |
for cite in citations:
|
| 221 |
st.markdown(f"- {cite}")
|
| 222 |
|
| 223 |
if report_type == "Thorough Academic Research (~10 min)":
|
| 224 |
-
with st.spinner("
|
| 225 |
pdf_file = generate_pdf(final_output)
|
| 226 |
latex_file = generate_latex(final_output)
|
| 227 |
st.markdown(generate_download_button(pdf_file, "Research_Report.pdf", "application/pdf"), unsafe_allow_html=True)
|
|
@@ -229,11 +229,11 @@ Write the report in academic markdown with paragraphs (use bullet points only wh
|
|
| 229 |
|
| 230 |
overlaps = check_plagiarism(final_output, topic)
|
| 231 |
if overlaps:
|
| 232 |
-
st.warning("
|
| 233 |
for hit in overlaps:
|
| 234 |
st.markdown(f"- [{hit['title']}]({hit['url']})")
|
| 235 |
else:
|
| 236 |
-
st.success("
|
| 237 |
|
| 238 |
except Exception as e:
|
| 239 |
st.error(f"Error: {e}")
|
|
|
|
| 149 |
|
| 150 |
with st.sidebar:
|
| 151 |
st.title(" Deep Research Assistant")
|
| 152 |
+
topic = st.text_input(" Topic to research")
|
| 153 |
+
report_type = st.selectbox(" Type of report", [
|
| 154 |
"Summary - Short and fast (~2 min)",
|
| 155 |
"Detailed Report (~5 min)",
|
| 156 |
"Thorough Academic Research (~10 min)"
|
| 157 |
])
|
| 158 |
+
tone = st.selectbox(" Tone of the report", [
|
| 159 |
"Objective - Impartial and unbiased presentation of facts and findings",
|
| 160 |
"Persuasive - Advocating a specific point of view",
|
| 161 |
"Narrative - Storytelling tone for layperson readers"
|
| 162 |
])
|
| 163 |
+
source_type = st.selectbox(" Sources to include", ["Web Only", "Academic Only", "Hybrid"])
|
| 164 |
+
custom_domains = st.text_input(" Query Domains (Optional)", placeholder="techcrunch.com, forbes.com")
|
| 165 |
+
research_button = st.button(" Start Research")
|
| 166 |
|
| 167 |
+
st.title(" Research Output")
|
| 168 |
|
| 169 |
if research_button and topic:
|
| 170 |
try:
|
| 171 |
+
with st.status(" Gathering data..."):
|
| 172 |
st.info("Fetching from sources...")
|
| 173 |
|
| 174 |
all_sources = []
|
|
|
|
| 193 |
combined_text += f"- [{m['title']}]({m['url']})\n> {m.get('snippet', m.get('summary', ''))[:300]}...\n\n"
|
| 194 |
citations.append(generate_apa_citation(m['title'], m['url'], m['source']))
|
| 195 |
|
| 196 |
+
with st.spinner(" Synthesizing report..."):
|
| 197 |
prompt = f"""
|
| 198 |
# Research Topic: {topic}
|
| 199 |
Tone: {tone}
|
|
|
|
| 209 |
"""
|
| 210 |
final_output = call_llm([{"role": "user", "content": prompt}])
|
| 211 |
|
| 212 |
+
st.markdown(f" {report_type}")
|
| 213 |
st.markdown(final_output, unsafe_allow_html=True)
|
| 214 |
|
| 215 |
if report_type == "Thorough Academic Research (~10 min)":
|
| 216 |
image_url = fetch_related_image(topic)
|
| 217 |
st.image(image_url, caption="Related Image", use_column_width=True)
|
| 218 |
|
| 219 |
+
st.markdown(" Citations (APA Format)")
|
| 220 |
for cite in citations:
|
| 221 |
st.markdown(f"- {cite}")
|
| 222 |
|
| 223 |
if report_type == "Thorough Academic Research (~10 min)":
|
| 224 |
+
with st.spinner(" Preparing PDF and LaTeX..."):
|
| 225 |
pdf_file = generate_pdf(final_output)
|
| 226 |
latex_file = generate_latex(final_output)
|
| 227 |
st.markdown(generate_download_button(pdf_file, "Research_Report.pdf", "application/pdf"), unsafe_allow_html=True)
|
|
|
|
| 229 |
|
| 230 |
overlaps = check_plagiarism(final_output, topic)
|
| 231 |
if overlaps:
|
| 232 |
+
st.warning(" Potential overlaps detected:")
|
| 233 |
for hit in overlaps:
|
| 234 |
st.markdown(f"- [{hit['title']}]({hit['url']})")
|
| 235 |
else:
|
| 236 |
+
st.success(" No major overlaps found.")
|
| 237 |
|
| 238 |
except Exception as e:
|
| 239 |
st.error(f"Error: {e}")
|