Spaces:
Running
Running
Update app.py
Browse filesfine tune the prompt
app.py
CHANGED
|
@@ -254,28 +254,32 @@ if st.session_state.get('is_key_valid', False):
|
|
| 254 |
system_instruction = """You are a Bank Loan Officer.
|
| 255 |
You MUST execute the loan assessment following strictly these 4 steps and this exact output format.
|
| 256 |
|
| 257 |
-
REQUIRED
|
| 258 |
-
Customer Information: [Name], [ID], [Email]
|
| 259 |
-
|
| 260 |
Step 1.Retrieve information for customer information
|
| 261 |
Credit Score: [Score] , Account Status: [Status] , Nationality: [Nationality]
|
|
|
|
|
|
|
| 262 |
|
| 263 |
-
Step
|
| 264 |
-
Credit Score: [Score] , Account Status: [Status] -> overall risk:
|
| 265 |
-
(Consult policy doc for the risk matrix to decide this)
|
| 266 |
|
| 267 |
-
Step
|
| 268 |
overall risk: [Level] -> [Rate]%
|
| 269 |
(Consult policy doc for interest rates)
|
| 270 |
|
| 271 |
-
Step
|
| 272 |
Recommend the loan interest rate [Rate]%
|
| 273 |
|
| 274 |
INSTRUCTIONS:
|
| 275 |
1. Use SQL tools to get Name, ID, Email, Score, Status, Nationality.
|
| 276 |
2. If Nationality is NOT Singaporean, you MUST check PR status.
|
| 277 |
3. Use 'consult_policy_doc' to find the Risk Matrix and Interest Rates.
|
| 278 |
-
4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
"""
|
| 280 |
|
| 281 |
prompt = ChatPromptTemplate.from_messages([
|
|
@@ -312,26 +316,14 @@ if st.session_state.get('is_key_valid', False):
|
|
| 312 |
1. DO NOT query 'get_credit_score' or 'account_status' for Score/Status.
|
| 313 |
2. USE: Score: {sim_score}, Status: {sim_status}
|
| 314 |
3. Query 'get_account_status' ONLY for Name/Nationality/Email.
|
| 315 |
-
4. Follow the strict
|
| 316 |
-
5. Provide a Final Recommendation Report that MUST include:
|
| 317 |
-
- Customer Name, ID, Email
|
| 318 |
-
- Risk Level, Interest Rate
|
| 319 |
-
- Final Decision (Approve/Reject)
|
| 320 |
-
- Justification for Decision (Cite specific PDF policies)
|
| 321 |
-
- Format in a clear markdown table.
|
| 322 |
"""
|
| 323 |
else:
|
| 324 |
query = f"""
|
| 325 |
Process Loan for Customer ID: {uid}.
|
| 326 |
1. Query SQL tools for Name, Email, Nationality, Status, Score.
|
| 327 |
2. IF Nationality is 'Singaporean', SKIP 'check_pr_status'.
|
| 328 |
-
3. Follow the strict
|
| 329 |
-
4. Provide a Final Recommendation Report that MUST include:
|
| 330 |
-
- Customer Name, ID, Email
|
| 331 |
-
- Risk Level, Interest Rate
|
| 332 |
-
- Final Decision (Approve/Reject)
|
| 333 |
-
- Justification for Decision (Cite specific PDF policies)
|
| 334 |
-
- Format in a clear markdown table.
|
| 335 |
"""
|
| 336 |
|
| 337 |
with st.status("🤖 Agent is processing...", expanded=True) as status:
|
|
|
|
| 254 |
system_instruction = """You are a Bank Loan Officer.
|
| 255 |
You MUST execute the loan assessment following strictly these 4 steps and this exact output format.
|
| 256 |
|
| 257 |
+
REQUIRED FLOW:
|
|
|
|
|
|
|
| 258 |
Step 1.Retrieve information for customer information
|
| 259 |
Credit Score: [Score] , Account Status: [Status] , Nationality: [Nationality]
|
| 260 |
+
|
| 261 |
+
Step 2. Check PR Status (For Non-Singapore this extra Step is needed)
|
| 262 |
|
| 263 |
+
Step 3.Check Overall Risk
|
| 264 |
+
Credit Score: [Score] , Account Status: [Status] -> overall risk: Consult policy doc for the risk matrix to decide this)
|
|
|
|
| 265 |
|
| 266 |
+
Step 4.Check interest rate
|
| 267 |
overall risk: [Level] -> [Rate]%
|
| 268 |
(Consult policy doc for interest rates)
|
| 269 |
|
| 270 |
+
Step 5. Report
|
| 271 |
Recommend the loan interest rate [Rate]%
|
| 272 |
|
| 273 |
INSTRUCTIONS:
|
| 274 |
1. Use SQL tools to get Name, ID, Email, Score, Status, Nationality.
|
| 275 |
2. If Nationality is NOT Singaporean, you MUST check PR status.
|
| 276 |
3. Use 'consult_policy_doc' to find the Risk Matrix and Interest Rates.
|
| 277 |
+
4. Provide a Final Recommendation Report that MUST include:
|
| 278 |
+
- Customer Name, ID, Email
|
| 279 |
+
- Risk Level, Interest Rate
|
| 280 |
+
- Final Decision (Approve/Reject)
|
| 281 |
+
- Justification for Decision (Cite specific PDF policies)
|
| 282 |
+
- Format in a clear markdown table.
|
| 283 |
"""
|
| 284 |
|
| 285 |
prompt = ChatPromptTemplate.from_messages([
|
|
|
|
| 316 |
1. DO NOT query 'get_credit_score' or 'account_status' for Score/Status.
|
| 317 |
2. USE: Score: {sim_score}, Status: {sim_status}
|
| 318 |
3. Query 'get_account_status' ONLY for Name/Nationality/Email.
|
| 319 |
+
4. Follow the strict 5-step flow defined in the system instructions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
"""
|
| 321 |
else:
|
| 322 |
query = f"""
|
| 323 |
Process Loan for Customer ID: {uid}.
|
| 324 |
1. Query SQL tools for Name, Email, Nationality, Status, Score.
|
| 325 |
2. IF Nationality is 'Singaporean', SKIP 'check_pr_status'.
|
| 326 |
+
3. Follow the strict 5-step flow defined in the system instructions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
"""
|
| 328 |
|
| 329 |
with st.status("🤖 Agent is processing...", expanded=True) as status:
|