Upload app.py
Browse files
app.py
CHANGED
|
@@ -222,14 +222,20 @@ def render_fema_block(fema_res: Dict[str, Any]) -> str:
|
|
| 222 |
return str(err)
|
| 223 |
cas_url = fema_res.get("cas_url")
|
| 224 |
name_url = fema_res.get("name_url")
|
|
|
|
| 225 |
alt = fema_res.get("alt_url")
|
| 226 |
-
|
|
|
|
| 227 |
return "FEMA link unavailable."
|
| 228 |
lines = ["A FEMA risk assessment for this chemical is available:"]
|
| 229 |
if cas_url:
|
| 230 |
lines.append(f"- [Search by CAS]({cas_url})")
|
| 231 |
if name_url:
|
| 232 |
lines.append(f"- [Search by Chemical Name]({name_url})")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
if alt:
|
| 234 |
lines.append(f"- [Generic FEMA search]({alt})")
|
| 235 |
return "\n".join(lines)
|
|
@@ -277,7 +283,9 @@ async def run_search(query: str) -> Dict[str, Any]:
|
|
| 277 |
cas = pub.get("resolved_cas") or q
|
| 278 |
|
| 279 |
# CTX is CAS-first (but we allow name too; resolver will try both)
|
| 280 |
-
|
|
|
|
|
|
|
| 281 |
ntp_task = ntp.search_technical_reports(cas, http, limit=8)
|
| 282 |
|
| 283 |
ctx_res, ntp_res = await asyncio.gather(ctx_task, ntp_task)
|
|
|
|
| 222 |
return str(err)
|
| 223 |
cas_url = fema_res.get("cas_url")
|
| 224 |
name_url = fema_res.get("name_url")
|
| 225 |
+
combo_url = fema_res.get("combo_url")
|
| 226 |
alt = fema_res.get("alt_url")
|
| 227 |
+
search_api = fema_res.get("search_api_url")
|
| 228 |
+
if not cas_url and not name_url and not combo_url and not alt and not search_api:
|
| 229 |
return "FEMA link unavailable."
|
| 230 |
lines = ["A FEMA risk assessment for this chemical is available:"]
|
| 231 |
if cas_url:
|
| 232 |
lines.append(f"- [Search by CAS]({cas_url})")
|
| 233 |
if name_url:
|
| 234 |
lines.append(f"- [Search by Chemical Name]({name_url})")
|
| 235 |
+
if combo_url:
|
| 236 |
+
lines.append(f"- [Search by CAS + Name]({combo_url})")
|
| 237 |
+
if search_api:
|
| 238 |
+
lines.append(f"- [Generic FEMA search (alt)]({search_api})")
|
| 239 |
if alt:
|
| 240 |
lines.append(f"- [Generic FEMA search]({alt})")
|
| 241 |
return "\n".join(lines)
|
|
|
|
| 283 |
cas = pub.get("resolved_cas") or q
|
| 284 |
|
| 285 |
# CTX is CAS-first (but we allow name too; resolver will try both)
|
| 286 |
+
pub_dtxsid = pub.get("dtxsid") if isinstance(pub, dict) else None
|
| 287 |
+
ctx_query = pub_dtxsid or q
|
| 288 |
+
ctx_task = ctx_src.fetch_ctx_genetox(ctx_query, http) if ctx_query else asyncio.sleep(0, result={"ok": False})
|
| 289 |
ntp_task = ntp.search_technical_reports(cas, http, limit=8)
|
| 290 |
|
| 291 |
ctx_res, ntp_res = await asyncio.gather(ctx_task, ntp_task)
|