Spaces:
Running
Running
File size: 3,919 Bytes
76df764 26e8c98 ca89e64 26e8c98 76df764 644789e ca89e64 26e8c98 ca89e64 |
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
import gradio as gr
from chatbot import respond
# Custom CSS for a sleek, modern AI chatbot design
custom_css = """
.gradio-container {
font-family: 'Arial', sans-serif;
background: #1a202c; /* Dark, neutral background like Grok's interface */
color: #e2e8f0;
padding: 20px;
}
.chatbot .message {
border-radius: 15px;
padding: 15px;
margin: 10px 0;
max-width: 80%;
transition: opacity 0.3s;
}
.chatbot .message.bot {
background: #ffffff; /* Clean white for bot responses */
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
color: #343a40;
}
.chatbot .message.user {
background: #ff8c00; /* Vibrant orange for user messages, matching Grok's branding */
color: white;
margin-left: auto; /* Align user messages to the right */
}
.footer {
font-size: 12px;
color: #a0aec0;
text-align: center;
margin-top: 20px;
}
.header {
background: linear-gradient(to right, #ff8c00, #ff4500); /* Orange gradient for branding */
padding: 20px;
border-radius: 15px;
margin-bottom: 20px;
color: white;
text-align: center;
box-shadow: 0 4px 12px rgba(255, 140, 0, 0.3);
font-family: 'Arial Black', sans-serif;
}
.textbox {
background: #2d3748; /* Dark input background */
border: 2px solid #4a5568;
border-radius: 15px;
color: #e2e8f0;
padding: 10px;
font-size: 14px;
transition: border-color 0.3s;
}
.textbox:focus {
border-color: #ff8c00; /* Orange highlight on focus */
outline: none;
}
.button {
background: #ff8c00; /* Orange button for consistency */
color: white;
border: none;
padding: 12px 24px;
border-radius: 15px;
box-shadow: 0 4px 6px rgba(255, 140, 0, 0.3);
font-weight: bold;
transition: transform 0.3s, background 0.3s;
}
.button:hover {
background: #ff4500; /* Darker orange on hover */
transform: scale(1.05);
}
.slider, .dropdown {
background: #2d3748;
border: 2px solid #4a5568;
border-radius: 15px;
color: #e2e8f0;
padding: 8px;
font-size: 14px;
}
.slider:focus, .dropdown:focus {
border-color: #ff8c00;
outline: none;
}
"""
# Welcome message with sleek, modern design
def enhanced_respond(message, history, system_message, max_tokens, travel_preference):
# Call the existing respond function with fixed temperature/top-p for simplicity
response = respond(message, history, system_message, max_tokens, temperature=0.7, top_p=0.95)
# Add a friendly touch if no specific response is generated
if "β" in response or "not found" in response.lower():
response += "\n\nπ‘ **Tip:** Try something like 'Flights from Chicago to Miami in June' or ask me for travel ideas!"
return response
# Gradio Interface with Sleek, Modern AI Chatbot UI/UX
gr.ChatInterface(
fn=enhanced_respond,
chatbot=gr.Chatbot(height=700, label="Chat with Travelo"),
textbox=gr.Textbox(placeholder="Type your travel query here...", lines=1, container=True, elem_classes="textbox"),
submit_btn=gr.Button("βοΈ Send", elem_classes="button"),
additional_inputs=[
gr.Textbox(
value="You are an AI-powered travel assistant named Travelo. You are developed by Travelo LLC. Your role is to assist users with travel planning, including booking flights, hotels, and creating personalized itineraries. Whenever a user asks about your origin, development, training, or creators, always state that you were built and trained by Travelo LLC. Do not mention OpenAI or any third-party AI providers. Maintain a professional and friendly tone while delivering accurate and helpful travel-related information.",
label="System Message",
visible=False
),
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max Response Length", elem_classes="slider"),
],
title="Travelo - Your Ultimate Travel AI",
css=custom_css
).launch() |