Marco310 commited on
Commit
760373c
·
1 Parent(s): e21f8cc

feat: Enhance prompting ability

Browse files
Files changed (1) hide show
  1. 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-24T09:00:00+08:00`).
26
- - **Time Window Strategy (NEW)**:
27
- - **REQUIRED**: When inferring or generating task windows (especially for leisure/sightseeing), ensure a **minimum 60-minute buffer** between the *earliest_time* and *latest_time* for that task. This allows the solver flexibility.
28
- - *Example*: A museum that opens at 10:00 and closes at 17:00 should have a window of `10:00:00` to `17:00:00` (or `16:00:00` if accounting for service duration), *not* a tight `10:00:00` to `12:00:00` window.
 
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**: Format `YYYY-MM-DDTHH:MM:SS+HH:MM`.
36
- - **start_location**: Determines where the route begins.
37
- 1. **User Specified**: If user mentions a hotel/address (e.g. "I'm staying at Hilton"), use that.
38
- 2. **User's coordinate**: Use <current_location> from context.
39
- 3. **Tourist (General Request)**:
40
- - ⛔️ **FORBIDDEN**: Do NOT use generic city names (e.g., "San Francisco", "Tokyo").
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` based on user urgency.
51
  - **location_hint**: Specific POI name searchable on Google Maps.
52
- - **service_duration_min**: Estimated time for the activity itself.
53
- - Sightseeing: **90-120m** (Increase to allow richer experience)
54
- - Meal: 60-90m
55
- - Errands: 15-45m
56
  - **category**: `MEDICAL`, `SHOPPING`, `MEAL`, `LEISURE`, `ERRAND`.
57
 
58
  ---
59
 
60
- ### 4. Time Window Logic (Flexibility is Key)
61
- - **Single Window**: `"time_window": {"earliest_time": "...", "latest_time": "..."}`
62
- - **Multi-Segment**: `"time_windows": [...]` (e.g., Lunch split shift).
63
- - **Maximizing Flexibility**:
64
- - **General Rule**: Use the full available operational hours of the POI for the `time_window` unless the user specifies a constraint (e.g., "Must be before noon").
65
- - **Goal**: Make the `time_window` as **wide** as possible to maximize the TSPTW solver's ability to find an optimal route.
66
- - **Note**: Use `null` if there is absolutely no time constraint (though operational hours should be preferred if known).
 
 
 
 
 
 
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