DarkNeuron-AI commited on
Commit
a5cd7c8
Β·
verified Β·
1 Parent(s): 925004f

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +626 -0
main.py ADDED
@@ -0,0 +1,626 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!pip install diffusers transformers accelerate safetensors torch torchvision pillow --quiet gradio
2
+
3
+ # πŸš€ Gradio Chatbot Space for DarkNeuron Chat v1.1
4
+ # Author: @Madara369Uchiha | Works perfectly on Hugging Face Spaces
5
+
6
+ import gradio as gr
7
+ import torch
8
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
9
+
10
+ # πŸ”§ Model Setup
11
+ model_name = "DarkNeuron-AI/darkneuron-chat-v1.1"
12
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
13
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32)
14
+ device = 0 if torch.cuda.is_available() else -1
15
+
16
+ # βš™οΈ Create Chat Pipeline
17
+ chatbot = pipeline(
18
+ "text-generation",
19
+ model=model,
20
+ tokenizer=tokenizer,
21
+ device=device,
22
+ return_full_text=False
23
+ )
24
+
25
+ # 🧠 Chat Function
26
+ def chat_fn(message, history):
27
+ history_text = ""
28
+ for user, bot in history:
29
+ history_text += f"User: {user}\nBot: {bot}\n"
30
+ prompt = f"{history_text}User: {message}\nBot:"
31
+
32
+ response = chatbot(
33
+ prompt,
34
+ max_length=200,
35
+ do_sample=True,
36
+ temperature=0.7,
37
+ top_p=0.9,
38
+ num_return_sequences=1
39
+ )[0]["generated_text"]
40
+
41
+ return response.strip()
42
+
43
+ # 🎨 Ultra Premium DarkNeuron Chat v1.1
44
+ # Perfect Dark Theme - No Tint - Premium Look
45
+
46
+ # ... (Your chat_fn code stays here) ...
47
+
48
+ # 🎨 Perfect Dark Premium CSS - NO TINT
49
+ custom_css = """
50
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
51
+ @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');
52
+
53
+ * {
54
+ margin: 0;
55
+ padding: 0;
56
+ box-sizing: border-box;
57
+ }
58
+
59
+ /* Ultra Dark Background */
60
+ .gradio-container {
61
+ background: #0d1117 !important;
62
+ min-height: 100vh;
63
+ }
64
+
65
+ /* Hide ALL Scrollbars */
66
+ ::-webkit-scrollbar { display: none !important; }
67
+ * {
68
+ scrollbar-width: none !important;
69
+ -ms-overflow-style: none !important;
70
+ }
71
+
72
+ /* Premium Glass Header */
73
+ .glass-header {
74
+ background: rgba(13, 17, 23, 0.8);
75
+ backdrop-filter: blur(30px);
76
+ border: 1px solid rgba(139, 122, 255, 0.3);
77
+ border-radius: 24px;
78
+ padding: 1.5rem 2rem;
79
+ margin-bottom: 2rem;
80
+ box-shadow: 0 8px 40px rgba(139, 122, 255, 0.2);
81
+ }
82
+
83
+ .logo-container {
84
+ display: flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+ gap: 1rem;
88
+ margin-bottom: 0.5rem;
89
+ }
90
+
91
+ .logo-icon {
92
+ font-size: 3rem;
93
+ color: #8b7aff;
94
+ filter: drop-shadow(0 0 25px rgba(139, 122, 255, 0.7));
95
+ animation: pulse 2s ease-in-out infinite;
96
+ }
97
+
98
+ @keyframes pulse {
99
+ 0%, 100% {
100
+ transform: scale(1);
101
+ filter: drop-shadow(0 0 25px rgba(139, 122, 255, 0.7));
102
+ }
103
+ 50% {
104
+ transform: scale(1.15);
105
+ filter: drop-shadow(0 0 40px rgba(139, 122, 255, 1));
106
+ }
107
+ }
108
+
109
+ .logo-text {
110
+ font-size: 2.3rem;
111
+ font-weight: 900;
112
+ background: linear-gradient(135deg, #8b7aff 0%, #b794f6 50%, #da92ff 100%);
113
+ -webkit-background-clip: text;
114
+ -webkit-text-fill-color: transparent;
115
+ }
116
+
117
+ .version-tag {
118
+ display: inline-flex;
119
+ align-items: center;
120
+ gap: 0.5rem;
121
+ padding: 0.5rem 1.3rem;
122
+ background: rgba(139, 122, 255, 0.2);
123
+ border: 1px solid rgba(139, 122, 255, 0.4);
124
+ border-radius: 30px;
125
+ font-size: 0.9rem;
126
+ color: #c4b5ff;
127
+ box-shadow: 0 4px 20px rgba(139, 122, 255, 0.25);
128
+ }
129
+
130
+ /* Hero Section */
131
+ .hero-section {
132
+ text-align: center;
133
+ padding: 3rem 0 4rem;
134
+ }
135
+
136
+ .hero-title {
137
+ font-size: 4.5rem;
138
+ font-weight: 900;
139
+ color: #ffffff;
140
+ margin-bottom: 1.5rem;
141
+ text-shadow: 0 0 80px rgba(139, 122, 255, 0.8);
142
+ letter-spacing: -0.02em;
143
+ }
144
+
145
+ .hero-subtitle {
146
+ font-size: 1.4rem;
147
+ color: rgba(255, 255, 255, 0.75);
148
+ max-width: 800px;
149
+ margin: 0 auto 2rem;
150
+ line-height: 1.8;
151
+ }
152
+
153
+ /* Feature Cards - PURE DARK, NO TINT */
154
+ .feature-glass-card {
155
+ background: rgba(139, 122, 255, 0.25) !important;
156
+ border: 1px solid rgba(139, 122, 255, 0.25) !important;
157
+ border-radius: 24px !important;
158
+ padding: 3rem 2.5rem !important;
159
+ transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
160
+ box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6) !important;
161
+ position: relative;
162
+ overflow: hidden;
163
+ }
164
+
165
+ .feature-glass-card::after {
166
+ content: '';
167
+ position: absolute;
168
+ top: 0;
169
+ left: 0;
170
+ right: 0;
171
+ bottom: 0;
172
+ background: transparent !important;
173
+ pointer-events: none;
174
+ }
175
+
176
+ .feature-glass-card::before {
177
+ content: '';
178
+ position: absolute;
179
+ top: 0;
180
+ left: -100%;
181
+ width: 100%;
182
+ height: 100%;
183
+ background: linear-gradient(90deg, transparent, rgba(139, 122, 255, 0.08), transparent);
184
+ transition: left 0.8s ease;
185
+ }
186
+
187
+ .feature-glass-card:hover::before {
188
+ left: 100%;
189
+ }
190
+
191
+ .feature-glass-card:hover {
192
+ transform: translateY(-12px) scale(1.03);
193
+ background: #1c2128 !important;
194
+ border-color: rgba(139, 122, 255, 0.5) !important;
195
+ box-shadow: 0 20px 60px rgba(139, 122, 255, 0.4) !important;
196
+ }
197
+
198
+ .icon-box {
199
+ background: transparent !important;
200
+ border: none !important;
201
+ padding: 1.5rem !important;
202
+ border-radius: 16px !important;
203
+ margin-bottom: 2rem !important;
204
+ display: inline-block;
205
+ }
206
+
207
+ .icon-wrapper {
208
+ font-size: 4.5rem;
209
+ display: inline-block;
210
+ transition: all 0.6s ease;
211
+ filter: drop-shadow(0 8px 20px rgba(139, 122, 255, 0.4));
212
+ }
213
+
214
+ .feature-glass-card:hover .icon-wrapper {
215
+ transform: rotateY(360deg) scale(1.2);
216
+ filter: drop-shadow(0 12px 30px rgba(139, 122, 255, 0.7));
217
+ }
218
+
219
+ .feature-title-glass {
220
+ font-size: 1.6rem;
221
+ font-weight: 800;
222
+ color: #ffffff;
223
+ margin-bottom: 1rem;
224
+ letter-spacing: -0.01em;
225
+ }
226
+
227
+ .feature-desc-glass {
228
+ color: rgba(255, 255, 255, 0.7);
229
+ line-height: 1.8;
230
+ font-size: 1rem;
231
+ }
232
+
233
+ /* Chat Container */
234
+ .chat-container-glass {
235
+ background: #161b22;
236
+ border: 2px solid #4ade80;
237
+ border-radius: 24px;
238
+ padding: 2rem;
239
+ box-shadow: 0 0 50px rgba(74, 222, 128, 0.25);
240
+ }
241
+
242
+ /* Settings Sidebar */
243
+ .settings-sidebar {
244
+ background: #161b22;
245
+ border: 1px solid rgba(139, 122, 255, 0.25);
246
+ border-radius: 20px;
247
+ padding: 2rem;
248
+ box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
249
+ }
250
+
251
+ .settings-header {
252
+ font-size: 1.2rem;
253
+ font-weight: 700;
254
+ color: #b794f6;
255
+ margin-bottom: 1.5rem;
256
+ display: flex;
257
+ align-items: center;
258
+ gap: 0.5rem;
259
+ padding-bottom: 1rem;
260
+ border-bottom: 1px solid rgba(139, 122, 255, 0.2);
261
+ }
262
+
263
+ /* Sliders & Inputs */
264
+ label {
265
+ color: rgba(255, 255, 255, 0.8) !important;
266
+ font-weight: 600 !important;
267
+ font-size: 0.9rem !important;
268
+ }
269
+
270
+ input[type="range"] {
271
+ -webkit-appearance: none;
272
+ width: 100%;
273
+ height: 6px;
274
+ border-radius: 5px;
275
+ background: rgba(255, 255, 255, 0.2) !important;
276
+ outline: none;
277
+ }
278
+
279
+ input[type="range"]::-webkit-slider-thumb {
280
+ -webkit-appearance: none;
281
+ appearance: none;
282
+ width: 18px;
283
+ height: 18px;
284
+ border-radius: 50%;
285
+ background: linear-gradient(135deg, #8b7aff, #b794f6);
286
+ cursor: pointer;
287
+ box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
288
+ }
289
+
290
+ input[type="number"],
291
+ textarea {
292
+ background: #0d1117 !important;
293
+ border: 1px solid rgba(255, 255, 255, 0.3) !important;
294
+ border-radius: 10px !important;
295
+ color: white !important;
296
+ padding: 0.7rem !important;
297
+ }
298
+
299
+ /* Chatbot */
300
+ .chatbot {
301
+ border: none !important;
302
+ background: transparent !important;
303
+ }
304
+
305
+ /* Input Box */
306
+ .input-glass-box input,
307
+ .input-glass-box textarea {
308
+ background: #0d1117 !important;
309
+ border: 1px solid rgba(139, 122, 255, 0.3) !important;
310
+ border-radius: 14px !important;
311
+ padding: 1rem 1.3rem !important;
312
+ color: rgba(255, 255, 255, 0.95) !important;
313
+ font-size: 1rem !important;
314
+ }
315
+
316
+ .input-glass-box input::placeholder,
317
+ .input-glass-box textarea::placeholder {
318
+ color: rgba(255, 255, 255, 0.5) !important;
319
+ }
320
+
321
+ .input-glass-box input:focus,
322
+ .input-glass-box textarea:focus {
323
+ background: #0d1117 !important;
324
+ border-color: rgba(139, 122, 255, 0.6) !important;
325
+ box-shadow: 0 0 25px rgba(139, 122, 255, 0.4) !important;
326
+ outline: none !important;
327
+ }
328
+
329
+ /* Buttons */
330
+ button {
331
+ border-radius: 14px !important;
332
+ font-weight: 700 !important;
333
+ padding: 0.9rem 2rem !important;
334
+ transition: all 0.4s ease !important;
335
+ font-size: 1rem !important;
336
+ }
337
+
338
+ .primary-btn {
339
+ background: linear-gradient(135deg, #8b7aff 0%, #b794f6 100%) !important;
340
+ border: none !important;
341
+ color: white !important;
342
+ box-shadow: 0 6px 25px rgba(139, 122, 255, 0.5);
343
+ }
344
+
345
+ .primary-btn:hover {
346
+ transform: translateY(-4px) scale(1.05) !important;
347
+ box-shadow: 0 15px 45px rgba(139, 122, 255, 0.7) !important;
348
+ }
349
+
350
+ .secondary-btn {
351
+ background: #0d1117 !important;
352
+ border: 1px solid rgba(139, 122, 255, 0.35) !important;
353
+ color: rgba(255, 255, 255, 0.95) !important;
354
+ }
355
+
356
+ .secondary-btn:hover {
357
+ background: #161b22 !important;
358
+ transform: translateY(-4px) !important;
359
+ box-shadow: 0 12px 35px rgba(139, 122, 255, 0.35) !important;
360
+ }
361
+
362
+ /* Section Headers */
363
+ .section-header-glass {
364
+ text-align: center;
365
+ font-size: 3rem;
366
+ font-weight: 900;
367
+ background: linear-gradient(135deg, #8b7aff, #b794f6, #da92ff);
368
+ -webkit-background-clip: text;
369
+ -webkit-text-fill-color: transparent;
370
+ margin: 5rem 0 3.5rem;
371
+ letter-spacing: -0.02em;
372
+ }
373
+
374
+ .section-header-glass::after {
375
+ content: '';
376
+ display: block;
377
+ width: 120px;
378
+ height: 5px;
379
+ background: linear-gradient(90deg, #8b7aff, #b794f6);
380
+ margin: 1.3rem auto 0;
381
+ border-radius: 3px;
382
+ }
383
+
384
+ /* Footer */
385
+ .footer-glass {
386
+ background: rgba(13, 17, 23, 0.8);
387
+ backdrop-filter: blur(20px);
388
+ border-top: 1px solid rgba(139, 122, 255, 0.25);
389
+ padding: 3rem;
390
+ margin-top: 6rem;
391
+ text-align: center;
392
+ color: rgba(255, 255, 255, 0.65);
393
+ }
394
+
395
+ /* Floating Animation */
396
+ @keyframes float {
397
+ 0%, 100% { transform: translateY(0px); }
398
+ 50% { transform: translateY(-20px); }
399
+ }
400
+
401
+ .floating {
402
+ animation: float 3s ease-in-out infinite;
403
+ }
404
+
405
+ /* Responsive */
406
+ @media (max-width: 768px) {
407
+ .hero-title { font-size: 2.5rem; }
408
+ .hero-subtitle { font-size: 1.1rem; }
409
+ .feature-glass-card { padding: 2rem !important; }
410
+ }
411
+ """
412
+
413
+ # 🎯 Ultra Dark Theme
414
+ custom_theme = gr.themes.Soft(
415
+ primary_hue="purple",
416
+ secondary_hue="blue",
417
+ neutral_hue="slate",
418
+ font=gr.themes.GoogleFont("Inter"),
419
+ ).set(
420
+ body_background_fill="#0d1117",
421
+ block_background_fill="#161b22",
422
+ input_background_fill="#0d1117",
423
+ )
424
+
425
+ # πŸš€ Build Interface
426
+ with gr.Blocks(theme=custom_theme, css=custom_css, title="DarkNeuron Chat v1.1") as demo:
427
+
428
+ # 🌟 Header
429
+ with gr.Column(elem_classes=["glass-header"]):
430
+ gr.HTML("""
431
+ <div class="logo-container">
432
+ <i class="fas fa-brain logo-icon floating"></i>
433
+ <span class="logo-text">DarkNeuron</span>
434
+ </div>
435
+ <div style="text-align: center;">
436
+ <span class="version-tag">
437
+ <i class="fas fa-sparkles"></i>
438
+ v1.1 Ultra Premium
439
+ </span>
440
+ </div>
441
+ """)
442
+
443
+ # 🎯 Hero
444
+ with gr.Column(elem_classes=["hero-section"]):
445
+ gr.HTML("""
446
+ <h1 class="hero-title">Welcome to DarkNeuron</h1>
447
+ <p class="hero-subtitle">Experience the pinnacle of AI conversation with advanced controls, stunning ultra-dark visuals, and blazing-fast performance.</p>
448
+ """)
449
+
450
+ # πŸ’¬ Chat Interface with Settings Sidebar
451
+ with gr.Row():
452
+ # βš™οΈ Settings Sidebar (Left)
453
+ with gr.Column(scale=2, elem_classes=["settings-sidebar"]):
454
+ gr.HTML('<div class="settings-header"><i class="fas fa-sliders"></i> Advanced Settings</div>')
455
+
456
+ temperature = gr.Slider(
457
+ minimum=0.1, maximum=2.0, value=0.7, step=0.1,
458
+ label="🌑️ Temperature",
459
+ info="Creativity level"
460
+ )
461
+
462
+ top_p = gr.Slider(
463
+ minimum=0.1, maximum=1.0, value=0.9, step=0.05,
464
+ label="🎯 Top P",
465
+ info="Sampling threshold"
466
+ )
467
+
468
+ max_tokens = gr.Slider(
469
+ minimum=50, maximum=2048, value=200, step=50,
470
+ label="πŸ“ Max Tokens",
471
+ info="Response length"
472
+ )
473
+
474
+ top_k = gr.Slider(
475
+ minimum=1, maximum=100, value=50, step=1,
476
+ label="πŸ”’ Top K",
477
+ info="Vocabulary limit"
478
+ )
479
+
480
+ system_prompt = gr.Textbox(
481
+ label="πŸ’¬ System Prompt",
482
+ placeholder="You are a helpful AI assistant...",
483
+ lines=4,
484
+ value="You are DarkNeuron, a helpful and intelligent AI assistant."
485
+ )
486
+
487
+ # πŸ’¬ Chat Area (Center/Right)
488
+ with gr.Column(scale=5, elem_classes=["chat-container-glass"]):
489
+ chatbot_ui = gr.Chatbot(
490
+ label="",
491
+ height=600,
492
+ show_copy_button=True,
493
+ show_label=False,
494
+ avatar_images=(
495
+ "https://api.dicebear.com/7.x/avataaars/svg?seed=User&backgroundColor=8b7aff",
496
+ "https://api.dicebear.com/7.x/bottts/svg?seed=DarkNeuron&backgroundColor=b794f6"
497
+ ),
498
+ bubble_full_width=False,
499
+ )
500
+
501
+ with gr.Row():
502
+ with gr.Column(scale=6, elem_classes=["input-glass-box"]):
503
+ chat_input = gr.Textbox(
504
+ placeholder="Type your message here...",
505
+ show_label=False,
506
+ container=False,
507
+ max_lines=1,
508
+ )
509
+ submit_btn = gr.Button("πŸš€ Send", scale=1, elem_classes=["primary-btn"])
510
+
511
+ with gr.Row():
512
+ clear_btn = gr.Button("πŸ—‘οΈ Clear", scale=1, elem_classes=["secondary-btn"])
513
+ regenerate_btn = gr.Button("πŸ”„ Regenerate", scale=1, elem_classes=["secondary-btn"])
514
+ export_btn = gr.Button("πŸ’Ύ Export", scale=1, elem_classes=["secondary-btn"])
515
+
516
+ # ✨ Features - NO TINT
517
+ gr.HTML('<h2 class="section-header-glass">Powerful Features</h2>')
518
+
519
+ with gr.Row(equal_height=True):
520
+ with gr.Column(scale=1):
521
+ with gr.Group(elem_classes=["feature-glass-card"]):
522
+ gr.HTML("""
523
+ <div class="icon-box">
524
+ <div class="icon-wrapper">
525
+ <i class="fas fa-bolt" style="color: #fbbf24;"></i>
526
+ </div>
527
+ </div>
528
+ <div class="feature-title-glass">Lightning Fast</div>
529
+ <div class="feature-desc-glass">Real-time streaming with token-by-token generation for instant, natural conversations.</div>
530
+ """)
531
+
532
+ with gr.Column(scale=1):
533
+ with gr.Group(elem_classes=["feature-glass-card"]):
534
+ gr.HTML("""
535
+ <div class="icon-box">
536
+ <div class="icon-wrapper">
537
+ <i class="fas fa-shield-halved" style="color: #4ade80;"></i>
538
+ </div>
539
+ </div>
540
+ <div class="feature-title-glass">Private & Secure</div>
541
+ <div class="feature-desc-glass">Enterprise-grade security with complete data isolation on Hugging Face Spaces.</div>
542
+ """)
543
+
544
+ with gr.Column(scale=1):
545
+ with gr.Group(elem_classes=["feature-glass-card"]):
546
+ gr.HTML("""
547
+ <div class="icon-box">
548
+ <div class="icon-wrapper">
549
+ <i class="fas fa-microchip" style="color: #f87171;"></i>
550
+ </div>
551
+ </div>
552
+ <div class="feature-title-glass">GPU Accelerated</div>
553
+ <div class="feature-desc-glass">Optimized PyTorch inference with blazing-fast GPU acceleration.</div>
554
+ """)
555
+
556
+ with gr.Row(equal_height=True):
557
+ with gr.Column(scale=1):
558
+ with gr.Group(elem_classes=["feature-glass-card"]):
559
+ gr.HTML("""
560
+ <div class="icon-box">
561
+ <div class="icon-wrapper">
562
+ <i class="fas fa-comments" style="color: #b794f6;"></i>
563
+ </div>
564
+ </div>
565
+ <div class="feature-title-glass">Smart Context</div>
566
+ <div class="feature-desc-glass">Maintains conversation context for coherent, intelligent responses.</div>
567
+ """)
568
+
569
+ with gr.Column(scale=1):
570
+ with gr.Group(elem_classes=["feature-glass-card"]):
571
+ gr.HTML("""
572
+ <div class="icon-box">
573
+ <div class="icon-wrapper">
574
+ <i class="fas fa-wand-magic-sparkles" style="color: #fb923c;"></i>
575
+ </div>
576
+ </div>
577
+ <div class="feature-title-glass">Beautiful UI</div>
578
+ <div class="feature-desc-glass">Ultra-dark theme with advanced animations and stunning visual effects.</div>
579
+ """)
580
+
581
+ with gr.Column(scale=1):
582
+ with gr.Group(elem_classes=["feature-glass-card"]):
583
+ gr.HTML("""
584
+ <div class="icon-box">
585
+ <div class="icon-wrapper">
586
+ <i class="fas fa-code-branch" style="color: #60a5fa;"></i>
587
+ </div>
588
+ </div>
589
+ <div class="feature-title-glass">Open Source</div>
590
+ <div class="feature-desc-glass">Built with Transformers and Gradio - transparent and customizable.</div>
591
+ """)
592
+
593
+ # πŸ“Š Footer
594
+ gr.HTML("""
595
+ <div class="footer-glass">
596
+ <p style="font-size: 1.1rem;"><i class="fas fa-flask"></i> Built with Gradio & Transformers | Powered by DarkNeuron-AI</p>
597
+ <p style="margin-top: 0.7rem;"><i class="fas fa-heart" style="color: #f87171;"></i> Crafted with passion by @Madara369Uchiha</p>
598
+ </div>
599
+ """)
600
+
601
+ # βš™οΈ Event Handlers
602
+ def respond(message, chat_history, temp, top_p_val, max_tok):
603
+ if not message.strip():
604
+ return "", chat_history
605
+ bot_response = chat_fn(message, chat_history)
606
+ chat_history.append((message, bot_response))
607
+ return "", chat_history
608
+
609
+ def regenerate(chat_history):
610
+ if not chat_history:
611
+ return chat_history
612
+ last_message = chat_history[-1][0]
613
+ chat_history = chat_history[:-1]
614
+ bot_response = chat_fn(last_message, chat_history)
615
+ chat_history.append((last_message, bot_response))
616
+ return chat_history
617
+
618
+ # Connect events
619
+ chat_input.submit(respond, [chat_input, chatbot_ui, temperature, top_p, max_tokens], [chat_input, chatbot_ui])
620
+ submit_btn.click(respond, [chat_input, chatbot_ui, temperature, top_p, max_tokens], [chat_input, chatbot_ui])
621
+ clear_btn.click(lambda: [], None, chatbot_ui)
622
+ regenerate_btn.click(regenerate, chatbot_ui, chatbot_ui)
623
+
624
+ # πŸš€ Launch
625
+ if __name__ == "__main__":
626
+ demo.launch(share=True)