Spaces:
Runtime error
Runtime error
Create run_tb_diagnostics_with_link.py
Browse files
run_tb_diagnostics_with_link.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from results_store import save_result
|
| 2 |
+
|
| 3 |
+
async def run_tb_diagnostics(self, image_path: str, audio_path: str, user_id: int) -> Dict[str, Any]:
|
| 4 |
+
"""
|
| 5 |
+
Only runs TB analysis if explicitly requested. Includes shareable result link.
|
| 6 |
+
"""
|
| 7 |
+
try:
|
| 8 |
+
result = await self.health_module.evaluate_tb_risk(image_path, audio_path, user_id)
|
| 9 |
+
|
| 10 |
+
# Save result and generate private link
|
| 11 |
+
filename = save_result(result)
|
| 12 |
+
shareable_link = f"https://huggingface.co/spaces/Raiff1982/codriao/blob/main/results/{filename}"
|
| 13 |
+
result["shareable_link"] = shareable_link
|
| 14 |
+
|
| 15 |
+
logger.info(f"TB Diagnostic Result stored as {filename}")
|
| 16 |
+
return result
|
| 17 |
+
|
| 18 |
+
except Exception as e:
|
| 19 |
+
logger.error(f"TB diagnostics failed: {e}")
|
| 20 |
+
return {
|
| 21 |
+
"tb_risk": "ERROR",
|
| 22 |
+
"error": str(e),
|
| 23 |
+
"image_analysis": {},
|
| 24 |
+
"audio_analysis": {},
|
| 25 |
+
"ethical_analysis": "Unable to complete TB diagnostic.",
|
| 26 |
+
"explanation": None,
|
| 27 |
+
"system_health": None,
|
| 28 |
+
"shareable_link": None
|
| 29 |
+
}
|