Infinity-1995 commited on
Commit
85ca29e
·
verified ·
1 Parent(s): 73d4104

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -9,7 +9,6 @@ import tempfile
9
  import re
10
  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
11
  from reportlab.lib.styles import getSampleStyleSheet
12
- from reportlab.lib.pagesizes import letter
13
  import spacy
14
  from geopy.geocoders import Nominatim
15
  import folium
@@ -83,18 +82,23 @@ def extract_places_and_map(itinerary_text, city_context=None):
83
 
84
  return m._repr_html_()
85
 
86
- def generate_itinerary(mood, location, budget, days, traveller_type, current_location):
87
  mood_text = "any mood" if mood == "Any" else mood
88
  budget_text = "any budget" if budget == "Any" else budget
89
  traveller_text = "any traveller" if traveller_type == "Any" else traveller_type
90
  location_text = location if location.strip() != "" else "any destination"
91
- from_text = current_location.strip() if current_location.strip() != "" else "your city"
92
 
 
93
  prompt = (
94
- f"Create a {days}-day travel itinerary from {from_text} to {location_text}. "
95
- f"The travelers mood is {mood_text}, traveller type is {traveller_text}, "
96
  f"and the budget is {budget_text}. "
97
- f"Include daily activities, key landmarks, and meal or cultural suggestions. "
 
 
 
 
 
98
  f"Use Markdown formatting with **bold headings** for days and time slots."
99
  )
100
 
@@ -239,9 +243,9 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="teal", secondary_hue="teal")
239
  with gr.Row():
240
  mood = gr.Dropdown(MOODS, label="Mood", value="Any")
241
  location = gr.Textbox(label="Destination", placeholder="e.g., India, Japan, France (leave blank for Any)")
 
242
  with gr.Row():
243
  traveller_type = gr.Dropdown(TRAVELLER_TYPES, label="Traveller Type", value="Any")
244
- current_location = gr.Textbox(label="Current Location (From)", placeholder="e.g., Dubai, London (optional)")
245
 
246
  with gr.Row():
247
  budget = gr.Dropdown(["Low", "Medium", "High", "Any"], label="Budget", value="Any")
@@ -268,7 +272,7 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="teal", secondary_hue="teal")
268
 
269
  generate_btn.click(
270
  generate_itinerary,
271
- inputs=[mood, location, budget, days, traveller_type, current_location],
272
  outputs=[itinerary_output, image_output, map_output],
273
  show_progress=True
274
  )
@@ -280,4 +284,3 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="teal", secondary_hue="teal")
280
  )
281
 
282
  demo.launch()
283
-
 
9
  import re
10
  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
11
  from reportlab.lib.styles import getSampleStyleSheet
 
12
  import spacy
13
  from geopy.geocoders import Nominatim
14
  import folium
 
82
 
83
  return m._repr_html_()
84
 
85
+ def generate_itinerary(mood, location, budget, days, traveller_type):
86
  mood_text = "any mood" if mood == "Any" else mood
87
  budget_text = "any budget" if budget == "Any" else budget
88
  traveller_text = "any traveller" if traveller_type == "Any" else traveller_type
89
  location_text = location if location.strip() != "" else "any destination"
 
90
 
91
+ # Prompt tailored to traveller type
92
  prompt = (
93
+ f"Create a {days}-day travel itinerary for {location_text}. "
94
+ f"The traveler's mood is {mood_text}, traveller type is {traveller_text}, "
95
  f"and the budget is {budget_text}. "
96
+ f"Analyze the traveller type and tailor the itinerary accordingly:\n"
97
+ f"- Family: include kid-friendly attractions and activities.\n"
98
+ f"- Friends: include adventurous, social, and fun group activities.\n"
99
+ f"- Couple: include romantic spots, dining, and relaxation.\n"
100
+ f"- Solo: include safe, self-exploration options and easy transport.\n"
101
+ f"- Business: include short stays, meetings, and convenient travel options.\n"
102
  f"Use Markdown formatting with **bold headings** for days and time slots."
103
  )
104
 
 
243
  with gr.Row():
244
  mood = gr.Dropdown(MOODS, label="Mood", value="Any")
245
  location = gr.Textbox(label="Destination", placeholder="e.g., India, Japan, France (leave blank for Any)")
246
+
247
  with gr.Row():
248
  traveller_type = gr.Dropdown(TRAVELLER_TYPES, label="Traveller Type", value="Any")
 
249
 
250
  with gr.Row():
251
  budget = gr.Dropdown(["Low", "Medium", "High", "Any"], label="Budget", value="Any")
 
272
 
273
  generate_btn.click(
274
  generate_itinerary,
275
+ inputs=[mood, location, budget, days, traveller_type],
276
  outputs=[itinerary_output, image_output, map_output],
277
  show_progress=True
278
  )
 
284
  )
285
 
286
  demo.launch()