Spaces:
Sleeping
Sleeping
Ritvik commited on
Commit ·
835f765
1
Parent(s): b9a2939
Save local changes before pull
Browse files
app.py
CHANGED
|
@@ -1,282 +1,92 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from chatbot import respond
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 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;
|
| 123 |
-
pointer-events: none;
|
| 124 |
-
}
|
| 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 |
-
}
|
| 170 |
-
@keyframes fadeIn {
|
| 171 |
-
0% { opacity: 0; }
|
| 172 |
-
100% { opacity: 1; }
|
| 173 |
-
}
|
| 174 |
-
@keyframes ripple {
|
| 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
|
| 205 |
else:
|
| 206 |
-
response = f"
|
| 207 |
return history + [[message, response]], "" # Clears textbox
|
| 208 |
|
| 209 |
-
#
|
| 210 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
gr.Markdown(
|
| 212 |
"""
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
""",
|
| 217 |
-
elem_classes=["
|
| 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=
|
| 230 |
-
|
| 231 |
-
bubble_full_width=False,
|
| 232 |
avatar_images=(
|
| 233 |
-
"https://img.icons8.com/?size=100&id=
|
| 234 |
-
"https://img.icons8.com/?size=100&id=124350&format=png&color=
|
| 235 |
),
|
| 236 |
-
placeholder="
|
|
|
|
| 237 |
)
|
| 238 |
|
|
|
|
| 239 |
with gr.Row(variant="compact"):
|
| 240 |
textbox = gr.Textbox(
|
| 241 |
-
placeholder="
|
| 242 |
lines=1,
|
| 243 |
elem_classes=["textbox"],
|
| 244 |
autofocus=True
|
| 245 |
)
|
| 246 |
-
submit_btn = gr.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(
|
| 259 |
-
value="You are
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
visible=False
|
| 261 |
)
|
| 262 |
|
|
|
|
| 263 |
gr.Markdown(
|
| 264 |
"""
|
| 265 |
-
|
| 266 |
""",
|
| 267 |
elem_classes=["footer"]
|
| 268 |
)
|
| 269 |
|
| 270 |
# Event triggers
|
| 271 |
textbox.submit(
|
| 272 |
-
|
| 273 |
inputs=[textbox, chatbot, system_message, max_tokens],
|
| 274 |
outputs=[chatbot, textbox]
|
| 275 |
)
|
| 276 |
submit_btn.click(
|
| 277 |
-
|
| 278 |
inputs=[textbox, chatbot, system_message, max_tokens],
|
| 279 |
outputs=[chatbot, textbox]
|
| 280 |
)
|
| 281 |
|
| 282 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from chatbot import respond # Assuming this is correctly defined elsewhere
|
| 3 |
|
| 4 |
+
# Travel-themed response function with a fun twist
|
| 5 |
+
def travel_respond(message, history, system_message, max_tokens, temperature=0.7, top_p=0.95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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
response = respond(message, history, system_message, max_tokens, temperature, top_p)
|
| 7 |
if "❌" in response or "not found" in response.lower():
|
| 8 |
+
response = "🌍 Oops, let’s chart a new course! Try something like 'Flights to Rome next month' or 'Hidden gems in Thailand'."
|
| 9 |
else:
|
| 10 |
+
response = f"✈️ {response} 🌴 Ready to pack your bags? What’s your next stop?"
|
| 11 |
return history + [[message, response]], "" # Clears textbox
|
| 12 |
|
| 13 |
+
# Attractive, travel-inspired interface with highlighted Travelo
|
| 14 |
+
with gr.Blocks(
|
| 15 |
+
theme=gr.themes.Soft(primary_hue="blue", secondary_hue="teal"),
|
| 16 |
+
title="Travelo - Your Journey Starts Here",
|
| 17 |
+
css="""
|
| 18 |
+
.header { text-align: center; font-family: 'Arial', sans-serif; color: #1a3c6d; }
|
| 19 |
+
.header h1 { font-size: 3em; font-weight: bold; text-shadow: 2px 2px 4px #4682b4; }
|
| 20 |
+
.chatbot { border: 2px solid #1a3c6d; border-radius: 15px; background: #f0f8ff; }
|
| 21 |
+
.textbox { border-radius: 10px; }
|
| 22 |
+
.button { background: #1a3c6d; color: white; border-radius: 10px; font-weight: bold; }
|
| 23 |
+
.footer { text-align: center; color: #4682b4; font-size: 0.9em; margin-top: 20px; }
|
| 24 |
+
body { background: url('https://www.transparenttextures.com/patterns/paper-fibers.png'); }
|
| 25 |
+
"""
|
| 26 |
+
) as demo:
|
| 27 |
+
# Bold, highlighted Travelo header
|
| 28 |
gr.Markdown(
|
| 29 |
"""
|
| 30 |
+
# ✈️ Travelo 🌍
|
| 31 |
+
### Your Passport to Adventure Awaits!
|
| 32 |
+
Plan your dream trip with me – let’s explore the world!
|
| 33 |
""",
|
| 34 |
+
elem_classes=["header"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
+
# Chatbot with a travel flair
|
| 38 |
chatbot = gr.Chatbot(
|
| 39 |
+
height=600,
|
| 40 |
+
bubble_full_width=True,
|
|
|
|
| 41 |
avatar_images=(
|
| 42 |
+
"https://img.icons8.com/?size=100&id=124349&format=png&color=000000", # Backpack for user
|
| 43 |
+
"https://img.icons8.com/?size=100&id=124350&format=png&color=1a3c6d" # Colored airplane for Travelo
|
| 44 |
),
|
| 45 |
+
placeholder="🌴 Where’s your next adventure? Ask me anything!",
|
| 46 |
+
elem_classes=["chatbot"]
|
| 47 |
)
|
| 48 |
|
| 49 |
+
# Input area with a vibrant, compact design
|
| 50 |
with gr.Row(variant="compact"):
|
| 51 |
textbox = gr.Textbox(
|
| 52 |
+
placeholder="Dream big! (e.g., 'Best hikes in Patagonia' or 'Flights to Santorini')",
|
| 53 |
lines=1,
|
| 54 |
elem_classes=["textbox"],
|
| 55 |
autofocus=True
|
| 56 |
)
|
| 57 |
+
submit_btn = gr.Button("🌍 Explore", elem_classes=["button"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
# Hidden settings for a seamless experience
|
| 60 |
system_message = gr.Textbox(
|
| 61 |
+
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!",
|
| 62 |
+
visible=False
|
| 63 |
+
)
|
| 64 |
+
max_tokens = gr.Slider(
|
| 65 |
+
minimum=1,
|
| 66 |
+
maximum=1024,
|
| 67 |
+
value=256,
|
| 68 |
+
step=1,
|
| 69 |
visible=False
|
| 70 |
)
|
| 71 |
|
| 72 |
+
# Playful footer with a travel quote
|
| 73 |
gr.Markdown(
|
| 74 |
"""
|
| 75 |
+
🌴 *“The world is full of magic – let’s find it together!”* – Travelo LLC
|
| 76 |
""",
|
| 77 |
elem_classes=["footer"]
|
| 78 |
)
|
| 79 |
|
| 80 |
# Event triggers
|
| 81 |
textbox.submit(
|
| 82 |
+
travel_respond,
|
| 83 |
inputs=[textbox, chatbot, system_message, max_tokens],
|
| 84 |
outputs=[chatbot, textbox]
|
| 85 |
)
|
| 86 |
submit_btn.click(
|
| 87 |
+
travel_respond,
|
| 88 |
inputs=[textbox, chatbot, system_message, max_tokens],
|
| 89 |
outputs=[chatbot, textbox]
|
| 90 |
)
|
| 91 |
|
| 92 |
+
demo.launch(share=True) # Public link enabled
|