Spaces:
Sleeping
Sleeping
| """AutoRiskScoreEngine - IFRS-Ready Underwriting | |
| Built using BDR Agent Factory v1 | |
| """ | |
| import gradio as gr | |
| from agents.risk_agent import RiskCalculationAgent | |
| from agents.ifrs_agent import IFRSTaggingAgent | |
| class AutoRiskScoreEngine: | |
| def __init__(self): | |
| self.risk_agent = RiskCalculationAgent() | |
| self.ifrs_agent = IFRSTaggingAgent() | |
| def score_risk(self, policy_id: str, coverage_amount: float, loss_history: int): | |
| policy_data = {"policy_id": policy_id, "coverage_amount": coverage_amount, "loss_history": loss_history} | |
| risk_results = self.risk_agent.process(policy_data) | |
| ifrs_results = self.ifrs_agent.process(risk_results) | |
| score_text = f"""**Risk Score:** {risk_results['risk_score']:.1f}/100 | |
| **Risk Band:** {risk_results['risk_band'].upper()} | |
| **Confidence:** {risk_results['confidence']:.1%}""" | |
| justification_text = f"""**Justification:** | |
| {risk_results['justification']} | |
| **IFRS Classification:** | |
| Reserve Category: {ifrs_results['reserve_category']} | |
| Compliance Ready: {'β' if ifrs_results['compliance_ready'] else 'β'}""" | |
| ifrs_text = f"""**IFRS Tags:** | |
| {chr(10).join('- ' + tag for tag in ifrs_results['ifrs_tags'])} | |
| **Audit Trail:** | |
| - Risk Calculation Agent: β | |
| - IFRS Tagging Agent: β | |
| """ | |
| return score_text, justification_text, ifrs_text | |
| app = AutoRiskScoreEngine() | |
| with gr.Blocks(title="AutoRiskScoreEngine", theme=gr.themes.Soft()) as demo: | |
| gr.Markdown(""" | |
| # βοΈ AutoRiskScoreEngine | |
| ## IFRS-Ready Underwriting Risk Scoring | |
| **IFRS17 compliant | Automated triage | Risk segmentation** | |
| *Built using [BDR Agent Factory v1](https://huggingface.co/spaces/bdr-ai-org/BDR-Agent-Factory)* | |
| """) | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Markdown("### π Policy Information") | |
| policy_id = gr.Textbox(label="Policy ID", value="POL-2024-001") | |
| coverage_amount = gr.Number(label="Coverage Amount ($)", value=50000.00) | |
| loss_history = gr.Slider(label="Loss History Count", minimum=0, maximum=10, value=2, step=1) | |
| score_btn = gr.Button("βοΈ Calculate Risk Score", variant="primary", size="lg") | |
| with gr.Column(): | |
| gr.Markdown("### π― Risk Assessment") | |
| score_output = gr.Textbox(label="Risk Score", lines=3) | |
| justification_output = gr.Textbox(label="Justification", lines=5) | |
| ifrs_output = gr.Textbox(label="IFRS Compliance", lines=6) | |
| gr.Examples( | |
| examples=[ | |
| ["POL-2024-001", 50000.00, 2], | |
| ["POL-2024-002", 100000.00, 5], | |
| ["POL-2024-003", 25000.00, 0], | |
| ], | |
| inputs=[policy_id, coverage_amount, loss_history] | |
| ) | |
| score_btn.click( | |
| fn=app.score_risk, | |
| inputs=[policy_id, coverage_amount, loss_history], | |
| outputs=[score_output, justification_output, ifrs_output] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |