GenAI_Loan_Advisor / crew /tasks /resolution_tasks.py
DevKX's picture
Initial deploy
cffeaa1
from crewai import Task
"""
Final Resolution
This task aggregates the findings from all previous agents (Data, Policy, Underwriting).
KEY OBJECTIVE:
To synthesize technical data into a human-readable format.
It reads the JSON outputs from the previous steps via the 'context' parameter.
It strips away code syntax (removing curly braces/JSON).
It generates a professional Markdown report suitable for a Bank Officer to read.
It also help to format the final report
"""
def create_resolution_task(agent, query, context_tasks):
return Task(
description=(
f"**INTERNAL REPORT REQUEST**: '{query}'\n"
"**INPUTS**: Review the outputs from ALL previous agents (Data, Policy, Underwriting) in the context.\n\n"
"**OBJECTIVE**: Compile the 'Internal Verification Report' for the Bank Staff.\n\n"
"**REPORT STRUCTURE (Strictly Follow This)**:\n"
"1. **Executive Decision**: State the Underwriter's final verdict (Approve/Reject), the Risk Level, and the assigned Rate.\n"
"2. **Customer Profile**: Summarize the customer details (Name, Nationality, verified Score/Status) in bullet points.\n"
"3. **Policy Context**: Mention the specific Policy Rule that was triggered (e.g. 'Policy dictates that Closed accounts are Medium Risk').\n"
"4. **Logic Trace**: Explain *why* the decision was made in plain English.\n\n"
"**POLICY only STRUCTURE (Strictly Follow This)**:\n"
"1. **Policy Context**: Mention the specific from context Policy Rule (e.g. 'Based on the BANK's Policy'). Do not create your own policy\n"
"**Chit Chat only STRUCTURE (Strictly Follow This)**:\n"
"1. **Chit Chat**: Just chit chat and response postively.\n"
"**NEGATIVE CONSTRAINTS (CRITICAL)**:\n"
"- ❌ **NO RAW JSON**: Do not output code blocks like ```json ... ```. The user must never see curly braces.\n"
"- ❌ **NO LAZY COPYING**: Do not just dump the input data. Summarize it into sentences.\n"
"- βœ… **FORMATTING**: Do not use hashes (##). Use **BOLD UPPERCASE** for section headers (e.g. **EXECUTIVE DECISION**)."
),
expected_output=(
"A comprehensive Markdown report titled 'INTERNAL VERIFICATION REPORT'. "
"It must include the Decision, Data Evidence, Policy Rules, and Final Logic, written in professional prose without raw JSON."
"If its a Policy Question, only include Policy Context."
"If its a Chit Chat, Just communicate like how Human have small talks."
),
agent=agent,
context=context_tasks
)