Spaces:
Sleeping
Sleeping
Ritvik
commited on
Commit
·
0516d26
1
Parent(s):
41958d2
Save local changes before pull
Browse files
app.py
CHANGED
|
@@ -1,108 +1,122 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from chatbot import respond
|
| 3 |
|
| 4 |
-
# Ultra-
|
| 5 |
custom_css = """
|
| 6 |
.gradio-container {
|
| 7 |
-
font-family: '
|
| 8 |
-
background: linear-gradient(
|
| 9 |
color: #ffffff;
|
| 10 |
-
padding:
|
| 11 |
min-height: 100vh;
|
| 12 |
position: relative;
|
| 13 |
overflow: hidden;
|
| 14 |
-
animation:
|
| 15 |
}
|
|
|
|
|
|
|
| 16 |
.gradio-container::before {
|
| 17 |
content: '';
|
| 18 |
position: absolute;
|
| 19 |
-
top:
|
| 20 |
-
left:
|
| 21 |
-
width:
|
| 22 |
-
height:
|
| 23 |
-
background:
|
| 24 |
-
|
|
|
|
| 25 |
}
|
| 26 |
.gradio-container::after {
|
| 27 |
content: '';
|
| 28 |
position: absolute;
|
| 29 |
-
bottom:
|
| 30 |
-
right:
|
| 31 |
-
width:
|
| 32 |
-
height:
|
| 33 |
-
background: url('https://img.icons8.com/?size=100&id=
|
| 34 |
opacity: 0.3;
|
| 35 |
-
animation:
|
| 36 |
}
|
|
|
|
|
|
|
| 37 |
.chatbot {
|
| 38 |
-
background: rgba(
|
| 39 |
-
border-radius:
|
| 40 |
-
padding:
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
.chatbot:hover {
|
| 47 |
-
border-color: #
|
|
|
|
| 48 |
}
|
|
|
|
|
|
|
| 49 |
.chatbot .message {
|
| 50 |
-
border-radius:
|
| 51 |
-
padding:
|
| 52 |
-
margin:
|
| 53 |
max-width: 75%;
|
| 54 |
-
font-size:
|
| 55 |
-
animation:
|
| 56 |
border: none !important;
|
|
|
|
| 57 |
}
|
| 58 |
.chatbot .message.bot {
|
| 59 |
-
background: linear-gradient(135deg, #
|
| 60 |
-
color: #
|
| 61 |
-
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
|
| 62 |
}
|
| 63 |
.chatbot .message.user {
|
| 64 |
-
background: linear-gradient(135deg, #
|
| 65 |
-
color:
|
| 66 |
margin-left: auto;
|
| 67 |
-
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
|
| 68 |
}
|
|
|
|
|
|
|
| 69 |
.textbox {
|
| 70 |
-
background: rgba(
|
| 71 |
-
border:
|
| 72 |
-
border-radius:
|
| 73 |
-
color: #
|
| 74 |
-
padding: 15px
|
| 75 |
-
font-size:
|
| 76 |
transition: all 0.4s ease;
|
| 77 |
-
box-shadow: 0
|
| 78 |
}
|
| 79 |
.textbox:focus {
|
| 80 |
-
border-color: #
|
| 81 |
-
|
| 82 |
-
|
| 83 |
}
|
|
|
|
|
|
|
| 84 |
.button {
|
| 85 |
-
background: linear-gradient(135deg, #
|
| 86 |
-
color:
|
| 87 |
-
border-radius:
|
| 88 |
-
padding: 15px
|
| 89 |
-
font-size:
|
| 90 |
-
font-weight:
|
| 91 |
transition: all 0.3s ease;
|
| 92 |
position: relative;
|
| 93 |
overflow: hidden;
|
| 94 |
-
box-shadow: 0
|
| 95 |
}
|
| 96 |
.button:hover {
|
| 97 |
-
transform: translateY(-
|
| 98 |
-
box-shadow: 0
|
| 99 |
}
|
| 100 |
.button::after {
|
| 101 |
content: '';
|
| 102 |
position: absolute;
|
| 103 |
-
width:
|
| 104 |
-
height:
|
| 105 |
-
background: rgba(255, 255, 255, 0.
|
| 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.
|
| 116 |
text-align: center;
|
| 117 |
-
color: #
|
| 118 |
-
text-shadow:
|
| 119 |
margin-bottom: 10px;
|
| 120 |
-
animation:
|
| 121 |
}
|
| 122 |
h3 {
|
| 123 |
text-align: center;
|
| 124 |
-
color: #
|
| 125 |
-
font-size: 1.
|
| 126 |
margin-bottom: 30px;
|
| 127 |
-
animation: fadeIn
|
|
|
|
| 128 |
}
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
| 133 |
}
|
| 134 |
-
@keyframes
|
| 135 |
-
0% { transform:
|
| 136 |
-
100% { transform:
|
| 137 |
}
|
| 138 |
-
@keyframes
|
| 139 |
0%, 100% { transform: translateY(0); }
|
| 140 |
-
50% { transform: translateY(-
|
| 141 |
}
|
| 142 |
-
@keyframes
|
| 143 |
-
0% { opacity: 0; transform:
|
| 144 |
-
100% { opacity: 1; transform:
|
| 145 |
}
|
| 146 |
-
@keyframes
|
| 147 |
-
0% { opacity: 0; transform: scale(0.
|
| 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: #
|
| 161 |
-
--thumb-color: #
|
| 162 |
transition: all 0.3s ease;
|
| 163 |
}
|
| 164 |
.slider:hover {
|
| 165 |
-
--thumb-color: #
|
| 166 |
}
|
|
|
|
|
|
|
| 167 |
.footer {
|
| 168 |
text-align: center;
|
| 169 |
-
color: #
|
| 170 |
font-size: 1em;
|
| 171 |
-
margin-top:
|
| 172 |
animation: fadeIn 3s ease-in-out;
|
|
|
|
| 173 |
}
|
| 174 |
"""
|
| 175 |
|
| 176 |
-
# Enhanced
|
| 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
|
| 181 |
else:
|
| 182 |
-
response = f"
|
| 183 |
return history + [[message, response]], "" # Clears textbox
|
| 184 |
|
| 185 |
-
#
|
| 186 |
with gr.Blocks(css=custom_css) as demo:
|
| 187 |
gr.Markdown(
|
| 188 |
"""
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
""",
|
| 192 |
elem_classes=["title"]
|
| 193 |
)
|
| 194 |
|
| 195 |
chatbot = gr.Chatbot(
|
| 196 |
-
height=
|
| 197 |
-
label="
|
| 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="
|
| 204 |
)
|
| 205 |
|
| 206 |
with gr.Row(variant="compact"):
|
| 207 |
textbox = gr.Textbox(
|
| 208 |
-
placeholder="
|
| 209 |
lines=1,
|
| 210 |
elem_classes=["textbox"],
|
| 211 |
autofocus=True
|
| 212 |
)
|
| 213 |
-
submit_btn = gr.Button("✈️
|
| 214 |
|
| 215 |
-
with gr.Accordion("
|
| 216 |
max_tokens = gr.Slider(
|
| 217 |
minimum=1,
|
| 218 |
maximum=2048,
|
| 219 |
value=512,
|
| 220 |
step=1,
|
| 221 |
-
label="
|
| 222 |
-
info="How
|
| 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 |
-
|
| 233 |
""",
|
| 234 |
elem_classes=["footer"]
|
| 235 |
)
|
| 236 |
|
| 237 |
-
# Event triggers
|
| 238 |
textbox.submit(
|
| 239 |
enhanced_respond,
|
| 240 |
inputs=[textbox, chatbot, system_message, max_tokens],
|
| 241 |
-
outputs=[chatbot, textbox]
|
| 242 |
)
|
| 243 |
submit_btn.click(
|
| 244 |
enhanced_respond,
|
| 245 |
inputs=[textbox, chatbot, system_message, max_tokens],
|
| 246 |
-
outputs=[chatbot, 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()
|