Upload app.py
Browse files
app.py
CHANGED
|
@@ -221,9 +221,15 @@ def render_fema_block(fema_res: Dict[str, Any]) -> str:
|
|
| 221 |
err = fema_res.get("error") if isinstance(fema_res, dict) else "FEMA link unavailable."
|
| 222 |
return str(err)
|
| 223 |
url = fema_res.get("url")
|
| 224 |
-
|
|
|
|
| 225 |
return "FEMA link unavailable."
|
| 226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
|
| 229 |
def render_cdc_block(cdc_res: Any) -> str:
|
|
@@ -268,7 +274,7 @@ async def run_search(query: str) -> Dict[str, Any]:
|
|
| 268 |
cas = pub.get("resolved_cas") or q
|
| 269 |
|
| 270 |
# CTX is CAS-first (but we allow name too; resolver will try both)
|
| 271 |
-
ctx_task = ctx_src.fetch_ctx_genetox(
|
| 272 |
ntp_task = ntp.search_technical_reports(cas, http, limit=8)
|
| 273 |
|
| 274 |
ctx_res, ntp_res = await asyncio.gather(ctx_task, ntp_task)
|
|
|
|
| 221 |
err = fema_res.get("error") if isinstance(fema_res, dict) else "FEMA link unavailable."
|
| 222 |
return str(err)
|
| 223 |
url = fema_res.get("url")
|
| 224 |
+
alt = fema_res.get("alt_url")
|
| 225 |
+
if not url and not alt:
|
| 226 |
return "FEMA link unavailable."
|
| 227 |
+
lines = ["A FEMA risk assessment for this chemical is available:"]
|
| 228 |
+
if url:
|
| 229 |
+
lines.append(f"- [Filtered FEMA search]({url})")
|
| 230 |
+
if alt:
|
| 231 |
+
lines.append(f"- [Generic FEMA search]({alt})")
|
| 232 |
+
return "\n".join(lines)
|
| 233 |
|
| 234 |
|
| 235 |
def render_cdc_block(cdc_res: Any) -> str:
|
|
|
|
| 274 |
cas = pub.get("resolved_cas") or q
|
| 275 |
|
| 276 |
# CTX is CAS-first (but we allow name too; resolver will try both)
|
| 277 |
+
ctx_task = ctx_src.fetch_ctx_genetox(q, http) if q else asyncio.sleep(0, result={"ok": False})
|
| 278 |
ntp_task = ntp.search_technical_reports(cas, http, limit=8)
|
| 279 |
|
| 280 |
ctx_res, ntp_res = await asyncio.gather(ctx_task, ntp_task)
|