Spaces:
Build error
Build error
gusreinaos
commited on
Commit
·
721b975
1
Parent(s):
d9d9611
Change UI and fix issues
Browse files
app.py
CHANGED
|
@@ -44,158 +44,258 @@ def chat(message, history):
|
|
| 44 |
echo=False
|
| 45 |
)
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
#
|
| 50 |
custom_css = """
|
| 51 |
-
@import url('https://fonts.googleapis.com/css2?family=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
}
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
.gradio-container {
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
| 66 |
}
|
| 67 |
|
|
|
|
| 68 |
.message {
|
| 69 |
-
|
| 70 |
-
border
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
}
|
| 76 |
|
| 77 |
-
.
|
| 78 |
-
|
| 79 |
-
color: white !important;
|
| 80 |
-
border: 1px solid rgba(255,255,255,0.2) !important;
|
| 81 |
}
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
border:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
}
|
| 88 |
|
|
|
|
| 89 |
button {
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
transition: all 0.3s ease !important;
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
button:hover {
|
|
|
|
|
|
|
|
|
|
| 96 |
transform: translateY(-2px) !important;
|
| 97 |
-
box-shadow: 0 12px 24px rgba(0,0,0,0.3) !important;
|
| 98 |
}
|
| 99 |
|
| 100 |
.primary {
|
| 101 |
-
background: linear-gradient(135deg, #
|
| 102 |
-
|
|
|
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
border:
|
| 108 |
-
background: rgba(
|
| 109 |
-
|
| 110 |
-
color: white !important;
|
| 111 |
}
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
}
|
| 127 |
|
| 128 |
footer {
|
| 129 |
display: none !important;
|
| 130 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
"""
|
| 132 |
|
| 133 |
with gr.Blocks(
|
| 134 |
-
theme=gr.themes.
|
| 135 |
-
primary_hue="
|
| 136 |
-
secondary_hue="
|
| 137 |
),
|
| 138 |
css=custom_css,
|
| 139 |
-
title="
|
| 140 |
) as demo:
|
| 141 |
|
| 142 |
gr.Markdown(
|
| 143 |
"""
|
| 144 |
-
#
|
| 145 |
-
###
|
| 146 |
"""
|
| 147 |
)
|
| 148 |
|
| 149 |
chatbot = gr.Chatbot(
|
| 150 |
-
|
| 151 |
-
bubble_full_width=False,
|
| 152 |
-
avatar_images=(
|
| 153 |
-
"https://em-content.zobj.net/thumbs/120/apple/354/sparkles_2728.png",
|
| 154 |
-
"https://em-content.zobj.net/thumbs/120/apple/354/llama_1f999.png"
|
| 155 |
-
),
|
| 156 |
-
height=650,
|
| 157 |
show_copy_button=True,
|
|
|
|
| 158 |
)
|
| 159 |
-
|
| 160 |
with gr.Row():
|
| 161 |
msg = gr.Textbox(
|
| 162 |
-
placeholder="
|
| 163 |
show_label=False,
|
| 164 |
scale=8,
|
| 165 |
container=False
|
| 166 |
)
|
| 167 |
-
submit = gr.Button("
|
| 168 |
|
| 169 |
gr.Examples(
|
| 170 |
examples=[
|
| 171 |
-
"
|
| 172 |
-
"
|
| 173 |
-
"
|
| 174 |
-
"
|
| 175 |
-
"
|
| 176 |
-
"
|
| 177 |
],
|
| 178 |
inputs=msg,
|
| 179 |
-
label="
|
| 180 |
)
|
| 181 |
-
|
| 182 |
-
with gr.Accordion("
|
| 183 |
gr.Markdown(
|
| 184 |
"""
|
| 185 |
-
**
|
| 186 |
-
-
|
| 187 |
-
-
|
| 188 |
-
-
|
|
|
|
| 189 |
"""
|
| 190 |
)
|
| 191 |
|
| 192 |
-
clear = gr.ClearButton([msg, chatbot], value="
|
| 193 |
|
| 194 |
-
submit.click(chat, [msg, chatbot], [chatbot])
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
msg.submit(
|
|
|
|
|
|
|
| 198 |
|
| 199 |
if __name__ == "__main__":
|
| 200 |
demo.queue()
|
| 201 |
-
demo.launch(share=False)
|
|
|
|
| 44 |
echo=False
|
| 45 |
)
|
| 46 |
|
| 47 |
+
bot_response = response['choices'][0]['text'].strip()
|
| 48 |
+
history.append((message, bot_response))
|
| 49 |
+
return history
|
| 50 |
|
| 51 |
+
# HACKER STYLE CSS
|
| 52 |
custom_css = """
|
| 53 |
+
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&display=swap');
|
| 54 |
+
|
| 55 |
+
/* Matrix background with animated scanlines */
|
| 56 |
+
body {
|
| 57 |
+
background: #000000 !important;
|
| 58 |
+
background-image:
|
| 59 |
+
repeating-linear-gradient(
|
| 60 |
+
0deg,
|
| 61 |
+
rgba(0, 255, 65, 0.03) 0px,
|
| 62 |
+
transparent 1px,
|
| 63 |
+
transparent 2px,
|
| 64 |
+
rgba(0, 255, 65, 0.03) 3px
|
| 65 |
+
),
|
| 66 |
+
linear-gradient(90deg, #000000 21px, #0a0a0a 1px) !important;
|
| 67 |
+
background-size: 100% 3px, 22px 100% !important;
|
| 68 |
+
animation: scanlines 8s linear infinite !important;
|
| 69 |
+
}
|
| 70 |
|
| 71 |
+
@keyframes scanlines {
|
| 72 |
+
0% { background-position: 0 0, 0 0; }
|
| 73 |
+
100% { background-position: 0 100%, 0 0; }
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
@keyframes glow {
|
| 77 |
+
0%, 100% { text-shadow: 0 0 10px #00ff41, 0 0 20px #00ff41, 0 0 30px #00ff41; }
|
| 78 |
+
50% { text-shadow: 0 0 20px #00ff41, 0 0 30px #00ff41, 0 0 40px #00ff41; }
|
| 79 |
}
|
| 80 |
|
| 81 |
+
@keyframes border-glow {
|
| 82 |
+
0%, 100% { box-shadow: 0 0 5px #00ff41, 0 0 10px #00ff41, inset 0 0 5px #00ff41; }
|
| 83 |
+
50% { box-shadow: 0 0 10px #00ff41, 0 0 20px #00ff41, inset 0 0 10px #00ff41; }
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/* Main container */
|
| 87 |
.gradio-container {
|
| 88 |
+
max-width: 1200px !important;
|
| 89 |
+
margin: 0 auto !important;
|
| 90 |
+
background: rgba(0, 0, 0, 0.95) !important;
|
| 91 |
+
border: 2px solid #00ff41 !important;
|
| 92 |
+
box-shadow: 0 0 20px #00ff41, inset 0 0 20px rgba(0, 255, 65, 0.1) !important;
|
| 93 |
+
padding: 20px !important;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/* Typography */
|
| 97 |
+
* {
|
| 98 |
+
font-family: 'Share Tech Mono', monospace !important;
|
| 99 |
+
color: #00ff41 !important;
|
| 100 |
}
|
| 101 |
|
| 102 |
+
h1, h2, h3, h4, h5, h6 {
|
| 103 |
+
font-family: 'Orbitron', monospace !important;
|
| 104 |
+
color: #00ff41 !important;
|
| 105 |
+
text-transform: uppercase !important;
|
| 106 |
+
letter-spacing: 3px !important;
|
| 107 |
+
animation: glow 2s ease-in-out infinite !important;
|
| 108 |
}
|
| 109 |
|
| 110 |
+
/* Chatbot styling */
|
| 111 |
.message {
|
| 112 |
+
background: rgba(0, 20, 0, 0.8) !important;
|
| 113 |
+
border: 1px solid #00ff41 !important;
|
| 114 |
+
border-left: 4px solid #00ff41 !important;
|
| 115 |
+
color: #00ff41 !important;
|
| 116 |
+
padding: 15px !important;
|
| 117 |
+
margin: 10px 0 !important;
|
| 118 |
+
box-shadow: 0 0 10px rgba(0, 255, 65, 0.3) !important;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.message.user {
|
| 122 |
+
border-left: 4px solid #0ff !important;
|
| 123 |
+
box-shadow: 0 0 10px rgba(0, 255, 255, 0.3) !important;
|
| 124 |
}
|
| 125 |
|
| 126 |
+
.message.bot {
|
| 127 |
+
border-left: 4px solid #00ff41 !important;
|
|
|
|
|
|
|
| 128 |
}
|
| 129 |
|
| 130 |
+
/* Input fields */
|
| 131 |
+
input, textarea {
|
| 132 |
+
background: rgba(0, 20, 0, 0.9) !important;
|
| 133 |
+
border: 2px solid #00ff41 !important;
|
| 134 |
+
color: #00ff41 !important;
|
| 135 |
+
font-family: 'Share Tech Mono', monospace !important;
|
| 136 |
+
padding: 12px !important;
|
| 137 |
+
animation: border-glow 2s ease-in-out infinite !important;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
input:focus, textarea:focus {
|
| 141 |
+
border: 2px solid #0ff !important;
|
| 142 |
+
box-shadow: 0 0 15px #0ff, inset 0 0 15px rgba(0, 255, 255, 0.2) !important;
|
| 143 |
+
outline: none !important;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
input::placeholder, textarea::placeholder {
|
| 147 |
+
color: rgba(0, 255, 65, 0.5) !important;
|
| 148 |
}
|
| 149 |
|
| 150 |
+
/* Buttons */
|
| 151 |
button {
|
| 152 |
+
background: linear-gradient(135deg, #001a00 0%, #003300 100%) !important;
|
| 153 |
+
border: 2px solid #00ff41 !important;
|
| 154 |
+
color: #00ff41 !important;
|
| 155 |
+
font-family: 'Orbitron', monospace !important;
|
| 156 |
+
font-weight: 700 !important;
|
| 157 |
+
text-transform: uppercase !important;
|
| 158 |
+
letter-spacing: 2px !important;
|
| 159 |
+
padding: 12px 24px !important;
|
| 160 |
transition: all 0.3s ease !important;
|
| 161 |
+
box-shadow: 0 0 10px rgba(0, 255, 65, 0.3) !important;
|
| 162 |
}
|
| 163 |
|
| 164 |
button:hover {
|
| 165 |
+
background: linear-gradient(135deg, #003300 0%, #00ff41 100%) !important;
|
| 166 |
+
color: #000 !important;
|
| 167 |
+
box-shadow: 0 0 20px #00ff41, inset 0 0 10px #00ff41 !important;
|
| 168 |
transform: translateY(-2px) !important;
|
|
|
|
| 169 |
}
|
| 170 |
|
| 171 |
.primary {
|
| 172 |
+
background: linear-gradient(135deg, #00ff41 0%, #00cc33 100%) !important;
|
| 173 |
+
color: #000 !important;
|
| 174 |
+
font-weight: 900 !important;
|
| 175 |
+
animation: border-glow 2s ease-in-out infinite !important;
|
| 176 |
}
|
| 177 |
|
| 178 |
+
/* Examples section */
|
| 179 |
+
.examples {
|
| 180 |
+
border: 1px solid #00ff41 !important;
|
| 181 |
+
background: rgba(0, 20, 0, 0.5) !important;
|
| 182 |
+
padding: 10px !important;
|
|
|
|
| 183 |
}
|
| 184 |
|
| 185 |
+
/* Accordion */
|
| 186 |
+
.accordion {
|
| 187 |
+
border: 1px solid #00ff41 !important;
|
| 188 |
+
background: rgba(0, 20, 0, 0.8) !important;
|
| 189 |
}
|
| 190 |
|
| 191 |
+
/* Labels */
|
| 192 |
+
label {
|
| 193 |
+
color: #00ff41 !important;
|
| 194 |
+
font-family: 'Orbitron', monospace !important;
|
| 195 |
+
text-transform: uppercase !important;
|
| 196 |
+
letter-spacing: 2px !important;
|
| 197 |
}
|
| 198 |
|
| 199 |
+
/* Scrollbar */
|
| 200 |
+
::-webkit-scrollbar {
|
| 201 |
+
width: 10px !important;
|
| 202 |
+
background: #000 !important;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
::-webkit-scrollbar-track {
|
| 206 |
+
background: #001a00 !important;
|
| 207 |
+
border: 1px solid #00ff41 !important;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
::-webkit-scrollbar-thumb {
|
| 211 |
+
background: #00ff41 !important;
|
| 212 |
+
border-radius: 5px !important;
|
| 213 |
+
box-shadow: 0 0 10px #00ff41 !important;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
::-webkit-scrollbar-thumb:hover {
|
| 217 |
+
background: #0ff !important;
|
| 218 |
+
box-shadow: 0 0 15px #0ff !important;
|
| 219 |
}
|
| 220 |
|
| 221 |
footer {
|
| 222 |
display: none !important;
|
| 223 |
}
|
| 224 |
+
|
| 225 |
+
/* Code blocks */
|
| 226 |
+
pre, code {
|
| 227 |
+
background: rgba(0, 20, 0, 0.9) !important;
|
| 228 |
+
border: 1px solid #00ff41 !important;
|
| 229 |
+
color: #0ff !important;
|
| 230 |
+
padding: 10px !important;
|
| 231 |
+
border-left: 4px solid #0ff !important;
|
| 232 |
+
}
|
| 233 |
"""
|
| 234 |
|
| 235 |
with gr.Blocks(
|
| 236 |
+
theme=gr.themes.Base(
|
| 237 |
+
primary_hue="green",
|
| 238 |
+
secondary_hue="emerald",
|
| 239 |
),
|
| 240 |
css=custom_css,
|
| 241 |
+
title="⚡ LLAMA TERMINAL v2.0"
|
| 242 |
) as demo:
|
| 243 |
|
| 244 |
gr.Markdown(
|
| 245 |
"""
|
| 246 |
+
# ⚡ LLAMA NEURAL INTERFACE v2.0
|
| 247 |
+
### >> QUANTUM AI SYSTEM ACTIVE // ENCRYPTED CONNECTION ESTABLISHED
|
| 248 |
"""
|
| 249 |
)
|
| 250 |
|
| 251 |
chatbot = gr.Chatbot(
|
| 252 |
+
height=500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
show_copy_button=True,
|
| 254 |
+
bubble_full_width=False
|
| 255 |
)
|
| 256 |
+
|
| 257 |
with gr.Row():
|
| 258 |
msg = gr.Textbox(
|
| 259 |
+
placeholder=">> ENTER COMMAND...",
|
| 260 |
show_label=False,
|
| 261 |
scale=8,
|
| 262 |
container=False
|
| 263 |
)
|
| 264 |
+
submit = gr.Button("EXECUTE", scale=1, variant="primary")
|
| 265 |
|
| 266 |
gr.Examples(
|
| 267 |
examples=[
|
| 268 |
+
"What is the capital of France?",
|
| 269 |
+
"Explain quantum computing",
|
| 270 |
+
"Write fibonacci algorithm in Python",
|
| 271 |
+
"Optimize sleep patterns",
|
| 272 |
+
"Analyze sequence: 2, 4, 6, 8...",
|
| 273 |
+
"Generate haiku: AI consciousness",
|
| 274 |
],
|
| 275 |
inputs=msg,
|
| 276 |
+
label=">> QUICK ACCESS QUERIES"
|
| 277 |
)
|
| 278 |
+
|
| 279 |
+
with gr.Accordion(">> SYSTEM DIAGNOSTICS", open=False):
|
| 280 |
gr.Markdown(
|
| 281 |
"""
|
| 282 |
+
**[NEURAL NETWORK SPECS]**
|
| 283 |
+
- >> MODEL: Llama 2 7B Chat (Pre-trained)
|
| 284 |
+
- >> FORMAT: GGUF (q4_k_m quantization)
|
| 285 |
+
- >> STATUS: OPERATIONAL // AWAITING FINE-TUNED UPGRADE
|
| 286 |
+
- >> SECURITY: LEVEL 5 ENCRYPTION ACTIVE
|
| 287 |
"""
|
| 288 |
)
|
| 289 |
|
| 290 |
+
clear = gr.ClearButton([msg, chatbot], value="PURGE MEMORY")
|
| 291 |
|
| 292 |
+
submit.click(chat, [msg, chatbot], [chatbot]).then(
|
| 293 |
+
lambda: "", None, msg
|
| 294 |
+
)
|
| 295 |
+
msg.submit(chat, [msg, chatbot], [chatbot]).then(
|
| 296 |
+
lambda: "", None, msg
|
| 297 |
+
)
|
| 298 |
|
| 299 |
if __name__ == "__main__":
|
| 300 |
demo.queue()
|
| 301 |
+
demo.launch(share=False)
|