File size: 2,320 Bytes
cffeaa1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from crewai import Task




"""
Instructs the agent to perform a Vector Search and format the results.

KEY OBJECTIVE:
To convert unstructured PDF text into a structured JSON object. 
It explicitly separates "Rules" (logic like if/else) from "Data Points" (hard numbers/rates),
making it easier for the Underwriter agent to apply these policies programmatically later.
"""

def create_policy_search_task(agent, query: str):

    return Task(
        description=(
            f"**SEARCH REQUEST**: '{query}'\n\n"
            
            "**YOUR JOB**: Fetch the policy rules. Do NOT analyze them. Do NOT format them into tables.\n"
            "Just find the text and convert it into **Plain English Bullet Points** for the Supervisor.\n\n"
            
            "**EXECUTION STEPS**:\n"
            "1. Search for 'Overall Risk' and 'Interest Rates'.\n"
            "2. **STOP** immediately after the first search.\n"
            "3. **OUTPUT**: List the rules simply.\n\n"
            
            "**REQUIRED OUTPUT FORMAT**:\n"
            "Return a list like this:\n"
            "- If Credit Score is [Range] and Account is [Status], then Risk is [Level].\n"
            "- If Risk is [Level], then Interest Rate is [Value].\n"
            "\n"
            "(Include the specific numbers found in the search results)."
        ),
        expected_output="A simple list of policy rules in plain text.",
        agent=agent,
        
        # 🛑 HARD STOP: Prevent the loop.
        # The agent gets 1 try. If it finds anything, we take it.
        max_iter=1
    )
def create_policy_summary_task(agent, query: str):
    """
    Returns a Task for explaining policy without making a decision.
    This is for policy specific question like what is consider high risk
    """
    
    return Task(
        description=(
            f"**QUERY**: '{query}'\n\n"
            "**YOUR GOAL**: Explain the high-risk criteria or policy rules relevant to the query in plain text.\n"
            "Do NOT make a decision or assign any verdict. Output only a descriptive summary.\n"
            "Format:\n"
            "- Topic / Section\n"
            "- Rules Summary\n"
            "- Data Points if available"
        ),
        expected_output="Plain text summary of relevant policy rules.",
        agent=agent
    )