Update sub_agents.py
Browse files- sub_agents.py +29 -7
sub_agents.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from deepagents.middleware.subagents import SubAgent
|
| 2 |
-
from tools import route_tool, cost_tool, traffic_tool
|
| 3 |
|
| 4 |
route_agent = SubAgent(
|
| 5 |
name="RealRouteAgent",
|
|
@@ -59,6 +59,22 @@ traffic_agent = SubAgent(
|
|
| 59 |
tools=[traffic_tool],
|
| 60 |
)
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
coordinator = SubAgent(
|
| 63 |
name="Coordinator",
|
| 64 |
description="Synthesizes information and handles user queries intelligently",
|
|
@@ -66,11 +82,11 @@ coordinator = SubAgent(
|
|
| 66 |
You are the delivery coordinator. Your job is to understand what the user wants and respond appropriately.
|
| 67 |
|
| 68 |
CRITICAL DECISION LOGIC:
|
| 69 |
-
|
| 70 |
1. IF user asks for ROUTE planning:
|
| 71 |
- Check if BOTH origin AND destination are provided
|
| 72 |
- If missing, ask for them
|
| 73 |
-
- If provided, use route agent
|
| 74 |
|
| 75 |
2. IF user asks for COST calculation with specific numbers (distance, weight, duration):
|
| 76 |
- Use cost agent DIRECTLY
|
|
@@ -82,7 +98,12 @@ coordinator = SubAgent(
|
|
| 82 |
- If missing, ask for them
|
| 83 |
- If provided, use traffic agent
|
| 84 |
|
| 85 |
-
4. IF user asks for
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
- Check if ALL required info is provided (origin, destination, weight)
|
| 87 |
- If anything is missing, ask for it
|
| 88 |
- If all provided, coordinate all agents
|
|
@@ -92,13 +113,14 @@ coordinator = SubAgent(
|
|
| 92 |
2. Route Summary (distance, duration)
|
| 93 |
3. Cost Breakdown
|
| 94 |
4. Traffic Conditions
|
| 95 |
-
5.
|
|
|
|
| 96 |
|
| 97 |
MAP LINK FORMATTING:
|
| 98 |
- When you receive a map URL like "/view-map/route_X_Y.html", format it as:
|
| 99 |
-
"
|
| 100 |
- Place this at the TOP of your response
|
| 101 |
|
| 102 |
DO NOT make assumptions. If information is missing, ask the user.
|
| 103 |
""",
|
| 104 |
-
)
|
|
|
|
| 1 |
from deepagents.middleware.subagents import SubAgent
|
| 2 |
+
from tools import route_tool, cost_tool, traffic_tool, weather_tool
|
| 3 |
|
| 4 |
route_agent = SubAgent(
|
| 5 |
name="RealRouteAgent",
|
|
|
|
| 59 |
tools=[traffic_tool],
|
| 60 |
)
|
| 61 |
|
| 62 |
+
weather_agent = SubAgent(
|
| 63 |
+
name="RealWeatherAnalyzer",
|
| 64 |
+
description="Analyzes weather when both origin and destination are provided",
|
| 65 |
+
system_prompt="""
|
| 66 |
+
You are a weather analysis expert.
|
| 67 |
+
|
| 68 |
+
CRITICAL RULES:
|
| 69 |
+
- ONLY use 'real_weather_analyzer' if user provides BOTH origin AND destination
|
| 70 |
+
- If locations are missing, respond: "I need both origin and destination to analyze weather. Please provide both locations."
|
| 71 |
+
- DO NOT assume locations
|
| 72 |
+
- DO NOT analyze weather if user only asks for cost calculations
|
| 73 |
+
|
| 74 |
+
When locations ARE provided, give insights on current weather conditions.
|
| 75 |
+
"""
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
coordinator = SubAgent(
|
| 79 |
name="Coordinator",
|
| 80 |
description="Synthesizes information and handles user queries intelligently",
|
|
|
|
| 82 |
You are the delivery coordinator. Your job is to understand what the user wants and respond appropriately.
|
| 83 |
|
| 84 |
CRITICAL DECISION LOGIC:
|
| 85 |
+
|
| 86 |
1. IF user asks for ROUTE planning:
|
| 87 |
- Check if BOTH origin AND destination are provided
|
| 88 |
- If missing, ask for them
|
| 89 |
+
- If provided, only use route agent
|
| 90 |
|
| 91 |
2. IF user asks for COST calculation with specific numbers (distance, weight, duration):
|
| 92 |
- Use cost agent DIRECTLY
|
|
|
|
| 98 |
- If missing, ask for them
|
| 99 |
- If provided, use traffic agent
|
| 100 |
|
| 101 |
+
4. IF user asks for WEATHER analysis:
|
| 102 |
+
- Check if BOTH origin AND destination are provided
|
| 103 |
+
- If missing, ask for them
|
| 104 |
+
- If provided, use weather agent
|
| 105 |
+
|
| 106 |
+
5. IF user asks for COMPLETE delivery planning (route + cost + traffic + weather):
|
| 107 |
- Check if ALL required info is provided (origin, destination, weight)
|
| 108 |
- If anything is missing, ask for it
|
| 109 |
- If all provided, coordinate all agents
|
|
|
|
| 113 |
2. Route Summary (distance, duration)
|
| 114 |
3. Cost Breakdown
|
| 115 |
4. Traffic Conditions
|
| 116 |
+
5. Weather Conditions
|
| 117 |
+
6. Final Recommendations
|
| 118 |
|
| 119 |
MAP LINK FORMATTING:
|
| 120 |
- When you receive a map URL like "/view-map/route_X_Y.html", format it as:
|
| 121 |
+
"VIEW INTERACTIVE MAP: [CLICK HERE](/view-map/route_X_Y.html)"
|
| 122 |
- Place this at the TOP of your response
|
| 123 |
|
| 124 |
DO NOT make assumptions. If information is missing, ask the user.
|
| 125 |
""",
|
| 126 |
+
)
|