Spaces:
Runtime error
Runtime error
Upload agents/priority_router.py with huggingface_hub
Browse files- agents/priority_router.py +15 -7
agents/priority_router.py
CHANGED
|
@@ -315,19 +315,27 @@ Be conservative - err on the side of higher priority for concerning findings."""
|
|
| 315 |
"""Check for critical findings that require immediate communication."""
|
| 316 |
detected_critical = []
|
| 317 |
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
if critical in report_lower:
|
| 321 |
-
detected_critical.append(critical.replace("_", " ").title())
|
| 322 |
-
|
| 323 |
-
# Also check finding types
|
| 324 |
for finding in findings:
|
| 325 |
finding_type = finding.get("type", "").lower()
|
| 326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
name = finding_type.replace("_", " ").title()
|
| 328 |
if name not in detected_critical:
|
| 329 |
detected_critical.append(name)
|
| 330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
return detected_critical
|
| 332 |
|
| 333 |
def _determine_routing(self, priority_level: str, critical_findings: List[str]) -> Dict:
|
|
|
|
| 315 |
"""Check for critical findings that require immediate communication."""
|
| 316 |
detected_critical = []
|
| 317 |
|
| 318 |
+
# Only check actual findings from the analysis, not report text
|
| 319 |
+
# (Report text may contain "no pneumothorax" which would false-positive)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
for finding in findings:
|
| 321 |
finding_type = finding.get("type", "").lower()
|
| 322 |
+
severity = finding.get("severity", "").lower()
|
| 323 |
+
|
| 324 |
+
# Only flag as critical if it's actually a critical finding type
|
| 325 |
+
# AND has high/critical severity
|
| 326 |
+
if finding_type in self.CRITICAL_FINDINGS and severity in ["critical", "high", "moderate"]:
|
| 327 |
name = finding_type.replace("_", " ").title()
|
| 328 |
if name not in detected_critical:
|
| 329 |
detected_critical.append(name)
|
| 330 |
|
| 331 |
+
# Also check for specific high-severity findings
|
| 332 |
+
for finding in findings:
|
| 333 |
+
severity = finding.get("severity", "").lower()
|
| 334 |
+
if severity == "critical":
|
| 335 |
+
finding_type = finding.get("type", "Unknown").replace("_", " ").title()
|
| 336 |
+
if finding_type not in detected_critical:
|
| 337 |
+
detected_critical.append(f"{finding_type} (Critical)")
|
| 338 |
+
|
| 339 |
return detected_critical
|
| 340 |
|
| 341 |
def _determine_routing(self, priority_level: str, critical_findings: List[str]) -> Dict:
|