Spaces:
Sleeping
Sleeping
| from crewai import Task | |
| """ | |
| KEY OBJECTIVES: | |
| 1. Input Validation: Stop the agent early if no name is provided. | |
| 2. Anti-Hallucination: Explicitly forbid generating fake IDs/Names. | |
| 3. Dependency Management: Enforce the order of operations (Name -> ID -> Data). | |
| 4. Standardization: Force the output into a strict JSON format for the next agent. | |
| """ | |
| def create_data_collection_task(agent, inputs): | |
| return Task( | |
| description=( | |
| f"**INVESTIGATION REQUIRED**: The Manager needs a full data profile for query: '{inputs}'\n\n" | |
| "### π PRE-FLIGHT CHECK:\n" | |
| "1. If the query does not contain a specific person's name (e.g., 'Andy', 'Hilda'), DO NOT ATTEMPT TO SEARCH \n" | |
| "2. Do Not create your own customer data like Customer name or Customer ID to search\n" | |
| "3. Respond immediately with: {'found': false, 'error': 'No customer name provided in query.'} and exit\n\n" | |
| "**EXECUTION PLAN (STRICT ORDER)**:\n" | |
| "1. **RESOLVE ID**: Use `get_customer_id_by_name` to find the unique ID for the name provided.\n" | |
| " - *CRITICAL*: If this returns 'None', STOP and return {{'found': false}}.\n" | |
| "2. **FETCH DETAILS**: Use the retrieved ID to call `get_customer_details`.\n" | |
| "3. **FETCH FINANCIALS**: Use the retrieved ID to call `get_credit_score` and `get_account_status`.\n" | |
| "4. **FETCH LEGAL**: Use the retrieved ID to call `get_pr_status`.\n\n" | |
| "**REQUIRED OUTPUT SCHEMA**:\n" | |
| "You must consolidate all API responses into this single JSON structure:\n" | |
| "{\n" | |
| ' "found": boolean,\n' | |
| ' "customer_name": "string",\n' | |
| ' "customer_id": "string",\n' | |
| ' "credit_score": number,\n' | |
| ' "nationality": "string",\n' | |
| ' "is_pr": boolean,\n' | |
| ' "account_status": "string"\n' | |
| "}" | |
| ), | |
| expected_output="A single valid JSON object containing the consolidated data from database.", | |
| agent=agent | |
| ) |