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