Spaces:
Runtime error
Runtime error
fix 2
Browse files
crew.py
CHANGED
|
@@ -325,29 +325,19 @@ def gather_news_doctor(count: int = 5) -> dict:
|
|
| 325 |
Gathers recent dementia news articles which are relevant doctors. Returns structured dict.
|
| 326 |
"""
|
| 327 |
from webscraper import search_dementia_news, scrape_article_content
|
| 328 |
-
print(f"[DEBUG] Searching for {count} doctor articles...") # ← HF logs will show this
|
| 329 |
articles = search_dementia_news(audience="doctor", max_results=min(count, 10))
|
| 330 |
-
print(f"[DEBUG] Found {len(articles)} raw results") # ← check if 0
|
| 331 |
clean_articles = []
|
| 332 |
-
for
|
| 333 |
-
if "error" in art:
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
|
|
|
| 341 |
continue
|
| 342 |
-
clean_articles.append({
|
| 343 |
-
"title": art["title"],
|
| 344 |
-
"url": art["url"],
|
| 345 |
-
"content": content[:3000]
|
| 346 |
-
})
|
| 347 |
-
except Exception as e:
|
| 348 |
-
print(f"[EXC] Scraping failed for {art['url']}: {e}")
|
| 349 |
-
continue
|
| 350 |
-
print(f"[DEBUG] Returning {len(clean_articles)} clean articles")
|
| 351 |
return {"articles": clean_articles}
|
| 352 |
|
| 353 |
# Load 2 different llms for different purposes.
|
|
@@ -379,9 +369,7 @@ patient_news = Agent(
|
|
| 379 |
backstory="You find and share clear, trustworthy news about dementia—like new treatments, daily care tips, and support resources—written for patients and caregivers.",
|
| 380 |
verbose=True,
|
| 381 |
llm=llm_news,
|
| 382 |
-
tools=[gather_news_patient]
|
| 383 |
-
function_calling=True,
|
| 384 |
-
tool_choice="required"
|
| 385 |
)
|
| 386 |
|
| 387 |
doctor_news = Agent(
|
|
@@ -390,9 +378,7 @@ doctor_news = Agent(
|
|
| 390 |
backstory="You find and summarize the latest clinical studies, guidelines, and expert insights on dementia—focused on diagnosis, treatment, and research for healthcare providers.",
|
| 391 |
verbose=True,
|
| 392 |
llm=llm_news,
|
| 393 |
-
tools=[gather_news_doctor]
|
| 394 |
-
function_calling=True,
|
| 395 |
-
tool_choice="required"
|
| 396 |
)
|
| 397 |
|
| 398 |
# Define tasks for agents
|
|
|
|
| 325 |
Gathers recent dementia news articles which are relevant doctors. Returns structured dict.
|
| 326 |
"""
|
| 327 |
from webscraper import search_dementia_news, scrape_article_content
|
|
|
|
| 328 |
articles = search_dementia_news(audience="doctor", max_results=min(count, 10))
|
|
|
|
| 329 |
clean_articles = []
|
| 330 |
+
for art in articles:
|
| 331 |
+
if "error" not in art:
|
| 332 |
+
try:
|
| 333 |
+
content = scrape_article_content(art["url"])
|
| 334 |
+
clean_articles.append({
|
| 335 |
+
"title": art["title"],
|
| 336 |
+
"url": art["url"],
|
| 337 |
+
"content": content[:3000]
|
| 338 |
+
})
|
| 339 |
+
except Exception:
|
| 340 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
return {"articles": clean_articles}
|
| 342 |
|
| 343 |
# Load 2 different llms for different purposes.
|
|
|
|
| 369 |
backstory="You find and share clear, trustworthy news about dementia—like new treatments, daily care tips, and support resources—written for patients and caregivers.",
|
| 370 |
verbose=True,
|
| 371 |
llm=llm_news,
|
| 372 |
+
tools=[gather_news_patient]
|
|
|
|
|
|
|
| 373 |
)
|
| 374 |
|
| 375 |
doctor_news = Agent(
|
|
|
|
| 378 |
backstory="You find and summarize the latest clinical studies, guidelines, and expert insights on dementia—focused on diagnosis, treatment, and research for healthcare providers.",
|
| 379 |
verbose=True,
|
| 380 |
llm=llm_news,
|
| 381 |
+
tools=[gather_news_doctor]
|
|
|
|
|
|
|
| 382 |
)
|
| 383 |
|
| 384 |
# Define tasks for agents
|