-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
125 lines (106 loc) · 4.08 KB
/
main.py
File metadata and controls
125 lines (106 loc) · 4.08 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import os
from tools import store_user_info, upload_file, get_session_status, clear_session_storage
from agents import concierge_assistant, document_verification_assistant, processing_assistant, compliance_assistant
from strands import Agent
from strands.models import BedrockModel
from config import AgentConfig
DEMO_USER = {
"name": "Joe Doe",
"email": "joe.doe@example.com",
"age": 35,
"address": "123 Main Street, Anytown, CA 90210",
"income": 85000.0,
"employment_length": 7.5,
"loan_intent": "home improvement",
"loan_amount": 25000.0,
"current_debt": 15000.0,
"loan_default": "no"
}
DEMO_DOCUMENTS = {
"identity_proof": {
"filename": "JoeDoeIDVerification.pdf",
"path": "data/JoeDoeIDVerification.pdf",
"user_email": "joe.doe@example.com"
},
"income_document": {
"filename": "JoeDoePayStub.pdf",
"path": "data/JoeDoePayStub.pdf",
"user_email": "joe.doe@example.com"
},
"bank_statement": {
"filename": "JoeDoeBankStatement.pdf",
"path": "data/JoeDoeBankStatement.pdf",
"user_email": "joe.doe@example.com"
},
"credit_report": {
"filename": "JoeDoeCreditReport.pdf",
"path": "data/JoeDoeCreditReport.pdf",
"user_email": "joe.doe@example.com"
}
}
config = AgentConfig()
model = BedrockModel(
model_id=config.model_id,
temperature=config.temperature,
top_p=config.top_p
)
LOAN_ASSISTANT_PROMPT = """
You are LoanAssist, orchestrating the complete loan processing workflow:
1. Concierge Agent: Store user info and upload documents
2. Document Verification Agent: Verify documents against user data
3. Processing Agent: Calculate underwriting metrics and risk analysis
4. Compliance Agent: Final review and regulatory compliance
Execute agents in sequence for complete loan processing workflow.
"""
agent = Agent(
system_prompt=LOAN_ASSISTANT_PROMPT,
tools=[concierge_assistant, document_verification_assistant, processing_assistant,
compliance_assistant, store_user_info, upload_file, get_session_status, clear_session_storage],
name="LoanAssist",
model=model
)
def validate_demo_files():
"""Check if demo files exist"""
missing = []
for _, doc_info in DEMO_DOCUMENTS.items():
if not os.path.exists(doc_info["path"]):
missing.append(doc_info["path"])
return len(missing) == 0, missing
def run_demo_workflow():
"""Execute complete multi-agent loan processing workflow"""
print("\n🚀 Starting Multi-Agent Loan Processing Workflow")
print(f"Applicant: {DEMO_USER['name']} - ${DEMO_USER['loan_amount']:,.0f} {DEMO_USER['loan_intent']} loan")
# Store user info and documents
store_user_info(DEMO_USER)
upload_file(DEMO_DOCUMENTS)
# Execute complete workflow
workflow_prompt = f"""
Execute complete loan processing workflow for {DEMO_USER['email']}:
1. First, use concierge_assistant to confirm application data is stored
2. Then use document_verification_assistant to verify uploaded documents
3. Next use processing_assistant for credit analysis and underwriting
4. Finally use compliance_assistant for final review and decision
Process each step completely before moving to the next.
"""
print("\n📋 Processing application through all agents...")
response = agent(workflow_prompt)
print(f"\n{response}")
if __name__ == "__main__":
print("\n💵 Loan Processing Multi-Agent Demo")
while True:
print("\nSelect an option:")
print("[1] Run Demo Workflow (Joe Doe)")
print("[2] Exit")
choice = input("\n> ").strip()
if choice == "1":
valid, missing = validate_demo_files()
if not valid:
print(f"\n❌ Missing demo files: {missing}")
print("Ensure all PDF files exist in data/ folder")
else:
run_demo_workflow()
elif choice == "2":
print("\nGoodbye! 👋")
break
else:
print("Invalid choice. Try again.")