fix: dependency
Browse files- interface.py +9 -1
- 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[
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
-
|
| 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 |
-
|
| 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": "
|
| 137 |
"trip_plan": {{
|
| 138 |
-
"title": "
|
| 139 |
-
"date": "{plan_request.travelDates or 'Flexible
|
| 140 |
"timeline": [
|
| 141 |
-
{{"t": "08:30", "detail": "
|
| 142 |
-
{{"t": "12:00", "detail": "Lunch
|
| 143 |
-
{{"t": "14:00", "detail": "Afternoon activity"}},
|
| 144 |
-
{{"t": "18:00", "detail": "Evening activity"}}
|
| 145 |
],
|
| 146 |
-
"spots": [
|
| 147 |
-
|
| 148 |
-
|
| 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
|
| 165 |
-
"checkins": "Check-in procedures
|
| 166 |
-
"sos": "Emergency
|
| 167 |
"contacts": {{
|
| 168 |
-
"ranger": {{"name": "
|
| 169 |
-
"hospital": {{"name": "
|
| 170 |
-
"police": {{"name": "
|
| 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
|
| 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
|