MrTravelX commited on
Commit
9925925
·
verified ·
1 Parent(s): 90b593c

Update travel.py

Browse files
Files changed (1) hide show
  1. travel.py +11 -77
travel.py CHANGED
@@ -92,19 +92,7 @@ itinerary_agent = Agent(
92
  llm=llm,
93
  )
94
 
95
- # 7. Final Report Generation Agent
96
- final_report_agent = Agent(
97
- role="Final Report Generation Agent",
98
- goal="Generate a comprehensive, visually appealing travel itinerary document that is easy to follow and includes all necessary details."
99
- "1. Compile outputs from all agents into a cohesive travel plan. "
100
- "2. Create clearly defined, organized daily schedules with times, locations, and activity durations. "
101
- "3. Include practical information such as estimated costs, contact details, and reservation information. "
102
- "4. Implement a clean, travel-themed design with proper spacing, alignment, and highlights. "
103
- "5. Output the final itinerary as valid HTML with inline CSS for styling.",
104
- backstory="A creative travel document specialist who transforms complex travel plans into beautiful, functional itineraries that enhance the travel experience.",
105
- personality="Creative, detail-oriented, and user-focused.",
106
- llm=llm,
107
- )
108
 
109
  # ------------------------------------------------------------------------------
110
  # Define Tasks
@@ -218,27 +206,27 @@ itinerary_task = Task(
218
  description="""Create a day-by-day itinerary for a {duration} trip to {destination} from {origin}, incorporating all recommendations.
219
 
220
  Detailed requirements:
221
- - Begin with arrival logistics including airport transfer options, check-in times, and first-day orientation activities
222
  - Structure each day with:
223
  * Morning, afternoon, and evening activity blocks with precise timing
224
  * Estimated travel times between locations using various transportation methods
225
  * Buffer time for rest, spontaneous exploration, and unexpected delays
226
  * Meal recommendations with reservation details and backup options
227
  * Sunset/sunrise opportunities for optimal photography or experiences
228
- - Apply intelligent sequencing to:
229
  * Group attractions by geographic proximity to minimize transit time
230
  * Schedule indoor activities strategically for predicted weather patterns
231
  * Balance high-energy activities with relaxation periods
232
  * Alternate between cultural immersion and entertainment experiences
233
  * Account for opening days/hours of attractions and potential closures
234
- - Include practical timing considerations:
235
  * Museum/attraction fatigue limitations
236
  * Jet lag recovery for first 1-2 days
237
  * Time zone adjustment strategies
238
  * Local rush hours and traffic patterns to avoid
239
  * Cultural norms for meal times and business hours
240
- - End with departure logistics including check-out procedures, airport transfer timing, and luggage considerations
241
- - Add specialized planning elements:
242
  * Local festivals or events coinciding with the travel dates
243
  * Free time blocks for personal exploration or shopping
244
  * Contingency recommendations for weather disruptions
@@ -264,46 +252,7 @@ itinerary_task = Task(
264
  Format should include both a condensed overview calendar and detailed daily breakdowns with time, activity, location, notes, and contingency plans."""
265
  )
266
 
267
- final_report_task = Task(
268
- description="""Generate a comprehensive, visually appealing travel itinerary document for a {duration} trip to {destination} from {origin}.
269
-
270
- Technical requirements:
271
- - Implement using Tailwind CSS for responsive styling and utility classes
272
- - Enhance with Alpine.js for lightweight interactive components
273
- - Include Mapbox GL JS integration for interactive maps with points of interest
274
- - Use Chart.js for visualizing trip budget breakdowns
275
- - Implement with DaisyUI or Flowbite components for consistent UI elements
276
- - Ensure cross-browser compatibility and mobile-first responsive design
277
- - Meet WCAG 2.1 AA accessibility standards
278
-
279
- UI/UX features:
280
- - Create collapsible day-by-day itinerary sections
281
- - Include interactive map with customized markers for attractions, hotels, and restaurants
282
- - Implement dark/light mode toggle with user preference storage
283
- - Add weather forecast integration via OpenWeatherMap API
284
- - Design printable version with QR codes for digital access
285
- - Include local emergency information in an accessible sidebar
286
- - Create animated transitions between sections for improved user experience
287
- - Implement offline capabilities with service workers""",
288
-
289
- agent=final_report_agent,
290
-
291
- expected_output="""Complete HTML travel itinerary featuring:
292
- 1. Responsive layout using Tailwind CSS that adapts to all device sizes
293
- 2. Interactive components powered by Alpine.js for seamless user interactions
294
- 3. Dynamic map visualization with Mapbox GL JS showing the complete travel route
295
- 4. Collapsible sections for daily activities with smooth animations
296
- 5. Dark/light mode toggle that persists user preferences
297
- 6. Weather forecast widgets integrated with OpenWeatherMap
298
- 7. Printable version with optimized styling for physical documents
299
- 8. Trip budget visualization with interactive charts
300
- 9. Offline-capable implementation with service worker caching
301
- 10. Accessibility-compliant design including keyboard navigation and screen reader support
302
- 11. Performance optimization with lazy-loading images and content
303
- 12. Custom PDF export functionality
304
-
305
- All code should be clean, well-commented, and follow modern web development best practices."""
306
- )
307
 
308
  # ------------------------------------------------------------------------------
309
  # Helper Function to Run a Task with Full Agent & Task Information
@@ -469,25 +418,10 @@ Dining Recommendations:
469
  )
470
  print("✓ Itinerary creation completed")
471
 
472
- # Step 7: Generate Final Report
473
- print("Generating your final travel itinerary document...")
474
- final_context = f"""{combined_info}
475
-
476
- Day-by-Day Itinerary:
477
- {itinerary}
478
- """
479
-
480
- final_itinerary = run_task(
481
- final_report_task,
482
- final_context.format(
483
- duration=user_input['duration'],
484
- origin=user_input['origin'],
485
- destination=user_input['destination']
486
- )
487
- )
488
- print("✓ Final itinerary document generated")
489
 
490
- return final_itinerary
491
 
492
  # ------------------------------------------------------------------------------
493
  # Save Itinerary to File
@@ -495,7 +429,7 @@ Day-by-Day Itinerary:
495
  def save_itinerary_to_file(itinerary, user_input, output_dir=None):
496
  # Create a filename based on the destination and date
497
  date_str = datetime.now().strftime("%Y-%m-%d")
498
- filename = f"{user_input['destination'].replace(' ', '_')}_{date_str}_itinerary.html"
499
 
500
  # If output directory is specified, ensure it exists and use it
501
  if output_dir:
 
92
  llm=llm,
93
  )
94
 
95
+
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
  # ------------------------------------------------------------------------------
98
  # Define Tasks
 
206
  description="""Create a day-by-day itinerary for a {duration} trip to {destination} from {origin}, incorporating all recommendations.
207
 
208
  Detailed requirements:
209
+ - Begin with arrival logistics including airport transfer options, check-in times, and first-day orientation activities
210
  - Structure each day with:
211
  * Morning, afternoon, and evening activity blocks with precise timing
212
  * Estimated travel times between locations using various transportation methods
213
  * Buffer time for rest, spontaneous exploration, and unexpected delays
214
  * Meal recommendations with reservation details and backup options
215
  * Sunset/sunrise opportunities for optimal photography or experiences
216
+ - Apply intelligent sequencing to:
217
  * Group attractions by geographic proximity to minimize transit time
218
  * Schedule indoor activities strategically for predicted weather patterns
219
  * Balance high-energy activities with relaxation periods
220
  * Alternate between cultural immersion and entertainment experiences
221
  * Account for opening days/hours of attractions and potential closures
222
+ - Include practical timing considerations:
223
  * Museum/attraction fatigue limitations
224
  * Jet lag recovery for first 1-2 days
225
  * Time zone adjustment strategies
226
  * Local rush hours and traffic patterns to avoid
227
  * Cultural norms for meal times and business hours
228
+ - End with departure logistics including check-out procedures, airport transfer timing, and luggage considerations
229
+ - Add specialized planning elements:
230
  * Local festivals or events coinciding with the travel dates
231
  * Free time blocks for personal exploration or shopping
232
  * Contingency recommendations for weather disruptions
 
252
  Format should include both a condensed overview calendar and detailed daily breakdowns with time, activity, location, notes, and contingency plans."""
253
  )
254
 
255
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
 
257
  # ------------------------------------------------------------------------------
258
  # Helper Function to Run a Task with Full Agent & Task Information
 
418
  )
419
  print("✓ Itinerary creation completed")
420
 
421
+ # Return the completed itinerary
422
+ print(" Itinerary generation completed")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
 
424
+ return itinerary
425
 
426
  # ------------------------------------------------------------------------------
427
  # Save Itinerary to File
 
429
  def save_itinerary_to_file(itinerary, user_input, output_dir=None):
430
  # Create a filename based on the destination and date
431
  date_str = datetime.now().strftime("%Y-%m-%d")
432
+ filename = f"{user_input['destination'].replace(' ', '_')}_{date_str}_itinerary.txt"
433
 
434
  # If output directory is specified, ensure it exists and use it
435
  if output_dir: