hchevva commited on
Commit
ee87da6
·
verified ·
1 Parent(s): b1101f6

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
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
- if not url:
 
225
  return "FEMA link unavailable."
226
- return f"A FEMA risk assessment for this chemical is available:\n\n[{url}]({url})"
 
 
 
 
 
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(cas, http) if cas else asyncio.sleep(0, result={"ok": False})
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)