Spaces:
Sleeping
Sleeping
File size: 2,984 Bytes
3f61ff7 |
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
"""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()
|