Spaces:
Running
Running
| """Explanation agent.""" | |
| from __future__ import annotations | |
| from app.common.types import PolyGuardAction, PolyGuardState | |
| class ExplainerAgent: | |
| name = "ExplainerAgent" | |
| def run(self, state: PolyGuardState, action: PolyGuardAction, critic_report: dict) -> dict: | |
| return { | |
| "explanation": ( | |
| f"Action {action.action_type.value} selected for mode {action.mode.value}. " | |
| f"Burden score={state.burden_score:.3f}, meds={len(state.patient.medications)}. " | |
| f"Critic legal={critic_report.get('legal', False)}." | |
| ), | |
| "grounded_facts": { | |
| "burden_score": state.burden_score, | |
| "polypharmacy_count": len(state.patient.medications), | |
| }, | |
| } | |