taspol commited on
Commit
1c02ddb
·
1 Parent(s): 887382d

fix: dependency

Browse files
Files changed (2) hide show
  1. interface.py +9 -1
  2. utils/llm_caller.py +24 -63
interface.py CHANGED
@@ -84,10 +84,18 @@ class Safety(BaseModel):
84
  sos: str = Field("", description="Emergency procedures")
85
  contacts: Optional[SafetyContacts] = Field(None, description="Emergency contacts")
86
 
 
 
 
 
 
 
 
 
87
  class TripPlan(BaseModel):
88
  title: str = Field(..., description="Descriptive title for the trip")
89
  date: str = Field(..., description="Suggested date/timing")
90
- timeline: List[Timeline] = Field(default_factory=list, description="Daily timeline")
91
  spots: List[Spot] = Field(default_factory=list, description="Points of interest")
92
  budget: Budget = Field(..., description="Budget breakdown")
93
  permits: Optional[Permits] = Field(None, description="Permit information")
 
84
  sos: str = Field("", description="Emergency procedures")
85
  contacts: Optional[SafetyContacts] = Field(None, description="Emergency contacts")
86
 
87
+ class TimelineEntry(BaseModel):
88
+ t: str = Field(..., description="Time in HH:MM format")
89
+ detail: str = Field(..., description="Activity description")
90
+
91
+ class DayTimeline(BaseModel):
92
+ day: int = Field(..., description="Day number")
93
+ activities: List[TimelineEntry] = Field(..., description="Activities for this day")
94
+
95
  class TripPlan(BaseModel):
96
  title: str = Field(..., description="Descriptive title for the trip")
97
  date: str = Field(..., description="Suggested date/timing")
98
+ timeline: List[DayTimeline] = Field(default_factory=list, description="Daily timeline")
99
  spots: List[Spot] = Field(default_factory=list, description="Points of interest")
100
  budget: Budget = Field(..., description="Budget breakdown")
101
  permits: Optional[Permits] = Field(None, description="Permit information")
utils/llm_caller.py CHANGED
@@ -111,82 +111,43 @@ class LLMCaller:
111
  context_text += f"\n{result['payload'].get('text', '')}"
112
 
113
  # 5. Create detailed prompt for LLM - updated with new fields
114
- llm_prompt = f"""
115
- You are a travel planning assistant. Based on the trip request and travel context provided, generate a comprehensive trip plan in the exact JSON format specified below.
 
 
 
 
 
116
 
117
- Trip Request:
118
- - From: {plan_request.start_place}
119
- - To: {destination}
120
- - Travel Dates: {plan_request.travelDates or 'Flexible'}
121
- - Duration: {duration} days
122
- - Budget: {budget} ({plan_request.budgetTier or 'Not specified'} tier)
123
- - Group Size: {plan_request.groupSize} people
124
- - Interests: {', '.join(plan_request.interests) if plan_request.interests else 'Not specified'}
125
- - Theme: {plan_request.theme or 'General travel'}
126
- - Transport Preference: {plan_request.transportPref or 'Any'}
127
- - Stay Preference: {plan_request.stayPref or 'Any'}
128
- - Legacy Context: {getattr(plan_request, 'trip_context', None) or 'None'}
129
 
130
- Relevant Travel Context:
131
-
132
-
133
- ***Don't Explain or add any additional text outside the JSON format***.
134
- Generate a response in this EXACT JSON format (no additional text before or after):
135
  {{
136
- "tripOverview": "A comprehensive 2-3 paragraph overview of the entire {duration}-day trip from {plan_request.start_place} to {destination}, highlighting the {plan_request.theme or 'travel'} theme and {', '.join(plan_request.interests) if plan_request.interests else 'general sightseeing'} interests",
137
  "trip_plan": {{
138
- "title": "Descriptive title for the {duration}-day {plan_request.theme or 'travel'} trip to {destination}",
139
- "date": "{plan_request.travelDates or 'Flexible dates'}",
140
  "timeline": [
141
- {{"t": "08:30", "detail": "Start of day activity"}},
142
- {{"t": "12:00", "detail": "Lunch break"}},
143
- {{"t": "14:00", "detail": "Afternoon activity"}},
144
- {{"t": "18:00", "detail": "Evening activity"}}
145
  ],
146
- "spots": [
147
- {{"name": "Location name", "time": "09:30 11:45", "notes": "Description and tips for this location"}},
148
- {{"name": "Another location", "time": "14:00 – 16:30", "notes": "More details and recommendations"}}
149
- ],
150
- "budget": {{
151
- "transport": estimated_transport_cost,
152
- "entrance": estimated_entrance_fees,
153
- "meals": estimated_meal_costs,
154
- "accommodation": estimated_accommodation_costs,
155
- "activities": estimated_activity_costs,
156
- "total": total_estimated_cost
157
- }},
158
- "permits": {{
159
- "needed": true_or_false,
160
- "notes": "Permit requirements and how to obtain them",
161
- "seasonal": "Seasonal considerations and restrictions"
162
- }},
163
  "safety": {{
164
- "registration": "Safety registration procedures",
165
- "checkins": "Check-in procedures and requirements",
166
- "sos": "Emergency procedures and protocols",
167
  "contacts": {{
168
- "ranger": {{"name": "Local ranger station name", "phone": "+66-XX-XXX-XXXX"}},
169
- "hospital": {{"name": "Nearest hospital name", "phone": "+66-XX-XXX-XXXX"}},
170
- "police": {{"name": "Local police station", "phone": "1155"}}
171
  }}
172
  }}
173
  }}
174
  }}
175
- Rules:
176
- - Use the provided context to fill in details.
177
- - Ensure all fields are filled with realistic and practical information.
178
- - Use local currency for prices and consider the {plan_request.budgetTier or 'moderate'} budget tier.
179
- - Accommodate {plan_request.groupSize} people in all recommendations.
180
- - Focus on {plan_request.theme or 'general'} themed activities.
181
- - Prioritize interests: {', '.join(plan_request.interests) if plan_request.interests else 'general sightseeing'}.
182
- - Consider transport preference: {plan_request.transportPref or 'any'}.
183
- - Consider accommodation preference: {plan_request.stayPref or 'any'}.
184
- - DONT ADD ANY INLINE NOTE IN JSON
185
-
186
- ***Don't Explain or add any additional text outside the JSON format***.
187
- Ensure the JSON is valid and well-structured.
188
 
189
- Create {duration} days of detailed activities. Include realistic prices, coordinates, and practical tips. Make it specific to the destinations, theme, interests, and budget tier provided.
190
  """
191
 
192
  # 6. Call LLM to generate structured trip plan
 
111
  context_text += f"\n{result['payload'].get('text', '')}"
112
 
113
  # 5. Create detailed prompt for LLM - updated with new fields
114
+ llm_prompt = f"""Generate a travel plan in JSON format for:
115
+ From: {plan_request.start_place} To: {destination}
116
+ Duration: {duration} days | Budget: {budget} ({plan_request.budgetTier or 'Mid-range'})
117
+ Group: {plan_request.groupSize} people | Theme: {plan_request.theme or 'General'}
118
+ Interests: {', '.join(plan_request.interests) if plan_request.interests else 'Sightseeing'}
119
+ Transport: {plan_request.transportPref or 'Any'} | Stay: {plan_request.stayPref or 'Any'}
120
+ Dates: {plan_request.travelDates or 'Flexible'}
121
 
122
+ Context: {context_text[:4000]}{"..." if len(context_text) > 4000 else ""}
 
 
 
 
 
 
 
 
 
 
 
123
 
124
+ Return ONLY this JSON structure:
 
 
 
 
125
  {{
126
+ "tripOverview": "2-3 paragraph trip overview",
127
  "trip_plan": {{
128
+ "title": "{duration}-day {plan_request.theme or 'travel'} trip to {destination}",
129
+ "date": "{plan_request.travelDates or 'Flexible'}",
130
  "timeline": [
131
+ {{"day": 1, "activities": [{{"t": "08:30", "detail": "Activity"}}, {{"t": "12:00", "detail": "Lunch"}}, {{"t": "14:00", "detail": "Activity"}}, {{"t": "18:00", "detail": "Evening"}}]}},
132
+ {{"day": 2, "activities": [{{"t": "08:30", "detail": "Activity"}}, {{"t": "12:00", "detail": "Lunch"}}, {{"t": "14:00", "detail": "Activity"}}, {{"t": "18:00", "detail": "Evening"}}]}}
 
 
133
  ],
134
+ "spots": [{{"name": "Location", "time": "09:30-11:45", "notes": "Details"}}],
135
+ "budget": {{"transport": 500, "entrance": 200, "meals": 800, "accommodation": 1200, "activities": 600, "total": 3300}},
136
+ "permits": {{"needed": false, "notes": "Requirements", "seasonal": "Best time"}},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  "safety": {{
138
+ "registration": "Safety info",
139
+ "checkins": "Check-in procedures",
140
+ "sos": "Emergency: 1669",
141
  "contacts": {{
142
+ "ranger": {{"name": "Tourist Police", "phone": "+66-2-123-4567"}},
143
+ "hospital": {{"name": "Local Hospital", "phone": "+66-2-310-3000"}},
144
+ "police": {{"name": "Police", "phone": "1155"}}
145
  }}
146
  }}
147
  }}
148
  }}
 
 
 
 
 
 
 
 
 
 
 
 
 
149
 
150
+ Create {duration} days with realistic prices for {plan_request.budgetTier or 'mid-range'} budget, {plan_request.groupSize} people. Focus on {plan_request.theme or 'general'} activities and {', '.join(plan_request.interests) if plan_request.interests else 'sightseeing'}.
151
  """
152
 
153
  # 6. Call LLM to generate structured trip plan