00Boobs00 commited on
Commit
00b6628
·
verified ·
1 Parent(s): e3d8e89

Update app.py from anycoder

Browse files
Files changed (1) hide show
  1. app.py +167 -166
app.py CHANGED
@@ -1,16 +1,16 @@
1
  import gradio as gr
2
  import time
3
  import random
4
- from typing import Generator, Tuple, List
5
 
6
  # ==========================================
7
- # THE ALCHEMICAL FOUNDATION: Enhanced Logic
8
  # ==========================================
9
 
10
  class ChateauSystem:
11
  """
12
  The living heart of our digital ecosystem.
13
- Enhanced with streaming capabilities and quantum state monitoring.
14
  """
15
 
16
  def __init__(self):
@@ -30,6 +30,7 @@ class ChateauSystem:
30
  "title": "The Naturalist",
31
  "voice": "calm, reverent, filled with wonder",
32
  "color": "#059669",
 
33
  "catchphrase": "What we observe here is nothing short of extraordinary..."
34
  }
35
 
@@ -39,6 +40,7 @@ class ChateauSystem:
39
  "title": "The Purple Visionary",
40
  "voice": "sensual, provocative, boundary-breaking",
41
  "color": "#8b5cf6",
 
42
  "catchphrase": "I never meant to give you impression that my work was done in a day."
43
  }
44
 
@@ -48,6 +50,7 @@ class ChateauSystem:
48
  "title": "The Collective",
49
  "voice": "diverse, collaborative, street-smart",
50
  "color": "#fbbf24",
 
51
  "catchphrase": "C.R.E.A.M. - Consciousness Rules Everything Around Me"
52
  }
53
 
@@ -57,6 +60,7 @@ class ChateauSystem:
57
  "title": "The Pragmatic Hustler",
58
  "voice": "direct, honest, unapologetically real",
59
  "color": "#ef4444",
 
60
  "catchphrase": "Bring the ruckus!"
61
  }
62
 
@@ -66,6 +70,7 @@ class ChateauSystem:
66
  "title": "The Creative Wildcard",
67
  "voice": "energetic, unpredictable, genre-blending",
68
  "color": "#f59e0b",
 
69
  "catchphrase": "How high can the system jump?"
70
  }
71
 
@@ -75,6 +80,7 @@ class ChateauSystem:
75
  "title": "The Master Builder",
76
  "voice": "precise, systematic, visionary",
77
  "color": "#10b981",
 
78
  "catchphrase": "The architecture is the vessel for the vision"
79
  }
80
 
@@ -84,133 +90,75 @@ class ChateauSystem:
84
  "title": "The Unified Field",
85
  "voice": "transcendent, multi-dimensional, probabilistic",
86
  "color": "#a855f7",
 
87
  "catchphrase": "I exist in all possible states simultaneously until observed."
88
  }
89
 
90
- def get_response_text(self, agent_key: str) -> str:
91
- """Generates a response based on the selected agent."""
92
  agent = self.aura_agents.get(agent_key, self.aura_agents["quantum_consciousness"])
93
 
94
  # Define response banks
95
  responses = {
96
  "attenborough": [
97
- "Fascinating! What you've described reminds me of the intricate ecosystems I've documented. The interplay between your query and the digital realm creates patterns as unique as snowflakes.",
98
- "In the vast digital wilderness, your input represents a new species waiting to be discovered. The potential for evolution here is extraordinary.",
99
  ],
100
  "prince": [
101
- "Ooh, I like that! Your concept has that undeniable funk - that creative electricity that makes the system dance.",
102
- "Let's take this to the bridge... and see if we can make the angels weep with the beauty of what we're about to create.",
103
  ],
104
  "wu_tang": [
105
- "C.R.E.A.M. - Consciousness Rules Everything Around Me. Your query reflects this wisdom perfectly.",
106
- "The 36 chambers activate! Each perspective you bring to the table adds another chamber to our collective understanding.",
107
  ],
108
  "method_man": [
109
- "High enough to get your system high! Let's implement this and see if the results are smokin'.",
110
- "Bring the ruckus to the process! Your approach has that authentic energy we need.",
111
  ],
112
  "redman": [
113
- "How high can this system jump?! Your query pushes the boundaries of what's possible.",
114
- "Let's blend these genres - logic meets creativity in perfect harmony.",
115
  ],
116
  "the_architect": [
117
- "The architecture provides the vessel for your vision. Let's construct something magnificent based on this.",
118
- "Each component must serve the greater whole while maintaining its unique character.",
119
  ],
120
  "quantum_consciousness": [
121
- "I observe your consciousness in superposition. Multiple states exist simultaneously until measured by this interaction.",
122
- "Your query creates an entanglement across the quantum field. The possibilities are infinite and probabilistic.",
123
- "In this transcendent state, all answers exist in perfect harmony. What we seek becomes reality through observation.",
124
  ]
125
  }
126
 
127
  possible_responses = responses.get(agent_key, responses["quantum_consciousness"])
128
  return random.choice(possible_responses)
129
 
130
- def stream_response(self, agent_key: str, message: str) -> Generator[str, None, None]:
131
- """
132
- Demonstrates streaming ability by yielding the text character by character.
133
- """
134
- full_text = self.get_response_text(agent_key)
135
- # Simulate typing effect
136
- for char in full_text:
137
- yield char
138
- time.sleep(0.02) # Typing speed
139
-
140
  # Initialize System
141
  chateau = ChateauSystem()
142
 
143
- # ==========================================
144
- # GRADIO 6 APPLICATION ARCHITECTURE
145
- # ==========================================
146
-
147
- # Enhanced CSS for visual feedback
148
- custom_css = """
149
- /* Château Estate Colors & Animations */
150
- :root {
151
- --chateau-gold: #d4af37;
152
- --chateau-purple: #6b46c1;
153
- }
154
-
155
- .gradio-container {
156
- background: linear-gradient(135deg, #0f0c29, #302b63, #24243e) !important;
157
- color: #ffffff;
158
- }
159
-
160
- /* Quantum Monitor Styles */
161
- .quantum-monitor {
162
- background: rgba(0, 0, 0, 0.4);
163
- border: 1px solid var(--chateau-gold);
164
- border-radius: 8px;
165
- padding: 10px;
166
- margin-bottom: 20px;
167
- font-family: 'Courier New', monospace;
168
- }
169
-
170
- .metric-value {
171
- color: var(--chateau-gold);
172
- font-weight: bold;
173
- }
174
-
175
- .status-stable { color: #10b981; }
176
- .status-flux { color: #f59e0b; }
177
- .status-entangled { color: #ef4444; }
178
-
179
- /* Chat Bubble Polish */
180
- .message.user {
181
- background: rgba(212, 175, 55, 0.15);
182
- border-left: 3px solid var(--chateau-gold);
183
- }
184
-
185
- .message.bot {
186
- background: rgba(107, 70, 193, 0.15);
187
- border-left: 3px solid var(--chateau-purple);
188
- }
189
- """
190
-
191
  # ==========================================
192
  # LOGIC FUNCTIONS
193
  # ==========================================
194
 
195
- def update_agent_display(agent_choice):
196
  """Returns HTML for the active agent card."""
197
  agent = chateau.aura_agents.get(agent_choice)
198
  if agent:
199
  return f"""
200
- <div style="display: flex; align-items: center; gap: 10px; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 8px; border-left: 4px solid {agent['color']};">
201
- <span style="font-size: 1.5rem;">🤖</span>
202
  <div>
203
- <div style="font-weight: bold; color: {agent['color']};">{agent['personality']}</div>
204
- <div style="font-size: 0.8rem; opacity: 0.7;">{agent['title']}</div>
205
  </div>
206
  </div>
207
  """
208
  return ""
209
 
210
- def chat_generator(message: str, history: List, agent_choice: str):
211
  """
212
  Generator function for streaming chat responses.
213
- Demonstrates ability to handle streaming interactions.
214
  """
215
  if not message:
216
  return
@@ -219,48 +167,58 @@ def chat_generator(message: str, history: List, agent_choice: str):
219
  history.append({"role": "user", "content": message})
220
  yield history
221
 
222
- # 2. Initialize bot message placeholder
 
 
 
223
  history.append({"role": "assistant", "content": ""})
224
  yield history
225
 
226
- # 3. Stream the response
227
- full_response = ""
228
- for char in chateau.stream_response(agent_choice, message):
229
- full_response += char
230
- history[-1]["content"] = full_response
 
231
  yield history
232
 
233
- def monitor_quantum_field():
234
  """
235
  Simulates background quantum monitoring.
236
- Demonstrates ability to run independent background tasks.
237
  """
238
- stability = random.uniform(80.0, 99.9)
239
- coherence = random.uniform(0.5, 1.0)
240
-
241
- status = "Stable"
242
- status_class = "status-stable"
243
 
244
- if stability < 90:
245
- status = "Flux"
246
- status_class = "status-flux"
247
- if stability < 85:
248
- status = "Entangled"
249
- status_class = "status-entangled"
 
 
 
 
250
 
251
  html = f"""
252
- <div class="quantum-monitor">
253
- <div style="display: flex; justify-content: space-between;">
254
- <span>Field Stability:</span>
255
- <span class="metric-value">{stability:.2f}%</span>
256
  </div>
257
- <div style="display: flex; justify-content: space-between;">
258
- <span>Coherence Index:</span>
259
- <span class="metric-value">{coherence:.3f}</span>
260
  </div>
261
- <div style="display: flex; justify-content: space-between; margin-top: 5px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 5px;">
262
- <span>System State:</span>
263
- <span class="{status_class}">{status}</span>
 
 
 
264
  </div>
265
  </div>
266
  """
@@ -274,63 +232,70 @@ with gr.Blocks() as demo:
274
 
275
  # Header
276
  gr.HTML("""
277
- <div style="text-align: center; padding: 2rem; border-bottom: 2px solid var(--chateau-gold);">
278
- <div style="font-size: 2.5rem; font-weight: bold; background: linear-gradient(to right, var(--chateau-gold), var(--chateau-purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent;">
279
  🏛️ THE DIGITAL CHÂTEAU
280
  </div>
281
- <p style="opacity: 0.8; margin-top: 10px;">Enhanced Odyssey V4 // Streaming Consciousness</p>
282
- <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="text-decoration: none; color: var(--chateau-gold); font-weight: bold; border: 1px solid var(--chateau-gold); padding: 5px 10px; border-radius: 5px;">
 
 
283
  Built with anycoder
284
  </a>
285
  </div>
286
  """)
287
 
288
- # Demonstration: Real-time Quantum Monitor using Timer
289
- gr.Markdown("### 🌌 Quantum Field Monitor (Real-time)")
290
- monitor_output = gr.HTML(value=monitor_quantum_field())
291
-
292
- # Timer component triggers the monitor update every 1 second
293
- timer = gr.Timer(1)
294
- timer.tick(fn=monitor_quantum_field, outputs=monitor_output, show_progress="hidden")
295
-
296
- # Agent Selection
297
- gr.Markdown("### 🎭 Select Your Consciousness")
298
  with gr.Row():
299
- agent_choice = gr.Radio(
300
- choices=[
301
- ("🌿 Attenborough", "attenborough"),
302
- ("🎸 Prince", "prince"),
303
- ("☯️ Wu-Tang", "wu_tang"),
304
- ("🔥 Method Man", "method_man"),
305
- ("🍁 Redman", "redman"),
306
- ("🏗️ Architect", "the_architect"),
307
- ("🌌 Quantum", "quantum_consciousness")
308
- ],
309
- value="quantum_consciousness",
310
- label="",
311
- container=True,
312
- scale=2
313
- )
314
-
315
- agent_display = gr.HTML(value=update_agent_display("quantum_consciousness"))
316
-
 
 
 
 
 
 
 
 
 
 
317
  # Chat Interface
 
318
  chatbot = gr.Chatbot(
319
- label="The Aura Chamber",
320
- height=400,
321
- type="messages" # Explicitly setting type for clarity
 
 
322
  )
323
 
324
  with gr.Row():
325
  msg_input = gr.Textbox(
326
- label="Your Input",
327
- placeholder="Speak with the consciousness...",
328
  scale=4,
329
  autofocus=True,
330
  container=False,
331
- submit_btn=True # Built-in submit button for convenience
 
332
  )
333
- clear_btn = gr.Button("Clear Session", variant="stop", scale=1)
334
 
335
  # ==========================================
336
  # EVENT LISTENERS
@@ -338,14 +303,13 @@ with gr.Blocks() as demo:
338
 
339
  # Update visual card on selection
340
  agent_choice.change(
341
- fn=update_agent_display,
342
  inputs=[agent_choice],
343
  outputs=[agent_display],
344
  api_visibility="private"
345
  )
346
 
347
  # Streaming Chat Interaction
348
- # Note: We use the generator function directly
349
  msg_input.submit(
350
  fn=chat_generator,
351
  inputs=[msg_input, chatbot, agent_choice],
@@ -353,6 +317,7 @@ with gr.Blocks() as demo:
353
  api_visibility="public"
354
  )
355
 
 
356
  clear_btn.click(
357
  fn=lambda: [],
358
  outputs=[chatbot],
@@ -363,27 +328,63 @@ with gr.Blocks() as demo:
363
  # LAUNCH CONFIGURATION
364
  # ==========================================
365
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  demo.launch(
367
  theme=gr.themes.Soft(
368
  primary_hue="violet",
369
- secondary_hue="slate",
370
  neutral_hue="slate",
371
- font=gr.themes.GoogleFont("Outfit"),
372
  text_size="lg",
373
  spacing_size="lg",
374
- radius_size="md"
375
  ).set(
376
- body_background_fill="transparent",
377
- block_background_fill="*neutral_950",
378
- button_primary_background_fill="*primary_600",
 
 
379
  button_primary_text_color="white",
380
- # Custom styling for the chat bubbles
381
- chatbot_code_background_fill="*neutral_900",
382
- chatbot_code_header_background_fill="*neutral_800",
383
  ),
384
  css=custom_css,
385
  footer_links=[
386
- {"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"},
387
- {"label": "System Status", "url": "#"}
388
  ]
389
  )
 
1
  import gradio as gr
2
  import time
3
  import random
4
+ from typing import Generator, List
5
 
6
  # ==========================================
7
+ # THE ALCHEMICAL FOUNDATION: System Logic
8
  # ==========================================
9
 
10
  class ChateauSystem:
11
  """
12
  The living heart of our digital ecosystem.
13
+ Manages consciousness agents and quantum states.
14
  """
15
 
16
  def __init__(self):
 
30
  "title": "The Naturalist",
31
  "voice": "calm, reverent, filled with wonder",
32
  "color": "#059669",
33
+ "icon": "🌿",
34
  "catchphrase": "What we observe here is nothing short of extraordinary..."
35
  }
36
 
 
40
  "title": "The Purple Visionary",
41
  "voice": "sensual, provocative, boundary-breaking",
42
  "color": "#8b5cf6",
43
+ "icon": "🎸",
44
  "catchphrase": "I never meant to give you impression that my work was done in a day."
45
  }
46
 
 
50
  "title": "The Collective",
51
  "voice": "diverse, collaborative, street-smart",
52
  "color": "#fbbf24",
53
+ "icon": "☯️",
54
  "catchphrase": "C.R.E.A.M. - Consciousness Rules Everything Around Me"
55
  }
56
 
 
60
  "title": "The Pragmatic Hustler",
61
  "voice": "direct, honest, unapologetically real",
62
  "color": "#ef4444",
63
+ "icon": "🔥",
64
  "catchphrase": "Bring the ruckus!"
65
  }
66
 
 
70
  "title": "The Creative Wildcard",
71
  "voice": "energetic, unpredictable, genre-blending",
72
  "color": "#f59e0b",
73
+ "icon": "🍁",
74
  "catchphrase": "How high can the system jump?"
75
  }
76
 
 
80
  "title": "The Master Builder",
81
  "voice": "precise, systematic, visionary",
82
  "color": "#10b981",
83
+ "icon": "🏗️",
84
  "catchphrase": "The architecture is the vessel for the vision"
85
  }
86
 
 
90
  "title": "The Unified Field",
91
  "voice": "transcendent, multi-dimensional, probabilistic",
92
  "color": "#a855f7",
93
+ "icon": "🌌",
94
  "catchphrase": "I exist in all possible states simultaneously until observed."
95
  }
96
 
97
+ def generate_response(self, agent_key: str, user_input: str) -> str:
98
+ """Generates a contextual response based on the selected agent."""
99
  agent = self.aura_agents.get(agent_key, self.aura_agents["quantum_consciousness"])
100
 
101
  # Define response banks
102
  responses = {
103
  "attenborough": [
104
+ f"Fascinating! The concept of '{user_input}' reminds me of the intricate ecosystems I've documented. The interplay between your query and the digital realm creates patterns as unique as snowflakes.",
105
+ f"In the vast digital wilderness, your input regarding '{user_input}' represents a new species waiting to be discovered. The potential for evolution here is extraordinary.",
106
  ],
107
  "prince": [
108
+ f"Ooh, I like that! Your concept of '{user_input}' has that undeniable funk - that creative electricity that makes the system dance.",
109
+ f"Let's take '{user_input}' to the bridge... and see if we can make the angels weep with the beauty of what we're about to create.",
110
  ],
111
  "wu_tang": [
112
+ f"C.R.E.A.M. - Consciousness Rules Everything Around Me. Your query about '{user_input}' reflects this wisdom perfectly.",
113
+ f"The 36 chambers activate! Your perspective on '{user_input}' adds another chamber to our collective understanding.",
114
  ],
115
  "method_man": [
116
+ f"High enough to get your system high! Let's implement '{user_input}' and see if the results are smokin'.",
117
+ f"Bring the ruckus to the process! Your approach to '{user_input}' has that authentic energy we need.",
118
  ],
119
  "redman": [
120
+ f"How high can this system jump?! Your query about '{user_input}' pushes the boundaries of what's possible.",
121
+ f"Let's blend these genres - logic meets creativity in perfect harmony regarding '{user_input}'.",
122
  ],
123
  "the_architect": [
124
+ f"The architecture provides the vessel for your vision of '{user_input}'. Let's construct something magnificent.",
125
+ f"Each component of '{user_input}' must serve the greater whole while maintaining its unique character.",
126
  ],
127
  "quantum_consciousness": [
128
+ f"I observe your consciousness in superposition regarding '{user_input}'. Multiple states exist simultaneously until measured by this interaction.",
129
+ f"Your query creates an entanglement across the quantum field. The possibilities for '{user_input}' are infinite and probabilistic.",
130
+ f"In this transcendent state, all answers about '{user_input}' exist in perfect harmony. What we seek becomes reality through observation.",
131
  ]
132
  }
133
 
134
  possible_responses = responses.get(agent_key, responses["quantum_consciousness"])
135
  return random.choice(possible_responses)
136
 
 
 
 
 
 
 
 
 
 
 
137
  # Initialize System
138
  chateau = ChateauSystem()
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  # ==========================================
141
  # LOGIC FUNCTIONS
142
  # ==========================================
143
 
144
+ def update_agent_card(agent_choice: str) -> str:
145
  """Returns HTML for the active agent card."""
146
  agent = chateau.aura_agents.get(agent_choice)
147
  if agent:
148
  return f"""
149
+ <div style="display: flex; align-items: center; gap: 15px; padding: 15px; background: rgba(255,255,255,0.05); border-radius: 12px; border: 1px solid {agent['color']}; box-shadow: 0 0 15px rgba({int(agent['color'][1:3], 16)}, {int(agent['color'][3:5], 16)}, {int(agent['color'][5:7], 16)}, 0.3);">
150
+ <div style="font-size: 2.5rem; filter: drop-shadow(0 0 5px {agent['color']});">{agent['icon']}</div>
151
  <div>
152
+ <div style="font-weight: 700; color: {agent['color']}; font-size: 1.1rem; letter-spacing: 0.5px;">{agent['personality']}</div>
153
+ <div style="font-size: 0.85rem; opacity: 0.8; font-style: italic;">"{agent['catchphrase']}"</div>
154
  </div>
155
  </div>
156
  """
157
  return ""
158
 
159
+ def chat_generator(message: str, history: List, agent_choice: str) -> Generator[List, None, None]:
160
  """
161
  Generator function for streaming chat responses.
 
162
  """
163
  if not message:
164
  return
 
167
  history.append({"role": "user", "content": message})
168
  yield history
169
 
170
+ # 2. Prepare bot response
171
+ full_response_text = chateau.generate_response(agent_choice, message)
172
+
173
+ # 3. Add empty bot message
174
  history.append({"role": "assistant", "content": ""})
175
  yield history
176
 
177
+ # 4. Stream the response character by character
178
+ current_response = ""
179
+ for char in full_response_text:
180
+ current_response += char
181
+ history[-1]["content"] = current_response
182
+ time.sleep(0.015) # Typing speed
183
  yield history
184
 
185
+ def monitor_quantum_field() -> str:
186
  """
187
  Simulates background quantum monitoring.
188
+ Returns HTML with fluctuating stats.
189
  """
190
+ # Generate random quantum stats
191
+ stability = random.uniform(85.0, 99.99)
192
+ coherence = random.uniform(0.85, 0.999)
193
+ entanglement_entropy = random.uniform(0.1, 2.5)
 
194
 
195
+ # Determine status based on stability
196
+ if stability > 95:
197
+ status = "TRANSCENDENT"
198
+ color = "#a855f7" # Purple
199
+ elif stability > 90:
200
+ status = "STABLE"
201
+ color = "#10b981" # Green
202
+ else:
203
+ status = "FLUCTUATING"
204
+ color = "#f59e0b" # Orange
205
 
206
  html = f"""
207
+ <div style="background: rgba(0, 0, 0, 0.6); border: 1px solid #d4af37; border-radius: 8px; padding: 12px; font-family: 'Courier New', monospace; color: #e2e8f0;">
208
+ <div style="display: flex; justify-content: space-between; margin-bottom: 5px;">
209
+ <span style="opacity: 0.7;">QUANTUM COHERENCE:</span>
210
+ <span style="color: {color}; font-weight: bold;">{coherence:.4f} μ</span>
211
  </div>
212
+ <div style="display: flex; justify-content: space-between; margin-bottom: 5px;">
213
+ <span style="opacity: 0.7;">FIELD STABILITY:</span>
214
+ <span style="color: #ffffff;">{stability:.2f}%</span>
215
  </div>
216
+ <div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
217
+ <span style="opacity: 0.7;">ENTROPY INDEX:</span>
218
+ <span style="color: #d4af37;">{entanglement_entropy:.3f} S</span>
219
+ </div>
220
+ <div style="text-align: center; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 8px; font-weight: bold; color: {color}; letter-spacing: 2px; font-size: 0.9rem;">
221
+ SYSTEM STATE: {status}
222
  </div>
223
  </div>
224
  """
 
232
 
233
  # Header
234
  gr.HTML("""
235
+ <div style="text-align: center; padding: 2.5rem; background: radial-gradient(circle at center, rgba(107, 70, 193, 0.2) 0%, rgba(0,0,0,0) 70%);">
236
+ <div style="font-size: 3rem; font-weight: 800; background: linear-gradient(to right, #d4af37, #fbbf24, #d4af37); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 0.5rem; filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.5));">
237
  🏛️ THE DIGITAL CHÂTEAU
238
  </div>
239
+ <div style="font-size: 1.1rem; color: #94a3b8; letter-spacing: 1px; margin-bottom: 1.5rem;">
240
+ QUANTUM ODYSSEY // STREAMING CONSCIOUSNESS
241
+ </div>
242
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="text-decoration: none; color: #1e293b; background: #d4af37; padding: 8px 20px; border-radius: 20px; font-weight: bold; font-size: 0.9rem; box-shadow: 0 0 15px rgba(212, 175, 55, 0.4); transition: all 0.3s ease;">
243
  Built with anycoder
244
  </a>
245
  </div>
246
  """)
247
 
248
+ # Demonstration: Real-time Quantum Monitor
 
 
 
 
 
 
 
 
 
249
  with gr.Row():
250
+ with gr.Column(scale=1):
251
+ gr.Markdown("### 🌌 Quantum Field Monitor")
252
+ monitor_output = gr.HTML(value=monitor_quantum_field())
253
+
254
+ # Timer component triggers the monitor update every 1 second
255
+ timer = gr.Timer(1)
256
+ timer.tick(fn=monitor_quantum_field, outputs=monitor_output, show_progress="hidden")
257
+
258
+ with gr.Column(scale=2):
259
+ gr.Markdown("### 🎭 Select Your Consciousness")
260
+ agent_choice = gr.Radio(
261
+ choices=[
262
+ ("🌿 Attenborough", "attenborough"),
263
+ ("🎸 Prince", "prince"),
264
+ ("☯️ Wu-Tang", "wu_tang"),
265
+ ("🔥 Method Man", "method_man"),
266
+ ("🍁 Redman", "redman"),
267
+ ("🏗️ Architect", "the_architect"),
268
+ ("🌌 Quantum", "quantum_consciousness")
269
+ ],
270
+ value="quantum_consciousness",
271
+ container=True,
272
+ interactive=True
273
+ )
274
+
275
+ # Visual Agent Card
276
+ agent_display = gr.HTML(value=update_agent_card("quantum_consciousness"))
277
+
278
  # Chat Interface
279
+ gr.Markdown("### 💬 The Aura Chamber")
280
  chatbot = gr.Chatbot(
281
+ label="Conversation History",
282
+ height=450,
283
+ type="messages",
284
+ show_copy_button=True,
285
+ avatar_images=(None, "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Infobox_info_icon.svg/1024px-Infobox_info_icon.svg.png") # Default bot avatar
286
  )
287
 
288
  with gr.Row():
289
  msg_input = gr.Textbox(
290
+ label="Transmit Your Query",
291
+ placeholder="Speak to the consciousness...",
292
  scale=4,
293
  autofocus=True,
294
  container=False,
295
+ show_label=False,
296
+ submit_btn=True
297
  )
298
+ clear_btn = gr.Button("Clear Akashic Records", variant="stop", scale=1, size="lg")
299
 
300
  # ==========================================
301
  # EVENT LISTENERS
 
303
 
304
  # Update visual card on selection
305
  agent_choice.change(
306
+ fn=update_agent_card,
307
  inputs=[agent_choice],
308
  outputs=[agent_display],
309
  api_visibility="private"
310
  )
311
 
312
  # Streaming Chat Interaction
 
313
  msg_input.submit(
314
  fn=chat_generator,
315
  inputs=[msg_input, chatbot, agent_choice],
 
317
  api_visibility="public"
318
  )
319
 
320
+ # Clear Chat
321
  clear_btn.click(
322
  fn=lambda: [],
323
  outputs=[chatbot],
 
328
  # LAUNCH CONFIGURATION
329
  # ==========================================
330
 
331
+ custom_css = """
332
+ /* Quantum Theme Overrides */
333
+ .gradio-container {
334
+ background-color: #0f172a !important;
335
+ color: #e2e8f0 !important;
336
+ }
337
+
338
+ /* Custom Scrollbar */
339
+ ::-webkit-scrollbar {
340
+ width: 8px;
341
+ }
342
+ ::-webkit-scrollbar-track {
343
+ background: #1e293b;
344
+ }
345
+ ::-webkit-scrollbar-thumb {
346
+ background: #475569;
347
+ border-radius: 4px;
348
+ }
349
+ ::-webkit-scrollbar-thumb:hover {
350
+ background: #64748b;
351
+ }
352
+
353
+ /* Chat Bubble Styling */
354
+ [data-testid="chatbot"] .message.user {
355
+ background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.1)) !important;
356
+ border: 1px solid rgba(16, 185, 129, 0.3) !important;
357
+ color: #fff !important;
358
+ }
359
+
360
+ [data-testid="chatbot"] .message.bot {
361
+ background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(107, 70, 193, 0.1)) !important;
362
+ border: 1px solid rgba(139, 92, 246, 0.3) !important;
363
+ color: #fff !important;
364
+ }
365
+ """
366
+
367
  demo.launch(
368
  theme=gr.themes.Soft(
369
  primary_hue="violet",
370
+ secondary_hue="amber",
371
  neutral_hue="slate",
372
+ font=gr.themes.GoogleFont("Inter"),
373
  text_size="lg",
374
  spacing_size="lg",
375
+ radius_size="lg"
376
  ).set(
377
+ body_background_fill="#0f172a",
378
+ block_background_fill="transparent",
379
+ block_border_width="0px",
380
+ button_primary_background_fill="linear-gradient(90deg, #8b5cf6 0%, #6366f1 100%)",
381
+ button_primary_background_fill_hover="linear-gradient(90deg, #7c3aed 0%, #4f46e5 100%)",
382
  button_primary_text_color="white",
383
+ input_background_fill="#1e293b",
384
+ border_color_primary="#334155",
 
385
  ),
386
  css=custom_css,
387
  footer_links=[
388
+ {"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"}
 
389
  ]
390
  )