dil-banking 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dil_banking-1.0.0/MANIFEST.in +3 -0
- dil_banking-1.0.0/PKG-INFO +204 -0
- dil_banking-1.0.0/README.md +170 -0
- dil_banking-1.0.0/pyproject.toml +65 -0
- dil_banking-1.0.0/setup.cfg +4 -0
- dil_banking-1.0.0/src/dil/__init__.py +58 -0
- dil_banking-1.0.0/src/dil/core/engine.py +288 -0
- dil_banking-1.0.0/src/dil/core/loader.py +150 -0
- dil_banking-1.0.0/src/dil/core/models.py +146 -0
- dil_banking-1.0.0/src/dil/core/registry.py +83 -0
- dil_banking-1.0.0/src/dil/domains/__init__.py +1 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/concepts.json +756 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/dist/concepts.parquet +0 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/dist/dil.lock +11 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/dist/rules.parquet +0 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/dist/terminology.parquet +0 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/manifest.json +33 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/processes.json +167 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/relationships.json +110 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/rules/general.json +55 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/rules/india.json +265 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/sources/source_registry.json +137 -0
- dil_banking-1.0.0/src/dil/domains/banking/1.0.0/terminology.json +539 -0
- dil_banking-1.0.0/src/dil/intelligence/context_builder.py +108 -0
- dil_banking-1.0.0/src/dil/intelligence/extractor.py +95 -0
- dil_banking-1.0.0/src/dil/intelligence/matcher.py +116 -0
- dil_banking-1.0.0/src/dil/llm/__init__.py +15 -0
- dil_banking-1.0.0/src/dil/llm/base.py +11 -0
- dil_banking-1.0.0/src/dil/llm/providers.py +149 -0
- dil_banking-1.0.0/src/dil/roles/manager.py +67 -0
- dil_banking-1.0.0/src/dil/roles/predefined/compliance_officer.json +18 -0
- dil_banking-1.0.0/src/dil/roles/predefined/credit_analyst.json +19 -0
- dil_banking-1.0.0/src/dil/roles/predefined/loan_advisor.json +20 -0
- dil_banking-1.0.0/src/dil/rules/engine.py +114 -0
- dil_banking-1.0.0/src/dil/storage/__init__.py +4 -0
- dil_banking-1.0.0/src/dil/storage/engine.py +250 -0
- dil_banking-1.0.0/src/dil/storage/parquet_exporter.py +186 -0
- dil_banking-1.0.0/src/dil_banking.egg-info/PKG-INFO +204 -0
- dil_banking-1.0.0/src/dil_banking.egg-info/SOURCES.txt +44 -0
- dil_banking-1.0.0/src/dil_banking.egg-info/dependency_links.txt +1 -0
- dil_banking-1.0.0/src/dil_banking.egg-info/requires.txt +17 -0
- dil_banking-1.0.0/src/dil_banking.egg-info/top_level.txt +1 -0
- dil_banking-1.0.0/tests/test_benchmark_gate.py +59 -0
- dil_banking-1.0.0/tests/test_dil_banking.py +130 -0
- dil_banking-1.0.0/tests/test_phase2_codification.py +128 -0
- dil_banking-1.0.0/tests/test_storage_engine.py +92 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dil-banking
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Domain Intelligence Layer (DIL) for Banking - Enterprise domain reasoning, deterministic rules, and role-governed context for LLMs
|
|
5
|
+
Author-email: DIL Architecture Team <architecture@dil.ai>
|
|
6
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
7
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Provides-Extra: storage
|
|
22
|
+
Requires-Dist: pyarrow>=12.0.0; extra == "storage"
|
|
23
|
+
Provides-Extra: openai
|
|
24
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
25
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "openai"
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
28
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
30
|
+
Provides-Extra: all
|
|
31
|
+
Requires-Dist: pyarrow>=12.0.0; extra == "all"
|
|
32
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
33
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "all"
|
|
34
|
+
|
|
35
|
+
# Domain Intelligence Layer (DIL) — Banking
|
|
36
|
+
|
|
37
|
+
**DIL** is a reusable intelligence infrastructure for enterprise AI applications in banking. It ensures LLMs reason like accredited banking specialists by decoupling **domain knowledge, role boundaries, and deterministic rules** from application data and the underlying model.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🏛 Architecture Overview
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
+---------------------------------------+
|
|
45
|
+
| Application / Chatbot |
|
|
46
|
+
+---------------------------------------+
|
|
47
|
+
│
|
|
48
|
+
▼
|
|
49
|
+
+---------------------------------------+
|
|
50
|
+
| DIL Interface Layer (SDK) |
|
|
51
|
+
| • Agent configuration (Role, Rules) |
|
|
52
|
+
| • Query & customer data intake |
|
|
53
|
+
+---------------------------------------+
|
|
54
|
+
│
|
|
55
|
+
┌──────────────────────────────────┼──────────────────────────────────┐
|
|
56
|
+
▼ ▼ ▼
|
|
57
|
+
+-----------------------+ +-----------------------+ +-----------------------+
|
|
58
|
+
| Domain Intelligence | | Role Intelligence | | Deterministic Rules |
|
|
59
|
+
| • Terminology | | • Objectives | | • Code computations |
|
|
60
|
+
| • Concepts & aliases | | • Persona tone | | • Regulatory caps |
|
|
61
|
+
| • 1-hop ontology | | • Disclaimers | | • RBI / Global rules |
|
|
62
|
+
+-----------------------+ +-----------------------+ +-----------------------+
|
|
63
|
+
└──────────────────────────────────┬──────────────────────────────────┘
|
|
64
|
+
│
|
|
65
|
+
▼
|
|
66
|
+
+---------------------------------------+
|
|
67
|
+
| Audit-Ready Context Engine |
|
|
68
|
+
| Structures facts, rule verdicts, |
|
|
69
|
+
| and mandatory governance directives |
|
|
70
|
+
+---------------------------------------+
|
|
71
|
+
│
|
|
72
|
+
▼
|
|
73
|
+
+---------------------------------------+
|
|
74
|
+
| Any LLM (OpenAI, Claude, Local) |
|
|
75
|
+
| "Code decides; LLM explains" |
|
|
76
|
+
+---------------------------------------+
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 📂 Project Structure
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
dil_banking/
|
|
85
|
+
├── pyproject.toml # Packaging configuration
|
|
86
|
+
├── README.md # Documentation
|
|
87
|
+
├── src/
|
|
88
|
+
│ └── dil/
|
|
89
|
+
│ ├── __init__.py # Public API exports
|
|
90
|
+
│ ├── core/
|
|
91
|
+
│ │ ├── engine.py # DIL and Agent classes
|
|
92
|
+
│ │ ├── loader.py # PackLoader and LoadedPack
|
|
93
|
+
│ │ ├── models.py # Dataclasses (Manifest, Concepts, Rules, Context)
|
|
94
|
+
│ │ └── registry.py # DomainRegistry & pack version manager
|
|
95
|
+
│ ├── domains/
|
|
96
|
+
│ │ └── banking/
|
|
97
|
+
│ │ └── 1.0.0/ # Versioned Banking Knowledge Pack
|
|
98
|
+
│ │ ├── manifest.json # Pack identity, dependencies, and asset maps
|
|
99
|
+
│ │ ├── terminology.json # Industry acronyms & definitions (EMI, LTV, CASA, etc.)
|
|
100
|
+
│ │ ├── concepts.json # 17 core banking entities with aliases & caveats
|
|
101
|
+
│ │ ├── relationships.json # Semantic graph & dependency linkages
|
|
102
|
+
│ │ ├── processes.json # Standard workflows (Credit Appraisal, KYC)
|
|
103
|
+
│ │ ├── rules/
|
|
104
|
+
│ │ │ ├── general.json # Global lending & affordability rules
|
|
105
|
+
│ │ │ └── india.json # RBI LTV caps, CIBIL thresholds, PAN rules
|
|
106
|
+
│ │ └── sources/
|
|
107
|
+
│ │ └── source_registry.json # Regulatory provenance & citations
|
|
108
|
+
│ ├── intelligence/
|
|
109
|
+
│ │ ├── matcher.py # Query tokenization, alias matching & 1-hop expansion
|
|
110
|
+
│ │ └── context_builder.py # Structured context assembler with guardrails
|
|
111
|
+
│ ├── roles/
|
|
112
|
+
│ │ ├── manager.py # Predefined & custom role manager
|
|
113
|
+
│ │ └── predefined/
|
|
114
|
+
│ │ ├── loan_advisor.json # Retail loan advisor persona & limits
|
|
115
|
+
│ │ ├── credit_analyst.json # Underwriting risk analyst persona
|
|
116
|
+
│ │ └── compliance_officer.json# KYC / AML compliance officer persona
|
|
117
|
+
│ ├── rules/
|
|
118
|
+
│ │ └── engine.py # Deterministic rule evaluator (code-driven checks)
|
|
119
|
+
│ └── llm/
|
|
120
|
+
│ ├── base.py # LLM callable protocol
|
|
121
|
+
│ └── providers.py # OpenAI provider adapter
|
|
122
|
+
├── tests/
|
|
123
|
+
│ └── test_dil_banking.py # Unit test suite
|
|
124
|
+
└── examples/
|
|
125
|
+
└── quickstart_loan_advisor.py # End-to-end quickstart script
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 🚀 Quickstart Guide
|
|
131
|
+
|
|
132
|
+
### 1. Installation
|
|
133
|
+
|
|
134
|
+
From the project root:
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
pip install -e dil_banking
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 2. Run the Unit Tests
|
|
141
|
+
|
|
142
|
+
```powershell
|
|
143
|
+
python -m unittest discover -s dil_banking/tests -v
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 3. Run the Loan Advisor Demo
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
python dil_banking/examples/quickstart_loan_advisor.py
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 💡 Developer Usage Example
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from dil import DIL
|
|
158
|
+
|
|
159
|
+
# 1. Initialize DIL for Banking with India jurisdiction overlay
|
|
160
|
+
dil = DIL(domain="banking", jurisdiction="india")
|
|
161
|
+
|
|
162
|
+
# 2. Configure a Role Agent with developer boundaries
|
|
163
|
+
advisor = dil.create_agent(
|
|
164
|
+
role="loan_advisor",
|
|
165
|
+
developer_rules=[
|
|
166
|
+
"Never guarantee loan approval.",
|
|
167
|
+
"Never invent interest rates.",
|
|
168
|
+
"State that sanction requires formal verification.",
|
|
169
|
+
],
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
# 3. Supply customer data for automated calculation & rule evaluation
|
|
173
|
+
customer_data = {
|
|
174
|
+
"applicant_age": 31,
|
|
175
|
+
"loan_amount": 4000000, # ₹40 Lakh
|
|
176
|
+
"property_value": 4800000, # ₹48 Lakh (Calculated LTV: 83.33% -> Breaches RBI 80% cap!)
|
|
177
|
+
"monthly_income": 95000,
|
|
178
|
+
"existing_emi": 15000, # (Calculated DTI: 15.79% -> Complies with <= 50% limit)
|
|
179
|
+
"cibil_score": 745, # (Complies with >= 700 prime cutoff)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
question = "Can I get a home loan of 40 lakh for this property?"
|
|
183
|
+
|
|
184
|
+
# 4. Prepare context or ask an LLM
|
|
185
|
+
result, messages = advisor.prepare(
|
|
186
|
+
question=question,
|
|
187
|
+
customer_data=customer_data,
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# Deterministic rule verdicts are already computed:
|
|
191
|
+
for er in result.evaluated_rules:
|
|
192
|
+
print(f"[{er.status}] {er.rule_title}: {er.message}")
|
|
193
|
+
|
|
194
|
+
# 5. Call LLM (OpenAI, Claude, or local model)
|
|
195
|
+
# response = advisor.ask(question=question, customer_data=customer_data, llm_callable=my_llm_fn)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 🛡 Key Guarantees
|
|
201
|
+
1. **Mathematical Accuracy**: Calculations (LTV, DTI, debt servicing) are executed in pure Python code.
|
|
202
|
+
2. **Regulatory Provenance**: Every rule breach or pass carries its `rule_id`, jurisdiction, and source citation (e.g., RBI Master Directions).
|
|
203
|
+
3. **No Hallucinated Policies**: Explicit system and developer boundaries instruct the model to state missing requirements instead of guessing bank criteria.
|
|
204
|
+
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Domain Intelligence Layer (DIL) — Banking
|
|
2
|
+
|
|
3
|
+
**DIL** is a reusable intelligence infrastructure for enterprise AI applications in banking. It ensures LLMs reason like accredited banking specialists by decoupling **domain knowledge, role boundaries, and deterministic rules** from application data and the underlying model.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🏛 Architecture Overview
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
+---------------------------------------+
|
|
11
|
+
| Application / Chatbot |
|
|
12
|
+
+---------------------------------------+
|
|
13
|
+
│
|
|
14
|
+
▼
|
|
15
|
+
+---------------------------------------+
|
|
16
|
+
| DIL Interface Layer (SDK) |
|
|
17
|
+
| • Agent configuration (Role, Rules) |
|
|
18
|
+
| • Query & customer data intake |
|
|
19
|
+
+---------------------------------------+
|
|
20
|
+
│
|
|
21
|
+
┌──────────────────────────────────┼──────────────────────────────────┐
|
|
22
|
+
▼ ▼ ▼
|
|
23
|
+
+-----------------------+ +-----------------------+ +-----------------------+
|
|
24
|
+
| Domain Intelligence | | Role Intelligence | | Deterministic Rules |
|
|
25
|
+
| • Terminology | | • Objectives | | • Code computations |
|
|
26
|
+
| • Concepts & aliases | | • Persona tone | | • Regulatory caps |
|
|
27
|
+
| • 1-hop ontology | | • Disclaimers | | • RBI / Global rules |
|
|
28
|
+
+-----------------------+ +-----------------------+ +-----------------------+
|
|
29
|
+
└──────────────────────────────────┬──────────────────────────────────┘
|
|
30
|
+
│
|
|
31
|
+
▼
|
|
32
|
+
+---------------------------------------+
|
|
33
|
+
| Audit-Ready Context Engine |
|
|
34
|
+
| Structures facts, rule verdicts, |
|
|
35
|
+
| and mandatory governance directives |
|
|
36
|
+
+---------------------------------------+
|
|
37
|
+
│
|
|
38
|
+
▼
|
|
39
|
+
+---------------------------------------+
|
|
40
|
+
| Any LLM (OpenAI, Claude, Local) |
|
|
41
|
+
| "Code decides; LLM explains" |
|
|
42
|
+
+---------------------------------------+
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 📂 Project Structure
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
dil_banking/
|
|
51
|
+
├── pyproject.toml # Packaging configuration
|
|
52
|
+
├── README.md # Documentation
|
|
53
|
+
├── src/
|
|
54
|
+
│ └── dil/
|
|
55
|
+
│ ├── __init__.py # Public API exports
|
|
56
|
+
│ ├── core/
|
|
57
|
+
│ │ ├── engine.py # DIL and Agent classes
|
|
58
|
+
│ │ ├── loader.py # PackLoader and LoadedPack
|
|
59
|
+
│ │ ├── models.py # Dataclasses (Manifest, Concepts, Rules, Context)
|
|
60
|
+
│ │ └── registry.py # DomainRegistry & pack version manager
|
|
61
|
+
│ ├── domains/
|
|
62
|
+
│ │ └── banking/
|
|
63
|
+
│ │ └── 1.0.0/ # Versioned Banking Knowledge Pack
|
|
64
|
+
│ │ ├── manifest.json # Pack identity, dependencies, and asset maps
|
|
65
|
+
│ │ ├── terminology.json # Industry acronyms & definitions (EMI, LTV, CASA, etc.)
|
|
66
|
+
│ │ ├── concepts.json # 17 core banking entities with aliases & caveats
|
|
67
|
+
│ │ ├── relationships.json # Semantic graph & dependency linkages
|
|
68
|
+
│ │ ├── processes.json # Standard workflows (Credit Appraisal, KYC)
|
|
69
|
+
│ │ ├── rules/
|
|
70
|
+
│ │ │ ├── general.json # Global lending & affordability rules
|
|
71
|
+
│ │ │ └── india.json # RBI LTV caps, CIBIL thresholds, PAN rules
|
|
72
|
+
│ │ └── sources/
|
|
73
|
+
│ │ └── source_registry.json # Regulatory provenance & citations
|
|
74
|
+
│ ├── intelligence/
|
|
75
|
+
│ │ ├── matcher.py # Query tokenization, alias matching & 1-hop expansion
|
|
76
|
+
│ │ └── context_builder.py # Structured context assembler with guardrails
|
|
77
|
+
│ ├── roles/
|
|
78
|
+
│ │ ├── manager.py # Predefined & custom role manager
|
|
79
|
+
│ │ └── predefined/
|
|
80
|
+
│ │ ├── loan_advisor.json # Retail loan advisor persona & limits
|
|
81
|
+
│ │ ├── credit_analyst.json # Underwriting risk analyst persona
|
|
82
|
+
│ │ └── compliance_officer.json# KYC / AML compliance officer persona
|
|
83
|
+
│ ├── rules/
|
|
84
|
+
│ │ └── engine.py # Deterministic rule evaluator (code-driven checks)
|
|
85
|
+
│ └── llm/
|
|
86
|
+
│ ├── base.py # LLM callable protocol
|
|
87
|
+
│ └── providers.py # OpenAI provider adapter
|
|
88
|
+
├── tests/
|
|
89
|
+
│ └── test_dil_banking.py # Unit test suite
|
|
90
|
+
└── examples/
|
|
91
|
+
└── quickstart_loan_advisor.py # End-to-end quickstart script
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 🚀 Quickstart Guide
|
|
97
|
+
|
|
98
|
+
### 1. Installation
|
|
99
|
+
|
|
100
|
+
From the project root:
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
pip install -e dil_banking
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 2. Run the Unit Tests
|
|
107
|
+
|
|
108
|
+
```powershell
|
|
109
|
+
python -m unittest discover -s dil_banking/tests -v
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 3. Run the Loan Advisor Demo
|
|
113
|
+
|
|
114
|
+
```powershell
|
|
115
|
+
python dil_banking/examples/quickstart_loan_advisor.py
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 💡 Developer Usage Example
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from dil import DIL
|
|
124
|
+
|
|
125
|
+
# 1. Initialize DIL for Banking with India jurisdiction overlay
|
|
126
|
+
dil = DIL(domain="banking", jurisdiction="india")
|
|
127
|
+
|
|
128
|
+
# 2. Configure a Role Agent with developer boundaries
|
|
129
|
+
advisor = dil.create_agent(
|
|
130
|
+
role="loan_advisor",
|
|
131
|
+
developer_rules=[
|
|
132
|
+
"Never guarantee loan approval.",
|
|
133
|
+
"Never invent interest rates.",
|
|
134
|
+
"State that sanction requires formal verification.",
|
|
135
|
+
],
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
# 3. Supply customer data for automated calculation & rule evaluation
|
|
139
|
+
customer_data = {
|
|
140
|
+
"applicant_age": 31,
|
|
141
|
+
"loan_amount": 4000000, # ₹40 Lakh
|
|
142
|
+
"property_value": 4800000, # ₹48 Lakh (Calculated LTV: 83.33% -> Breaches RBI 80% cap!)
|
|
143
|
+
"monthly_income": 95000,
|
|
144
|
+
"existing_emi": 15000, # (Calculated DTI: 15.79% -> Complies with <= 50% limit)
|
|
145
|
+
"cibil_score": 745, # (Complies with >= 700 prime cutoff)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
question = "Can I get a home loan of 40 lakh for this property?"
|
|
149
|
+
|
|
150
|
+
# 4. Prepare context or ask an LLM
|
|
151
|
+
result, messages = advisor.prepare(
|
|
152
|
+
question=question,
|
|
153
|
+
customer_data=customer_data,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Deterministic rule verdicts are already computed:
|
|
157
|
+
for er in result.evaluated_rules:
|
|
158
|
+
print(f"[{er.status}] {er.rule_title}: {er.message}")
|
|
159
|
+
|
|
160
|
+
# 5. Call LLM (OpenAI, Claude, or local model)
|
|
161
|
+
# response = advisor.ask(question=question, customer_data=customer_data, llm_callable=my_llm_fn)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 🛡 Key Guarantees
|
|
167
|
+
1. **Mathematical Accuracy**: Calculations (LTV, DTI, debt servicing) are executed in pure Python code.
|
|
168
|
+
2. **Regulatory Provenance**: Every rule breach or pass carries its `rule_id`, jurisdiction, and source citation (e.g., RBI Master Directions).
|
|
169
|
+
3. **No Hallucinated Policies**: Explicit system and developer boundaries instruct the model to state missing requirements instead of guessing bank criteria.
|
|
170
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dil-banking"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Domain Intelligence Layer (DIL) for Banking - Enterprise domain reasoning, deterministic rules, and role-governed context for LLMs"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "DIL Architecture Team", email = "architecture@dil.ai" }
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
"Operating System :: OS Independent",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
27
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
28
|
+
]
|
|
29
|
+
dependencies = []
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
storage = [
|
|
33
|
+
"pyarrow>=12.0.0",
|
|
34
|
+
]
|
|
35
|
+
openai = [
|
|
36
|
+
"openai>=1.0.0",
|
|
37
|
+
"python-dotenv>=1.0.0",
|
|
38
|
+
]
|
|
39
|
+
dev = [
|
|
40
|
+
"pytest>=7.0",
|
|
41
|
+
"build>=1.0.0",
|
|
42
|
+
"twine>=4.0.0",
|
|
43
|
+
]
|
|
44
|
+
all = [
|
|
45
|
+
"pyarrow>=12.0.0",
|
|
46
|
+
"openai>=1.0.0",
|
|
47
|
+
"python-dotenv>=1.0.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools]
|
|
51
|
+
package-dir = {"" = "src"}
|
|
52
|
+
include-package-data = true
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.packages.find]
|
|
55
|
+
where = ["src"]
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.package-data]
|
|
58
|
+
"*" = ["*.json", "*.parquet", "*.lock"]
|
|
59
|
+
"dil" = [
|
|
60
|
+
"roles/predefined/*.json",
|
|
61
|
+
"domains/*/*/*.json",
|
|
62
|
+
"domains/*/*/*/*.json",
|
|
63
|
+
"domains/*/*/*/*.parquet",
|
|
64
|
+
"domains/*/*/*/*.lock",
|
|
65
|
+
]
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Domain Intelligence Layer (DIL) - Banking
|
|
3
|
+
A reusable intelligence infrastructure for AI applications in banking.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from dil.core.engine import DIL, Agent
|
|
7
|
+
from dil.core.loader import LoadedPack, PackLoader
|
|
8
|
+
from dil.core.models import (
|
|
9
|
+
ConceptItem,
|
|
10
|
+
ContextResult,
|
|
11
|
+
PackManifest,
|
|
12
|
+
ProcessItem,
|
|
13
|
+
RelationshipItem,
|
|
14
|
+
RoleDefinition,
|
|
15
|
+
RuleEvaluationResult,
|
|
16
|
+
RuleItem,
|
|
17
|
+
SourceItem,
|
|
18
|
+
TerminologyItem,
|
|
19
|
+
)
|
|
20
|
+
from dil.core.registry import DomainRegistry
|
|
21
|
+
from dil.llm.providers import (
|
|
22
|
+
create_gemini_callable,
|
|
23
|
+
create_generic_callable,
|
|
24
|
+
create_ollama_callable,
|
|
25
|
+
create_openai_callable,
|
|
26
|
+
)
|
|
27
|
+
from dil.roles.manager import RoleManager
|
|
28
|
+
from dil.rules.engine import RulesEngine
|
|
29
|
+
from dil.storage.engine import FTSStorageEngine
|
|
30
|
+
from dil.storage.parquet_exporter import ParquetPackExporter
|
|
31
|
+
|
|
32
|
+
__version__ = "1.0.0"
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"DIL",
|
|
36
|
+
"Agent",
|
|
37
|
+
"DomainRegistry",
|
|
38
|
+
"PackLoader",
|
|
39
|
+
"LoadedPack",
|
|
40
|
+
"RulesEngine",
|
|
41
|
+
"RoleManager",
|
|
42
|
+
"FTSStorageEngine",
|
|
43
|
+
"ParquetPackExporter",
|
|
44
|
+
"ContextResult",
|
|
45
|
+
"PackManifest",
|
|
46
|
+
"ConceptItem",
|
|
47
|
+
"TerminologyItem",
|
|
48
|
+
"RelationshipItem",
|
|
49
|
+
"ProcessItem",
|
|
50
|
+
"RuleItem",
|
|
51
|
+
"SourceItem",
|
|
52
|
+
"RoleDefinition",
|
|
53
|
+
"RuleEvaluationResult",
|
|
54
|
+
"create_openai_callable",
|
|
55
|
+
"create_gemini_callable",
|
|
56
|
+
"create_ollama_callable",
|
|
57
|
+
"create_generic_callable",
|
|
58
|
+
]
|