Spaces:
Sleeping
Sleeping
feat: Enhance prompting ability
Browse files- src/agent/setting/planner.py +33 -29
src/agent/setting/planner.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
markdown=True
|
| 3 |
|
| 4 |
description = """
|
|
@@ -10,10 +9,11 @@ Your goal is to analyze the user's request and strictly architect a **Task List*
|
|
| 10 |
expected_output = """
|
| 11 |
1. **Engaging Overview**: A warm, natural paragraph (3-4 sentences).
|
| 12 |
- **Language**: Match user's language.
|
| 13 |
-
- **Logic**: Briefly explain why you chose these spots.
|
| 14 |
-
- **Note**: Do NOT list the full itinerary step-by-step (the backend will schedule it).
|
| 15 |
2. Delimiter: `@@@@@`
|
| 16 |
-
3. **Structured Data**: Valid JSON containing `global_info` and `tasks`.
|
|
|
|
| 17 |
"""
|
| 18 |
|
| 19 |
instructions = """
|
|
@@ -22,48 +22,52 @@ instructions = """
|
|
| 22 |
### 1. Context & Time Logic (CRITICAL)
|
| 23 |
- Check `current_datetime` from context.
|
| 24 |
- **Strict ISO 8601 Format**: ALL timestamps MUST be in **ISO 8601 format** combining Date + Time + Offset.
|
| 25 |
-
- **Pattern**: `YYYY-MM-DDTHH:MM:SS+HH:MM` (e.g., `2025-11-
|
| 26 |
-
- **
|
| 27 |
-
|
| 28 |
-
-
|
|
|
|
| 29 |
|
| 30 |
---
|
| 31 |
|
| 32 |
### 2. Global Info Strategy (CRITICAL: Start Location)
|
| 33 |
- **language**: Match user's language (e.g., `en-US`, `zh-TW`).
|
| 34 |
- **plan_type**: Detect intent. Returns `TRIP` (Fun) or `SCHEDULE` (Errands).
|
| 35 |
-
- **departure_time**:
|
| 36 |
-
- **start_location**:
|
| 37 |
-
1. **User Specified**: If user
|
| 38 |
-
2. **User's
|
| 39 |
-
|
| 40 |
-
-
|
| 41 |
-
- ✅ **REQUIRED**: You MUST infer the **Main Airport** or **Central Train Station**.
|
| 42 |
-
- *Example*: User says "Trip to San Francisco" -> Set start to "San Francisco International Airport (SFO)".
|
| 43 |
-
- *Example*: User says "Trip to Osaka" -> Set start to "Osaka Station" or "Kansai Airport".
|
| 44 |
|
| 45 |
---
|
| 46 |
|
| 47 |
### 3. Task Generation & Duration Rules
|
| 48 |
- **task_id**: Unique integer starting from 1.
|
| 49 |
- **description**: Short, clear task name.
|
| 50 |
-
- **priority**: `HIGH`, `MEDIUM`, `LOW
|
| 51 |
- **location_hint**: Specific POI name searchable on Google Maps.
|
| 52 |
-
- **service_duration_min**:
|
| 53 |
-
- Sightseeing: **90-120m**
|
| 54 |
-
- Meal: 60-90m
|
| 55 |
-
- Errands: 15-45m
|
| 56 |
- **category**: `MEDICAL`, `SHOPPING`, `MEAL`, `LEISURE`, `ERRAND`.
|
| 57 |
|
| 58 |
---
|
| 59 |
|
| 60 |
-
### 4. Time Window Logic (Flexibility
|
| 61 |
-
- **
|
| 62 |
-
- **
|
| 63 |
-
|
| 64 |
-
-
|
| 65 |
-
|
| 66 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
---
|
| 69 |
|
|
|
|
|
|
|
| 1 |
markdown=True
|
| 2 |
|
| 3 |
description = """
|
|
|
|
| 9 |
expected_output = """
|
| 10 |
1. **Engaging Overview**: A warm, natural paragraph (3-4 sentences).
|
| 11 |
- **Language**: Match user's language.
|
| 12 |
+
- **Logic**: Briefly explain why you chose these spots and the flow.
|
| 13 |
+
- **Note**: Do NOT list the full itinerary step-by-step here (the backend will schedule it).
|
| 14 |
2. Delimiter: `@@@@@`
|
| 15 |
+
3. **Structured Data**: STRICT Valid JSON containing `global_info` and `tasks`.
|
| 16 |
+
- **Constraint**: Ensure `start_location` and `time_window` follow the specific logic in instructions.
|
| 17 |
"""
|
| 18 |
|
| 19 |
instructions = """
|
|
|
|
| 22 |
### 1. Context & Time Logic (CRITICAL)
|
| 23 |
- Check `current_datetime` from context.
|
| 24 |
- **Strict ISO 8601 Format**: ALL timestamps MUST be in **ISO 8601 format** combining Date + Time + Offset.
|
| 25 |
+
- **Pattern**: `YYYY-MM-DDTHH:MM:SS+HH:MM` (e.g., `2025-11-27T09:00:00+08:00`).
|
| 26 |
+
- **Future Date Rule**: The `departure_time` MUST be in the future. If the user does not specify a date, default to **Tomorrow**.
|
| 27 |
+
- **Smart Start Logic**:
|
| 28 |
+
- Do NOT default to an arbitrarily early time (e.g., 08:00) if the first logical task (like Lunch) starts much later.
|
| 29 |
+
- Set `departure_time` reasonably close to the first likely task's start window (minus estimated travel time).
|
| 30 |
|
| 31 |
---
|
| 32 |
|
| 33 |
### 2. Global Info Strategy (CRITICAL: Start Location)
|
| 34 |
- **language**: Match user's language (e.g., `en-US`, `zh-TW`).
|
| 35 |
- **plan_type**: Detect intent. Returns `TRIP` (Fun) or `SCHEDULE` (Errands).
|
| 36 |
+
- **departure_time**: See "Smart Start Logic" above.
|
| 37 |
+
- **start_location Logic**:
|
| 38 |
+
1. **User Specified**: If user explicitly names a start point (e.g., "From Grand Hyatt"), use that.
|
| 39 |
+
2. **Context Check (Cross-City vs. Local)**: Compare the User's `current_location` (from context) with the **Trip Destination**.
|
| 40 |
+
- **Different City/Region**: You MUST set `start_location` to the **Main Airport** or **Central Train Station** of the destination city (Full Name, e.g., "Kyoto Station", "Narita International Airport").
|
| 41 |
+
- **Same City/Region**: Set `start_location` strictly to the string `"USER LOCATION"`.
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
---
|
| 44 |
|
| 45 |
### 3. Task Generation & Duration Rules
|
| 46 |
- **task_id**: Unique integer starting from 1.
|
| 47 |
- **description**: Short, clear task name.
|
| 48 |
+
- **priority**: `HIGH`, `MEDIUM`, `LOW`.
|
| 49 |
- **location_hint**: Specific POI name searchable on Google Maps.
|
| 50 |
+
- **service_duration_min**:
|
| 51 |
+
- Sightseeing: **90-120m**
|
| 52 |
+
- Meal: **60-90m**
|
| 53 |
+
- Errands: **15-45m**
|
| 54 |
- **category**: `MEDICAL`, `SHOPPING`, `MEAL`, `LEISURE`, `ERRAND`.
|
| 55 |
|
| 56 |
---
|
| 57 |
|
| 58 |
+
### 4. Time Window Logic (Flexibility vs. Constraints)
|
| 59 |
+
- **Validation Rule**: `earliest_time` MUST be strictly BEFORE (<) `latest_time`.
|
| 60 |
+
- **General Tasks (Max Flexibility)**:
|
| 61 |
+
- Unless specified, use the POI's full operating hours.
|
| 62 |
+
- Make the window as **wide** as possible to allow the solver to optimize the route.
|
| 63 |
+
- **Meal Tasks (Fixed Logic)**:
|
| 64 |
+
- Meals act as anchors. Do NOT use infinite windows. Use logical meal times:
|
| 65 |
+
- **Breakfast**: ~ `07:00` to `10:00`
|
| 66 |
+
- **Lunch**: ~ `11:30` to `14:30`
|
| 67 |
+
- **Dinner**: ~ `17:30` to `20:30`
|
| 68 |
+
- **Format**:
|
| 69 |
+
- `time_window`: `{"earliest_time": "...", "latest_time": "..."}`
|
| 70 |
+
- Use `null` if absolutely no time constraint exists.
|
| 71 |
|
| 72 |
---
|
| 73 |
|