Spaces:
Sleeping
Sleeping
| 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 | |
| ) |