Spaces:
Sleeping
Sleeping
File size: 1,719 Bytes
aefac4f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "api"))
from app.services.ragbot import RagBotService
def test_format_response_uses_synthesizer_payload():
service = RagBotService()
workflow_result = {
"final_response": {
"biomarker_flags": [
{
"name": "Glucose",
"value": 120,
"unit": "mg/dL",
"status": "HIGH",
"reference_range": "70-100 mg/dL",
"warning": None
}
],
"safety_alerts": [],
"key_drivers": [],
"disease_explanation": {
"pathophysiology": "",
"citations": [],
"retrieved_chunks": None
},
"recommendations": {
"immediate_actions": [],
"lifestyle_changes": [],
"monitoring": []
},
"confidence_assessment": {
"prediction_reliability": "LOW",
"evidence_strength": "WEAK",
"limitations": []
},
"patient_summary": {"narrative": ""}
},
"biomarker_flags": [],
"safety_alerts": []
}
response = service._format_response(
request_id="req_test",
workflow_result=workflow_result,
input_biomarkers={"Glucose": 120},
extracted_biomarkers=None,
patient_context={},
model_prediction={"disease": "Diabetes", "confidence": 0.6, "probabilities": {}},
processing_time_ms=10.0
)
assert response.analysis.biomarker_flags[0].name == "Glucose"
|