Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,6 +28,15 @@ MOODS = [
|
|
| 28 |
"Beach & Island",
|
| 29 |
"Any"
|
| 30 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
MOOD_IMAGES = {
|
| 33 |
"Adventure": "images/adventure.png",
|
|
@@ -75,10 +84,21 @@ def extract_places_and_map(itinerary_text, city_context=None):
|
|
| 75 |
|
| 76 |
return m._repr_html_()
|
| 77 |
|
| 78 |
-
def generate_itinerary(mood, location, budget, days):
|
| 79 |
mood_text = "any mood" if mood == "Any" else mood
|
| 80 |
budget_text = "any budget" if budget == "Any" else budget
|
|
|
|
| 81 |
location_text = location if location.strip() != "" else "any destination"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
prompt = (
|
| 84 |
f"Create a {days}-day travel itinerary to {location_text}. "
|
|
@@ -227,6 +247,10 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="teal", secondary_hue="teal")
|
|
| 227 |
with gr.Row():
|
| 228 |
mood = gr.Dropdown(MOODS, label="Mood", value="Any")
|
| 229 |
location = gr.Textbox(label="Destination", placeholder="e.g., India, Japan, France (leave blank for Any)")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
with gr.Row():
|
| 232 |
budget = gr.Dropdown(["Low", "Medium", "High", "Any"], label="Budget", value="Any")
|
|
@@ -253,11 +277,12 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="teal", secondary_hue="teal")
|
|
| 253 |
|
| 254 |
generate_btn.click(
|
| 255 |
generate_itinerary,
|
| 256 |
-
inputs=[mood, location, budget, days],
|
| 257 |
outputs=[itinerary_output, image_output, map_output],
|
| 258 |
show_progress=True
|
| 259 |
)
|
| 260 |
|
|
|
|
| 261 |
download_btn.click(
|
| 262 |
generate_pdf,
|
| 263 |
inputs=[itinerary_output],
|
|
|
|
| 28 |
"Beach & Island",
|
| 29 |
"Any"
|
| 30 |
]
|
| 31 |
+
TRAVELLER_TYPES = [
|
| 32 |
+
"Solo",
|
| 33 |
+
"Couple",
|
| 34 |
+
"Family",
|
| 35 |
+
"Friends",
|
| 36 |
+
"Business",
|
| 37 |
+
"Any"
|
| 38 |
+
]
|
| 39 |
+
|
| 40 |
|
| 41 |
MOOD_IMAGES = {
|
| 42 |
"Adventure": "images/adventure.png",
|
|
|
|
| 84 |
|
| 85 |
return m._repr_html_()
|
| 86 |
|
| 87 |
+
def generate_itinerary(mood, location, budget, days, traveller_type, current_location):
|
| 88 |
mood_text = "any mood" if mood == "Any" else mood
|
| 89 |
budget_text = "any budget" if budget == "Any" else budget
|
| 90 |
+
traveller_text = "any traveller" if traveller_type == "Any" else traveller_type
|
| 91 |
location_text = location if location.strip() != "" else "any destination"
|
| 92 |
+
from_text = current_location.strip() if current_location.strip() != "" else "your city"
|
| 93 |
+
|
| 94 |
+
prompt = (
|
| 95 |
+
f"Create a {days}-day travel itinerary from {from_text} to {location_text}. "
|
| 96 |
+
f"The traveler’s mood is {mood_text}, traveller type is {traveller_text}, "
|
| 97 |
+
f"and the budget is {budget_text}. "
|
| 98 |
+
f"Include daily activities, key landmarks, and meal or cultural suggestions. "
|
| 99 |
+
f"Use Markdown formatting with **bold headings** for days and time slots."
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
|
| 103 |
prompt = (
|
| 104 |
f"Create a {days}-day travel itinerary to {location_text}. "
|
|
|
|
| 247 |
with gr.Row():
|
| 248 |
mood = gr.Dropdown(MOODS, label="Mood", value="Any")
|
| 249 |
location = gr.Textbox(label="Destination", placeholder="e.g., India, Japan, France (leave blank for Any)")
|
| 250 |
+
with gr.Row():
|
| 251 |
+
traveller_type = gr.Dropdown(TRAVELLER_TYPES, label="Traveller Type", value="Any")
|
| 252 |
+
current_location = gr.Textbox(label="Current Location (From)", placeholder="e.g., Dubai, London (optional)")
|
| 253 |
+
|
| 254 |
|
| 255 |
with gr.Row():
|
| 256 |
budget = gr.Dropdown(["Low", "Medium", "High", "Any"], label="Budget", value="Any")
|
|
|
|
| 277 |
|
| 278 |
generate_btn.click(
|
| 279 |
generate_itinerary,
|
| 280 |
+
inputs=[mood, location, budget, days, traveller_type, current_location],
|
| 281 |
outputs=[itinerary_output, image_output, map_output],
|
| 282 |
show_progress=True
|
| 283 |
)
|
| 284 |
|
| 285 |
+
|
| 286 |
download_btn.click(
|
| 287 |
generate_pdf,
|
| 288 |
inputs=[itinerary_output],
|