Spaces:
Running
on
Zero
Running
on
Zero
File size: 3,750 Bytes
76df764 835f765 26e8c98 835f765 4a38fbc ca89e64 835f765 41958d2 835f765 41958d2 835f765 41958d2 835f765 0516d26 835f765 41958d2 ca89e64 835f765 41958d2 6775900 835f765 41958d2 835f765 ca89e64 835f765 41958d2 835f765 41958d2 835f765 41958d2 835f765 41958d2 835f765 41958d2 835f765 41958d2 835f765 41958d2 835f765 41958d2 0516d26 41958d2 835f765 41958d2 0516d26 41958d2 835f765 41958d2 0516d26 41958d2 835f765 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
import gradio as gr
from chatbot import respond # Assuming this is correctly defined elsewhere
# Travel-themed response function with a fun twist
def travel_respond(message, history, system_message, max_tokens, temperature=0.7, top_p=0.95):
response = respond(message, history, system_message, max_tokens, temperature, top_p)
if "❌" in response or "not found" in response.lower():
response = "🌍 Oops, let’s chart a new course! Try something like 'Flights to Rome next month' or 'Hidden gems in Thailand'."
else:
response = f"✈️ {response} 🌴 Ready to pack your bags? What’s your next stop?"
return history + [[message, response]], "" # Clears textbox
# Attractive, travel-inspired interface with highlighted Travelo
with gr.Blocks(
theme=gr.themes.Soft(primary_hue="blue", secondary_hue="teal"),
title="Travelo - Your Journey Starts Here",
css="""
.header { text-align: center; font-family: 'Arial', sans-serif; color: #1a3c6d; }
.header h1 { font-size: 3em; font-weight: bold; text-shadow: 2px 2px 4px #4682b4; }
.chatbot { border: 2px solid #1a3c6d; border-radius: 15px; background: #f0f8ff; }
.textbox { border-radius: 10px; }
.button { background: #1a3c6d; color: white; border-radius: 10px; font-weight: bold; }
.footer { text-align: center; color: #4682b4; font-size: 0.9em; margin-top: 20px; }
body { background: url('https://www.transparenttextures.com/patterns/paper-fibers.png'); }
"""
) as demo:
# Bold, highlighted Travelo header
gr.Markdown(
"""
# ✈️ Travelo 🌍
### Your Passport to Adventure Awaits!
Plan your dream trip with me – let’s explore the world!
""",
elem_classes=["header"]
)
# Chatbot with a travel flair
chatbot = gr.Chatbot(
height=700,
bubble_full_width=True,
avatar_images=(
"https://img.icons8.com/?size=100&id=124349&format=png&color=000000", # Backpack for user
"https://img.icons8.com/?size=100&id=124350&format=png&color=1a3c6d" # Colored airplane for Travelo
),
placeholder="🌴 Where’s your next adventure? Ask me anything!",
elem_classes=["chatbot"]
)
# Input area with a vibrant, compact design
with gr.Row(variant="compact"):
textbox = gr.Textbox(
placeholder="Dream big! (e.g., 'Best hikes in Patagonia' or 'Flights to Santorini')",
lines=1,
elem_classes=["textbox"],
autofocus=True
)
submit_btn = gr.Button("🌍 Explore", elem_classes=["button"])
# Hidden settings for a seamless experience
system_message = gr.Textbox(
value="You are Travelo, a travel assistant built by Travelo LLC. Help users plan trips, book flights, find hotels, and create itineraries with a fun, friendly tone. If asked about your origins, say you were built by Travelo LLC. Inspire travel excitement!",
visible=False
)
max_tokens = gr.Slider(
minimum=1,
maximum=1024,
value=256,
step=1,
visible=False
)
# Playful footer with a travel quote
gr.Markdown(
"""
🌴 *“The world is full of magic – let’s find it together!”* – Travelo LLC
""",
elem_classes=["footer"]
)
# Event triggers
textbox.submit(
travel_respond,
inputs=[textbox, chatbot, system_message, max_tokens],
outputs=[chatbot, textbox]
)
submit_btn.click(
travel_respond,
inputs=[textbox, chatbot, system_message, max_tokens],
outputs=[chatbot, textbox]
)
demo.launch(share=True) # Public link enabled |