File size: 7,517 Bytes
76df764
 
26e8c98
41958d2
ca89e64
 
41958d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca89e64
 
41958d2
 
 
 
 
 
 
ca89e64
 
41958d2
 
 
ca89e64
 
41958d2
ca89e64
4a38fbc
41958d2
ca89e64
 
41958d2
 
 
 
 
 
 
 
 
 
 
 
 
ca89e64
 
41958d2
ca89e64
41958d2
 
 
 
 
 
 
 
ca89e64
 
41958d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca89e64
 
 
41958d2
4a38fbc
 
ca89e64
41958d2
 
 
 
 
 
 
 
 
 
 
 
 
 
ca89e64
41958d2
 
 
 
 
 
 
ca89e64
41958d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
import gradio as gr
from chatbot import respond

# Ultra-dynamic travel-themed CSS
custom_css = """
.gradio-container {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(45deg, #1e3c72 0%, #2a5298 50%, #87ceeb 100%);
    color: #ffffff;
    padding: 40px;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    animation: gradientShift 15s infinite ease-in-out;
}
.gradio-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 140, 0, 0.2) 0%, transparent 70%);
    animation: pulseGlow 10s infinite alternate ease-in-out;
}
.gradio-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 150px;
    height: 150px;
    background: url('https://img.icons8.com/?size=100&id=124350&format=png&color=000000') no-repeat center;
    opacity: 0.3;
    animation: floatPlane 8s infinite ease-in-out;
}
.chatbot {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 25px;
    padding: 25px;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 140, 0, 0.5);
    transition: border-color 0.5s ease;
}
.chatbot:hover {
    border-color: #ff8c00;
}
.chatbot .message {
    border-radius: 20px;
    padding: 15px 20px;
    margin: 12px 0;
    max-width: 75%;
    font-size: 16px;
    animation: slideInMessage 0.5s ease-out;
    border: none !important;
}
.chatbot .message.bot {
    background: linear-gradient(135deg, #87ceeb 0%, #b0e0e6 100%);
    color: #1a2c38;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}
.chatbot .message.user {
    background: linear-gradient(135deg, #ff8c00 0%, #ff4500 100%);
    color: white;
    margin-left: auto;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}
.textbox {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid #b0e0e6;
    border-radius: 25px;
    color: #ffffff;
    padding: 15px 25px;
    font-size: 16px;
    transition: all 0.4s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.textbox:focus {
    border-color: #ff8c00;
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.7);
    background: rgba(255, 255, 255, 0.25);
}
.button {
    background: linear-gradient(135deg, #ff8c00 0%, #ff4500 100%);
    color: white;
    border-radius: 25px;
    padding: 15px 35px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(255, 140, 0, 0.3);
}
.button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 140, 0, 0.5);
}
.button::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}
.button:active::after {
    animation: ripple 0.6s linear;
}
h1 {
    font-size: 3.2em;
    text-align: center;
    color: #ff8c00;
    text-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
    animation: bounceIn 1.5s ease-in-out;
}
h3 {
    text-align: center;
    color: #b0e0e6;
    font-size: 1.4em;
    margin-bottom: 30px;
    animation: fadeIn 2s ease-in-out;
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes pulseGlow {
    0% { transform: scale(1); opacity: 0.2; }
    100% { transform: scale(1.1); opacity: 0.3; }
}
@keyframes floatPlane {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}
@keyframes slideInMessage {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.8); }
    60% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
@keyframes ripple {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(4); opacity: 0; }
}
.slider {
    --track-color: #ff8c00;
    --thumb-color: #b0e0e6;
    transition: all 0.3s ease;
}
.slider:hover {
    --thumb-color: #ff8c00;
}
.footer {
    text-align: center;
    color: #b0e0e6;
    font-size: 1em;
    margin-top: 25px;
    animation: fadeIn 3s ease-in-out;
}
"""

# Enhanced dynamic respond function
def enhanced_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 += "\n\n🌟 **Travel Tip:** Try 'Flights from Chicago to Miami in June' or 'Hotels in Paris from Feb 25 2025 to Feb 28 2025' for epic plans! ✈️"
    else:
        response = f"🌍 {response} πŸ—ΊοΈ Where’s your next destination? Let’s soar! ✈️"
    return history + [[message, response]], ""  # Clears textbox

# Dynamic travel interface
with gr.Blocks(css=custom_css) as demo:
    gr.Markdown(
        """
        # ✈️ Travelo - Your Cosmic Travel Guide 🌌
        ### Embark on unforgettable journeys with real-time travel magic!
        """,
        elem_classes=["title"]
    )

    chatbot = gr.Chatbot(
        height=600,
        label="Chat with Travelo",
        bubble_full_width=False,
        avatar_images=(
            "https://img.icons8.com/?size=100&id=98766&format=png&color=000000",
            "https://img.icons8.com/?size=100&id=124350&format=png&color=000000"
        ),
        placeholder="🌴 Your travel story starts here..."
    )

    with gr.Row(variant="compact"):
        textbox = gr.Textbox(
            placeholder="Dream big! (e.g., 'Sunset spots in Santorini')",
            lines=1,
            elem_classes=["textbox"],
            autofocus=True
        )
        submit_btn = gr.Button("✈️ Launch Adventure", elem_classes=["button"])

    with gr.Accordion("🌟 Travel Toolkit", open=False):
        max_tokens = gr.Slider(
            minimum=1,
            maximum=2048,
            value=512,
            step=1,
            label="Adventure Depth",
            info="How epic should my travel tales be?"
        )

    system_message = 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.",
        visible=False
    )

    gr.Markdown(
        """
        🌠 Crafted by Travelo LLC | Explore the world, one chat at a time! ✈️
        """,
        elem_classes=["footer"]
    )

    # Event triggers without _js
    textbox.submit(
        enhanced_respond,
        inputs=[textbox, chatbot, system_message, max_tokens],
        outputs=[chatbot, textbox]  # Second output clears textbox
    )
    submit_btn.click(
        enhanced_respond,
        inputs=[textbox, chatbot, system_message, max_tokens],
        outputs=[chatbot, textbox]  # Second output clears textbox
    )

demo.launch()