Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -260,24 +260,41 @@ if research_button and topic:
|
|
260 |
with st.status("π Gathering and analyzing sources...") as status:
|
261 |
def fetch_all_sources():
|
262 |
sources = []
|
263 |
-
|
264 |
-
#
|
265 |
if source_type in ["Web Only", "Hybrid"]:
|
266 |
-
# Check if
|
267 |
-
if custom_domains.strip().startswith("http"):
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
sources += get_sources(topic, custom_domains)
|
273 |
-
|
274 |
-
|
|
|
|
|
275 |
if source_type in ["Academic Only", "Hybrid"]:
|
276 |
sources += get_arxiv_papers(topic)
|
277 |
sources += get_semantic_papers(topic)
|
278 |
-
|
279 |
return sources
|
280 |
|
|
|
281 |
merged = merge_duplicates(all_sources)
|
282 |
merged = sort_sources_chronologically(merged)
|
283 |
|
|
|
260 |
with st.status("π Gathering and analyzing sources...") as status:
|
261 |
def fetch_all_sources():
|
262 |
sources = []
|
263 |
+
|
264 |
+
# --- Web / Hybrid Sources ---
|
265 |
if source_type in ["Web Only", "Hybrid"]:
|
266 |
+
# Check if user gave a full URL
|
267 |
+
if custom_domains.strip().lower().startswith("http"):
|
268 |
+
custom_url = custom_domains.strip()
|
269 |
+
try:
|
270 |
+
response = tavily.search(query=custom_url, search_depth="advanced", max_results=1)
|
271 |
+
if response and "results" in response and response["results"]:
|
272 |
+
result = response["results"][0]
|
273 |
+
sources.append({
|
274 |
+
"title": result.get("title", "Untitled Web Page"),
|
275 |
+
"url": result.get("url", custom_url),
|
276 |
+
"snippet": result.get("content", ""),
|
277 |
+
"image_url": result.get("image_url"),
|
278 |
+
"source": "web",
|
279 |
+
"year": extract_year_from_text(result.get("content", ""))
|
280 |
+
})
|
281 |
+
except Exception as e:
|
282 |
+
print(f"β Failed to load direct URL: {e}")
|
283 |
+
|
284 |
+
# Otherwise treat it as domain(s)
|
285 |
+
elif custom_domains.strip():
|
286 |
sources += get_sources(topic, custom_domains)
|
287 |
+
else:
|
288 |
+
sources += get_sources(topic)
|
289 |
+
|
290 |
+
# --- Academic Sources ---
|
291 |
if source_type in ["Academic Only", "Hybrid"]:
|
292 |
sources += get_arxiv_papers(topic)
|
293 |
sources += get_semantic_papers(topic)
|
294 |
+
|
295 |
return sources
|
296 |
|
297 |
+
|
298 |
merged = merge_duplicates(all_sources)
|
299 |
merged = sort_sources_chronologically(merged)
|
300 |
|