Ritvik commited on
Commit
0516d26
·
1 Parent(s): 41958d2

Save local changes before pull

Browse files
Files changed (1) hide show
  1. app.py +137 -104
app.py CHANGED
@@ -1,108 +1,122 @@
1
  import gradio as gr
2
  from chatbot import respond
3
 
4
- # Ultra-dynamic travel-themed CSS
5
  custom_css = """
6
  .gradio-container {
7
- font-family: 'Poppins', sans-serif;
8
- background: linear-gradient(45deg, #1e3c72 0%, #2a5298 50%, #87ceeb 100%);
9
  color: #ffffff;
10
- padding: 40px;
11
  min-height: 100vh;
12
  position: relative;
13
  overflow: hidden;
14
- animation: gradientShift 15s infinite ease-in-out;
15
  }
 
 
16
  .gradio-container::before {
17
  content: '';
18
  position: absolute;
19
- top: -50%;
20
- left: -50%;
21
- width: 200%;
22
- height: 200%;
23
- background: radial-gradient(circle, rgba(255, 140, 0, 0.2) 0%, transparent 70%);
24
- animation: pulseGlow 10s infinite alternate ease-in-out;
 
25
  }
26
  .gradio-container::after {
27
  content: '';
28
  position: absolute;
29
- bottom: 0;
30
- right: 0;
31
- width: 150px;
32
- height: 150px;
33
- background: url('https://img.icons8.com/?size=100&id=124350&format=png&color=000000') no-repeat center;
34
  opacity: 0.3;
35
- animation: floatPlane 8s infinite ease-in-out;
36
  }
 
 
37
  .chatbot {
38
- background: rgba(255, 255, 255, 0.25);
39
- border-radius: 25px;
40
- padding: 25px;
41
- backdrop-filter: blur(15px);
42
- box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
43
- border: 2px solid rgba(255, 140, 0, 0.5);
44
- transition: border-color 0.5s ease;
 
 
 
45
  }
46
  .chatbot:hover {
47
- border-color: #ff8c00;
 
48
  }
 
 
49
  .chatbot .message {
50
- border-radius: 20px;
51
- padding: 15px 20px;
52
- margin: 12px 0;
53
  max-width: 75%;
54
- font-size: 16px;
55
- animation: slideInMessage 0.5s ease-out;
56
  border: none !important;
 
57
  }
58
  .chatbot .message.bot {
59
- background: linear-gradient(135deg, #87ceeb 0%, #b0e0e6 100%);
60
- color: #1a2c38;
61
- box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
62
  }
63
  .chatbot .message.user {
64
- background: linear-gradient(135deg, #ff8c00 0%, #ff4500 100%);
65
- color: white;
66
  margin-left: auto;
67
- box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
68
  }
 
 
69
  .textbox {
70
- background: rgba(255, 255, 255, 0.15);
71
- border: 2px solid #b0e0e6;
72
- border-radius: 25px;
73
- color: #ffffff;
74
- padding: 15px 25px;
75
- font-size: 16px;
76
  transition: all 0.4s ease;
77
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
78
  }
79
  .textbox:focus {
80
- border-color: #ff8c00;
81
- box-shadow: 0 0 20px rgba(255, 140, 0, 0.7);
82
- background: rgba(255, 255, 255, 0.25);
83
  }
 
 
84
  .button {
85
- background: linear-gradient(135deg, #ff8c00 0%, #ff4500 100%);
86
- color: white;
87
- border-radius: 25px;
88
- padding: 15px 35px;
89
- font-size: 16px;
90
- font-weight: 600;
91
  transition: all 0.3s ease;
92
  position: relative;
93
  overflow: hidden;
94
- box-shadow: 0 4px 15px rgba(255, 140, 0, 0.3);
95
  }
96
  .button:hover {
97
- transform: translateY(-3px);
98
- box-shadow: 0 8px 25px rgba(255, 140, 0, 0.5);
99
  }
100
  .button::after {
101
  content: '';
102
  position: absolute;
103
- width: 100px;
104
- height: 100px;
105
- background: rgba(255, 255, 255, 0.3);
106
  border-radius: 50%;
107
  transform: scale(0);
108
  animation: ripple 0.6s linear;
@@ -111,40 +125,45 @@ custom_css = """
111
  .button:active::after {
112
  animation: ripple 0.6s linear;
113
  }
 
 
114
  h1 {
115
- font-size: 3.2em;
116
  text-align: center;
117
- color: #ff8c00;
118
- text-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
119
  margin-bottom: 10px;
120
- animation: bounceIn 1.5s ease-in-out;
121
  }
122
  h3 {
123
  text-align: center;
124
- color: #b0e0e6;
125
- font-size: 1.4em;
126
  margin-bottom: 30px;
127
- animation: fadeIn 2s ease-in-out;
 
128
  }
129
- @keyframes gradientShift {
130
- 0% { background-position: 0% 50%; }
131
- 50% { background-position: 100% 50%; }
132
- 100% { background-position: 0% 50%; }
 
 
133
  }
134
- @keyframes pulseGlow {
135
- 0% { transform: scale(1); opacity: 0.2; }
136
- 100% { transform: scale(1.1); opacity: 0.3; }
137
  }
138
- @keyframes floatPlane {
139
  0%, 100% { transform: translateY(0); }
140
- 50% { transform: translateY(-20px); }
141
  }
142
- @keyframes slideInMessage {
143
- 0% { opacity: 0; transform: translateY(20px); }
144
- 100% { opacity: 1; transform: translateY(0); }
145
  }
146
- @keyframes bounceIn {
147
- 0% { opacity: 0; transform: scale(0.8); }
148
  60% { opacity: 1; transform: scale(1.05); }
149
  100% { opacity: 1; transform: scale(1); }
150
  }
@@ -156,70 +175,84 @@ h3 {
156
  0% { transform: scale(0); opacity: 1; }
157
  100% { transform: scale(4); opacity: 0; }
158
  }
 
 
159
  .slider {
160
- --track-color: #ff8c00;
161
- --thumb-color: #b0e0e6;
162
  transition: all 0.3s ease;
163
  }
164
  .slider:hover {
165
- --thumb-color: #ff8c00;
166
  }
 
 
167
  .footer {
168
  text-align: center;
169
- color: #b0e0e6;
170
  font-size: 1em;
171
- margin-top: 25px;
172
  animation: fadeIn 3s ease-in-out;
 
173
  }
174
  """
175
 
176
- # Enhanced dynamic respond function
177
  def enhanced_respond(message, history, system_message, max_tokens, temperature=0.7, top_p=0.95):
178
  response = respond(message, history, system_message, max_tokens, temperature, top_p)
179
  if "❌" in response or "not found" in response.lower():
180
- 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! ✈️"
181
  else:
182
- response = f"🌍 {response} 🗺️ Where’s your next destination? Let’s soar! ✈️"
183
  return history + [[message, response]], "" # Clears textbox
184
 
185
- # Dynamic travel interface
186
  with gr.Blocks(css=custom_css) as demo:
187
  gr.Markdown(
188
  """
189
- # ✈️ Travelo - Your Cosmic Travel Guide 🌌
190
- ### Embark on unforgettable journeys with real-time travel magic!
 
 
 
 
 
 
 
 
 
191
  """,
192
  elem_classes=["title"]
193
  )
194
 
195
  chatbot = gr.Chatbot(
196
- height=600,
197
- label="Chat with Travelo",
198
  bubble_full_width=False,
199
  avatar_images=(
200
- "https://img.icons8.com/?size=100&id=98766&format=png&color=000000",
201
- "https://img.icons8.com/?size=100&id=124350&format=png&color=000000"
202
  ),
203
- placeholder="🌴 Your travel story starts here..."
204
  )
205
 
206
  with gr.Row(variant="compact"):
207
  textbox = gr.Textbox(
208
- placeholder="Dream big! (e.g., 'Sunset spots in Santorini')",
209
  lines=1,
210
  elem_classes=["textbox"],
211
  autofocus=True
212
  )
213
- submit_btn = gr.Button("✈️ Launch Adventure", elem_classes=["button"])
214
 
215
- with gr.Accordion("🌟 Travel Toolkit", open=False):
216
  max_tokens = gr.Slider(
217
  minimum=1,
218
  maximum=2048,
219
  value=512,
220
  step=1,
221
- label="Adventure Depth",
222
- info="How epic should my travel tales be?"
223
  )
224
 
225
  system_message = gr.Textbox(
@@ -229,21 +262,21 @@ with gr.Blocks(css=custom_css) as demo:
229
 
230
  gr.Markdown(
231
  """
232
- 🌠 Crafted by Travelo LLC | Explore the world, one chat at a time! ✈️
233
  """,
234
  elem_classes=["footer"]
235
  )
236
 
237
- # Event triggers without _js
238
  textbox.submit(
239
  enhanced_respond,
240
  inputs=[textbox, chatbot, system_message, max_tokens],
241
- outputs=[chatbot, textbox] # Second output clears textbox
242
  )
243
  submit_btn.click(
244
  enhanced_respond,
245
  inputs=[textbox, chatbot, system_message, max_tokens],
246
- outputs=[chatbot, textbox] # Second output clears textbox
247
  )
248
 
249
  demo.launch()
 
1
  import gradio as gr
2
  from chatbot import respond
3
 
4
+ # Ultra-unique travel-themed CSS
5
  custom_css = """
6
  .gradio-container {
7
+ font-family: 'Cinzel', serif; /* Vintage explorer font */
8
+ background: url('https://www.transparenttextures.com/patterns/old-map.png') repeat, linear-gradient(135deg, #2b2d42 0%, #8d5524 50%, #d4a017 100%); /* Map texture + earthy tones */
9
  color: #ffffff;
10
+ padding: 50px;
11
  min-height: 100vh;
12
  position: relative;
13
  overflow: hidden;
14
+ animation: windBlow 25s infinite ease-in-out;
15
  }
16
+
17
+ /* Compass and travel artifacts */
18
  .gradio-container::before {
19
  content: '';
20
  position: absolute;
21
+ top: 10%;
22
+ left: 5%;
23
+ width: 120px;
24
+ height: 120px;
25
+ background: url('https://img.icons8.com/?size=100&id=10447&format=png&color=000000') no-repeat center;
26
+ opacity: 0.4;
27
+ animation: compassSpin 20s infinite linear;
28
  }
29
  .gradio-container::after {
30
  content: '';
31
  position: absolute;
32
+ bottom: 5%;
33
+ right: 5%;
34
+ width: 100px;
35
+ height: 100px;
36
+ background: url('https://img.icons8.com/?size=100&id=98766&format=png&color=000000') no-repeat center; /* Suitcase */
37
  opacity: 0.3;
38
+ animation: suitcaseBounce 10s infinite ease-in-out;
39
  }
40
+
41
+ /* Chat container with parchment vibe */
42
  .chatbot {
43
+ background: rgba(245, 245, 220, 0.9); /* Parchment-like */
44
+ border-radius: 20px;
45
+ padding: 30px;
46
+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 0 10px rgba(139, 69, 19, 0.3);
47
+ border: 3px solid #8d5524; /* Leather-brown border */
48
+ transition: all 0.5s ease;
49
+ width: 90%;
50
+ max-width: 900px;
51
+ height: 1000px; /* Matches your increased height */
52
+ overflow-y: auto;
53
  }
54
  .chatbot:hover {
55
+ border-color: #d4a017; /* Golden highlight */
56
+ box-shadow: 0 15px 50px rgba(212, 160, 23, 0.4);
57
  }
58
+
59
+ /* Messages with travel flair */
60
  .chatbot .message {
61
+ border-radius: 15px;
62
+ padding: 20px 25px;
63
+ margin: 15px 0;
64
  max-width: 75%;
65
+ font-size: 18px;
66
+ animation: messageFade 0.6s ease-out;
67
  border: none !important;
68
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
69
  }
70
  .chatbot .message.bot {
71
+ background: linear-gradient(135deg, #87cefa 0%, #4682b4 100%); /* Ocean breeze */
72
+ color: #ffffff;
 
73
  }
74
  .chatbot .message.user {
75
+ background: linear-gradient(135deg, #deb887 0%, #cd853f 100%); /* Sandy desert */
76
+ color: #2b2d42;
77
  margin-left: auto;
 
78
  }
79
+
80
+ /* Textbox with explorer’s journal style */
81
  .textbox {
82
+ background: rgba(245, 245, 220, 0.7);
83
+ border: 3px solid #8d5524;
84
+ border-radius: 20px;
85
+ color: #2b2d42;
86
+ padding: 15px 30px;
87
+ font-size: 18px;
88
  transition: all 0.4s ease;
89
+ box-shadow: 0 3px 15px rgba(0, 0, 0, 0.2);
90
  }
91
  .textbox:focus {
92
+ border-color: #d4a017;
93
+ background: rgba(245, 245, 220, 0.9);
94
+ box-shadow: 0 0 25px rgba(212, 160, 23, 0.7);
95
  }
96
+
97
+ /* Button with adventure flair */
98
  .button {
99
+ background: linear-gradient(135deg, #d4a017 0%, #8d5524 100%); /* Gold to leather */
100
+ color: #ffffff;
101
+ border-radius: 20px;
102
+ padding: 15px 40px;
103
+ font-size: 18px;
104
+ font-weight: 700;
105
  transition: all 0.3s ease;
106
  position: relative;
107
  overflow: hidden;
108
+ box-shadow: 0 5px 20px rgba(139, 69, 19, 0.4);
109
  }
110
  .button:hover {
111
+ transform: translateY(-4px);
112
+ box-shadow: 0 10px 30px rgba(212, 160, 23, 0.6);
113
  }
114
  .button::after {
115
  content: '';
116
  position: absolute;
117
+ width: 120px;
118
+ height: 120px;
119
+ background: rgba(255, 255, 255, 0.4);
120
  border-radius: 50%;
121
  transform: scale(0);
122
  animation: ripple 0.6s linear;
 
125
  .button:active::after {
126
  animation: ripple 0.6s linear;
127
  }
128
+
129
+ /* Title and subheader with explorer’s charm */
130
  h1 {
131
+ font-size: 3.5em;
132
  text-align: center;
133
+ color: #d4a017; /* Golden */
134
+ text-shadow: 4px 4px 12px rgba(0, 0, 0, 0.5);
135
  margin-bottom: 10px;
136
+ animation: titleReveal 2s ease-in-out;
137
  }
138
  h3 {
139
  text-align: center;
140
+ color: #ffffff;
141
+ font-size: 1.6em;
142
  margin-bottom: 30px;
143
+ animation: fadeIn 2.5s ease-in-out;
144
+ font-style: italic;
145
  }
146
+
147
+ /* Animations */
148
+ @keyframes windBlow {
149
+ 0% { background-position: 0 0; }
150
+ 50% { background-position: 100px 100px; }
151
+ 100% { background-position: 0 0; }
152
  }
153
+ @keyframes compassSpin {
154
+ 0% { transform: rotate(0deg); }
155
+ 100% { transform: rotate(360deg); }
156
  }
157
+ @keyframes suitcaseBounce {
158
  0%, 100% { transform: translateY(0); }
159
+ 50% { transform: translateY(-25px); }
160
  }
161
+ @keyframes messageFade {
162
+ 0% { opacity: 0; transform: translateX(-20px); }
163
+ 100% { opacity: 1; transform: translateX(0); }
164
  }
165
+ @keyframes titleReveal {
166
+ 0% { opacity: 0; transform: scale(0.9); }
167
  60% { opacity: 1; transform: scale(1.05); }
168
  100% { opacity: 1; transform: scale(1); }
169
  }
 
175
  0% { transform: scale(0); opacity: 1; }
176
  100% { transform: scale(4); opacity: 0; }
177
  }
178
+
179
+ /* Slider with travel aesthetic */
180
  .slider {
181
+ --track-color: #8d5524;
182
+ --thumb-color: #d4a017;
183
  transition: all 0.3s ease;
184
  }
185
  .slider:hover {
186
+ --thumb-color: #ffffff;
187
  }
188
+
189
+ /* Footer */
190
  .footer {
191
  text-align: center;
192
+ color: #ffffff !important;
193
  font-size: 1em;
194
+ margin-top: 2em;
195
  animation: fadeIn 3s ease-in-out;
196
+ text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.3);
197
  }
198
  """
199
 
200
+ # Enhanced travel-themed respond function
201
  def enhanced_respond(message, history, system_message, max_tokens, temperature=0.7, top_p=0.95):
202
  response = respond(message, history, system_message, max_tokens, temperature, top_p)
203
  if "❌" in response or "not found" in response.lower():
204
+ response += "\n\n🧭 **Explorer’s Hint:** Chart a course with 'Flights from London to Tokyo in May' or 'Hidden gems in Barcelona from March 10 2025 to March 15 2025'! ✈️"
205
  else:
206
+ response = f"🗺️ {response} 🌍 Where will your compass point next, adventurer? ✈️"
207
  return history + [[message, response]], "" # Clears textbox
208
 
209
+ # Ultimate travel interface
210
  with gr.Blocks(css=custom_css) as demo:
211
  gr.Markdown(
212
  """
213
+ <div style="color: white !important;">
214
+ 🗺️ Forged by Travelo LLC | Unravel the globe’s wonders, one tale at a time! ✈️
215
+ </div>
216
+ """,
217
+ elem_classes=["footer"]
218
+ )
219
+
220
+ gr.Markdown(
221
+ """
222
+ # ✈️ Travelo - The Explorer’s Chronicle 🧭
223
+ ### Embark on Epic Quests with Your Trusty Guide!
224
  """,
225
  elem_classes=["title"]
226
  )
227
 
228
  chatbot = gr.Chatbot(
229
+ height=1000, # Kept your increased height
230
+ label="Travelo’s Logbook",
231
  bubble_full_width=False,
232
  avatar_images=(
233
+ "https://img.icons8.com/?size=100&id=98766&format=png&color=000000", # Suitcase
234
+ "https://img.icons8.com/?size=100&id=124350&format=png&color=000000" # Airplane
235
  ),
236
+ placeholder="🗺️ Begin your epic tale here, weary traveler..."
237
  )
238
 
239
  with gr.Row(variant="compact"):
240
  textbox = gr.Textbox(
241
+ placeholder="Seek your destiny! (e.g., 'Secret trails in Patagonia')",
242
  lines=1,
243
  elem_classes=["textbox"],
244
  autofocus=True
245
  )
246
+ submit_btn = gr.Button("✈️ Set Sail", elem_classes=["button"])
247
 
248
+ with gr.Accordion("🧭 Explorer’s Gear", open=False):
249
  max_tokens = gr.Slider(
250
  minimum=1,
251
  maximum=2048,
252
  value=512,
253
  step=1,
254
+ label="Legend Length",
255
+ info="How vast shall your travel saga be?"
256
  )
257
 
258
  system_message = gr.Textbox(
 
262
 
263
  gr.Markdown(
264
  """
265
+ 🗺️ Forged by Travelo LLC | Unravel the globe’s wonders, one tale at a time! ✈️
266
  """,
267
  elem_classes=["footer"]
268
  )
269
 
270
+ # Event triggers
271
  textbox.submit(
272
  enhanced_respond,
273
  inputs=[textbox, chatbot, system_message, max_tokens],
274
+ outputs=[chatbot, textbox]
275
  )
276
  submit_btn.click(
277
  enhanced_respond,
278
  inputs=[textbox, chatbot, system_message, max_tokens],
279
+ outputs=[chatbot, textbox]
280
  )
281
 
282
  demo.launch()