Bader Alabddan commited on
Commit
3f61ff7
Β·
1 Parent(s): 9183615

Complete AutoRiskScoreEngine vertical

Browse files
agents/ifrs_agent.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """IFRS Tagging Agent"""
2
+ from typing import Dict, Any
3
+
4
+ class IFRSTaggingAgent:
5
+ def __init__(self):
6
+ self.name = "IFRSTaggingAgent"
7
+
8
+ def process(self, risk_results: Dict[str, Any]) -> Dict[str, Any]:
9
+ risk_band = risk_results.get("risk_band", "low")
10
+
11
+ ifrs_tags = ["IFRS17_COMPLIANT"]
12
+ if risk_band == "high":
13
+ ifrs_tags.append("HIGH_RISK_RESERVE")
14
+ elif risk_band == "medium":
15
+ ifrs_tags.append("MEDIUM_RISK_RESERVE")
16
+ else:
17
+ ifrs_tags.append("LOW_RISK_RESERVE")
18
+
19
+ return {
20
+ "ifrs_tags": ifrs_tags,
21
+ "reserve_category": f"{risk_band}_risk",
22
+ "compliance_ready": True
23
+ }
24
+
25
+ def get_trace(self) -> Dict[str, Any]:
26
+ return {"agent": self.name, "status": "completed"}
agents/risk_agent.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Risk Calculation Agent"""
2
+ from typing import Dict, Any
3
+
4
+ class RiskCalculationAgent:
5
+ def __init__(self):
6
+ self.name = "RiskCalculationAgent"
7
+
8
+ def process(self, policy_data: Dict[str, Any]) -> Dict[str, Any]:
9
+ loss_history = policy_data.get("loss_history", 0)
10
+ coverage_amount = policy_data.get("coverage_amount", 0)
11
+
12
+ risk_score = min((loss_history * 10) + (coverage_amount / 10000), 100)
13
+
14
+ if risk_score >= 70:
15
+ risk_band = "high"
16
+ elif risk_score >= 40:
17
+ risk_band = "medium"
18
+ else:
19
+ risk_band = "low"
20
+
21
+ return {
22
+ "risk_score": risk_score,
23
+ "risk_band": risk_band,
24
+ "justification": f"Based on loss history and coverage amount",
25
+ "confidence": 0.87
26
+ }
27
+
28
+ def get_trace(self) -> Dict[str, Any]:
29
+ return {"agent": self.name, "status": "completed"}
app.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """AutoRiskScoreEngine - IFRS-Ready Underwriting
2
+
3
+ Built using BDR Agent Factory v1
4
+ """
5
+
6
+ import gradio as gr
7
+ from agents.risk_agent import RiskCalculationAgent
8
+ from agents.ifrs_agent import IFRSTaggingAgent
9
+
10
+ class AutoRiskScoreEngine:
11
+ def __init__(self):
12
+ self.risk_agent = RiskCalculationAgent()
13
+ self.ifrs_agent = IFRSTaggingAgent()
14
+
15
+ def score_risk(self, policy_id: str, coverage_amount: float, loss_history: int):
16
+ policy_data = {"policy_id": policy_id, "coverage_amount": coverage_amount, "loss_history": loss_history}
17
+
18
+ risk_results = self.risk_agent.process(policy_data)
19
+ ifrs_results = self.ifrs_agent.process(risk_results)
20
+
21
+ score_text = f"""**Risk Score:** {risk_results['risk_score']:.1f}/100
22
+ **Risk Band:** {risk_results['risk_band'].upper()}
23
+ **Confidence:** {risk_results['confidence']:.1%}"""
24
+
25
+ justification_text = f"""**Justification:**
26
+ {risk_results['justification']}
27
+
28
+ **IFRS Classification:**
29
+ Reserve Category: {ifrs_results['reserve_category']}
30
+ Compliance Ready: {'βœ“' if ifrs_results['compliance_ready'] else 'βœ—'}"""
31
+
32
+ ifrs_text = f"""**IFRS Tags:**
33
+ {chr(10).join('- ' + tag for tag in ifrs_results['ifrs_tags'])}
34
+
35
+ **Audit Trail:**
36
+ - Risk Calculation Agent: βœ“
37
+ - IFRS Tagging Agent: βœ“
38
+ """
39
+
40
+ return score_text, justification_text, ifrs_text
41
+
42
+ app = AutoRiskScoreEngine()
43
+
44
+ with gr.Blocks(title="AutoRiskScoreEngine", theme=gr.themes.Soft()) as demo:
45
+ gr.Markdown("""
46
+ # βš–οΈ AutoRiskScoreEngine
47
+ ## IFRS-Ready Underwriting Risk Scoring
48
+
49
+ **IFRS17 compliant | Automated triage | Risk segmentation**
50
+
51
+ *Built using [BDR Agent Factory v1](https://huggingface.co/spaces/bdr-ai-org/BDR-Agent-Factory)*
52
+ """)
53
+
54
+ with gr.Row():
55
+ with gr.Column():
56
+ gr.Markdown("### πŸ“‹ Policy Information")
57
+ policy_id = gr.Textbox(label="Policy ID", value="POL-2024-001")
58
+ coverage_amount = gr.Number(label="Coverage Amount ($)", value=50000.00)
59
+ loss_history = gr.Slider(label="Loss History Count", minimum=0, maximum=10, value=2, step=1)
60
+ score_btn = gr.Button("βš–οΈ Calculate Risk Score", variant="primary", size="lg")
61
+
62
+ with gr.Column():
63
+ gr.Markdown("### 🎯 Risk Assessment")
64
+ score_output = gr.Textbox(label="Risk Score", lines=3)
65
+ justification_output = gr.Textbox(label="Justification", lines=5)
66
+ ifrs_output = gr.Textbox(label="IFRS Compliance", lines=6)
67
+
68
+ gr.Examples(
69
+ examples=[
70
+ ["POL-2024-001", 50000.00, 2],
71
+ ["POL-2024-002", 100000.00, 5],
72
+ ["POL-2024-003", 25000.00, 0],
73
+ ],
74
+ inputs=[policy_id, coverage_amount, loss_history]
75
+ )
76
+
77
+ score_btn.click(
78
+ fn=app.score_risk,
79
+ inputs=[policy_id, coverage_amount, loss_history],
80
+ outputs=[score_output, justification_output, ifrs_output]
81
+ )
82
+
83
+ if __name__ == "__main__":
84
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio>=4.0.0\n
vercept/vercept_mvp.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "project_name": "AutoRiskScoreEngine",
3
+ "phase": "MVP",
4
+ "agents": ["RiskCalculationAgent", "IFRSTaggingAgent"],
5
+ "features": {"ifrs_compliance": true, "risk_segmentation": true},
6
+ "metrics": {"segmentation_accuracy": ">=85%"},
7
+ "governance": {"ifrs_tagging": true}
8
+ }
vercept/vercept_poc.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "project_name": "AutoRiskScoreEngine",
3
+ "phase": "PoC",
4
+ "objective": "Validate IFRS-ready underwriting risk scoring",
5
+ "scope": {"policy_types": ["motor", "property"]},
6
+ "agents": [{"name": "RiskCalculationAgent", "responsibility": "Calculate risk scores"}],
7
+ "success_criteria": ["Risk segmentation accuracy >=75%"]
8
+ }
vercept/vercept_prd.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "project_name": "AutoRiskScoreEngine",
3
+ "phase": "PRD",
4
+ "business_kpis": ["IFRS-ready risk classification", "Automated underwriting triage"],
5
+ "compliance": ["IFRS17_READY", "AUDIT_TRAIL"],
6
+ "deployment": {"environment": "secure enterprise API"},
7
+ "scalability": {"batch_scoring": true}
8
+ }