Spaces:
Runtime error
Runtime error
Download src/backend/core/constants.py from HAK-Tech/ciro-backend: direct link, hf CLI and curl.
- Browser
- Download file 3.09 kB
-
https://huggingface.co/spaces/HAK-Tech/ciro-backend/resolve/main/src/backend/core/constants.py
- Command line
-
hf download hf://spaces/HAK-Tech/ciro-backend/src/backend/core/constants.py
-
curl -L -o constants.py https://huggingface.co/spaces/HAK-Tech/ciro-backend/resolve/main/src/backend/core/constants.py
3.09 kB
| """ | |
| Hard-coded constants for CIRO's deterministic decision logic. | |
| What lives here | |
| --------------- | |
| Constants that are NOT meant to be tuned per request or per environment β | |
| they encode product decisions about how CIRO classifies and responds to | |
| crises. Putting them in one module keeps risk-tiering, planning, and | |
| the UI in lockstep about which types map to which tier. | |
| What does NOT live here | |
| ----------------------- | |
| Environment-driven config (API keys, feature flags, ports) β that | |
| belongs in `core/config.py` (pydantic-settings). If a value is something | |
| ops would change, it goes there, not here. | |
| """ | |
| from __future__ import annotations | |
| # ββ Risk tiering ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # | |
| # These sets define the response path a crisis takes after detection: | |
| # | |
| # LOW_RISK_TYPES β automated response (reroute, alert), no humans | |
| # MEDIUM_HIGH_RISK_TYPES β requires crowd verification before any | |
| # emergency dispatch | |
| # | |
| # Crisis types not in either set are treated as MEDIUM by the classifier | |
| # (fail-safe default β never silently skip verification for an unknown | |
| # type). | |
| LOW_RISK_TYPES: frozenset[str] = frozenset({ | |
| "traffic_jam", | |
| "rainfall", | |
| "road_blockage", | |
| }) | |
| MEDIUM_HIGH_RISK_TYPES: frozenset[str] = frozenset({ | |
| "flood", | |
| "fire", | |
| "accident", | |
| "building_collapse", | |
| "infrastructure_failure", | |
| "infrastructure", # alias used by the detection taxonomy | |
| "heatwave", | |
| }) | |
| # Confidence threshold below which a high-risk crisis is downgraded to | |
| # medium. The intent: "we are not confident enough to skip crowd | |
| # verification, but we are confident enough to investigate further." | |
| # Hard-coded β not configurable per request, per the phase doc's | |
| # architectural constraint. | |
| CONFIDENCE_THRESHOLD: float = 0.6 | |
| # ββ NGO escalation ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # | |
| # Severity score (1-5, from SituationReport) at or above which a confirmed | |
| # crisis is escalated to registered NGOs. Hard-coded per the phase doc. | |
| NGO_ESCALATION_THRESHOLD: int = 3 | |
| # Maps crisis type to the NGO categories that are relevant for that type. | |
| # An NGO matches when it has at least one category from this list AND its | |
| # coverage_areas overlap with the crisis location. Any crisis type not in | |
| # this map is treated as requiring "disaster_relief" as a fallback. | |
| NGO_CRISIS_TYPE_MAP: dict[str, list[str]] = { | |
| "flood": ["disaster_relief", "rescue"], | |
| "fire": ["fire_rescue", "medical"], | |
| "accident": ["medical", "rescue"], | |
| "building_collapse": ["rescue", "disaster_relief", "medical"], | |
| "heatwave": ["medical", "community_welfare"], | |
| "infrastructure_failure": ["disaster_relief"], | |
| "infrastructure": ["disaster_relief"], # detection-agent alias | |
| } | |