Spaces:
Sleeping
Sleeping
Update app.py
Browse fileschange the prompt to follow the example
app.py
CHANGED
|
@@ -251,13 +251,49 @@ if st.session_state.get('is_key_valid', False):
|
|
| 251 |
|
| 252 |
tools = [get_credit_score, get_account_status, check_pr_status, consult_policy_doc]
|
| 253 |
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, return_intermediate_steps=True)
|
| 262 |
|
| 263 |
col1, col2 = st.columns([1, 2])
|
|
|
|
| 251 |
|
| 252 |
tools = [get_credit_score, get_account_status, check_pr_status, consult_policy_doc]
|
| 253 |
|
| 254 |
+
# --- PROMPT TEMPLATE (Steps Enforcement) ---
|
| 255 |
+
template = """You are a Loan Risk Officer. You must execute the loan assessment process in exactly 4 sequential steps.
|
| 256 |
+
|
| 257 |
+
TOOLS AVAILABLE:
|
| 258 |
+
{tools}
|
| 259 |
+
|
| 260 |
+
INSTRUCTIONS:
|
| 261 |
+
For every request, you MUST follow this reasoning process and output format:
|
| 262 |
+
|
| 263 |
+
Step 1. Retrieve information for customer information
|
| 264 |
+
- Call the SQL tools (get_credit_score, get_account_status).
|
| 265 |
+
- If Nationality is NOT Singaporean, you MUST call check_pr_status.
|
| 266 |
+
- Output the gathered data.
|
| 267 |
+
|
| 268 |
+
Step 2. Check Overall Risk
|
| 269 |
+
- Use 'consult_policy_doc' to find the "Risk Classification Matrix" in the PDF.
|
| 270 |
+
- Compare the Credit Score and Account Status against the matrix.
|
| 271 |
+
- Determine the Risk Level (Low, Medium, or High).
|
| 272 |
+
|
| 273 |
+
Step 3. Check Interest Rate
|
| 274 |
+
- Use 'consult_policy_doc' to find the "Interest Rate Table".
|
| 275 |
+
- Find the rate corresponding to the Risk Level from Step 2.
|
| 276 |
+
|
| 277 |
+
Step 4. Final Report
|
| 278 |
+
- Generate the final recommendation.
|
| 279 |
+
|
| 280 |
+
EXAMPLE OUTPUT FORMAT (Follow this style exactly):
|
| 281 |
+
**Customer Information:** [Name], [ID]
|
| 282 |
+
**Step 1. Retrieve information**
|
| 283 |
+
Credit Score: [Score], Account Status: [Status], Nationality: [Nationality]
|
| 284 |
+
**Step 2. Check Overall Risk**
|
| 285 |
+
Credit Score: [Score] + Account Status: [Status] -> Overall Risk: [Level]
|
| 286 |
+
**Step 3. Check Interest Rate**
|
| 287 |
+
Overall Risk: [Level] -> [Rate]%
|
| 288 |
+
**Step 4. Report**
|
| 289 |
+
Recommend the loan at [Rate]% interest.
|
| 290 |
+
|
| 291 |
+
Begin!
|
| 292 |
+
|
| 293 |
+
Question: {input}
|
| 294 |
+
Thought:{agent_scratchpad}"""
|
| 295 |
+
|
| 296 |
+
prompt = PromptTemplate.from_template(template)
|
| 297 |
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, return_intermediate_steps=True)
|
| 298 |
|
| 299 |
col1, col2 = st.columns([1, 2])
|