vighnesh-shetty-vs commited on
Commit
e444069
·
1 Parent(s): 12130fe

Add updated files

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -190,7 +190,6 @@ def generate_victory_dashboard(state):
190
  </tr>
191
  """
192
 
193
- # Dynamically generate 50 confetti divs
194
  confetti_elements = "".join([f'<div class="confetti-piece" style="left: {random.randint(0, 100)}%; background-color: hsl({random.randint(0, 360)}, 100%, 60%); animation-duration: {random.uniform(2.5, 5)}s; animation-delay: {random.uniform(0, 2)}s;"></div>' for _ in range(60)])
195
 
196
  return f"""
@@ -286,7 +285,7 @@ def process_query(user_input, selected_model, state):
286
  if state["points"] >= 500 or state["water"] <= 0:
287
  state["game_over"] = True
288
  victory_html = generate_victory_dashboard(state)
289
- return (state, stats_ui, drip_ui, audio_path, impact_ui, gr.update(), gr.update(),
290
  gr.update(), gr.update(), gr.update(), gr.update(), gr.update(value=""),
291
  gr.update(visible=False), gr.update(visible=True), gr.update(value=victory_html))
292
 
@@ -312,11 +311,10 @@ def select_alternative(choice_text, state):
312
  if state["points"] >= 500:
313
  state["game_over"] = True
314
  victory_html = generate_victory_dashboard(state)
315
- return state, stats_ui, gr.update(), gr.update(), gr.update(visible=False), gr.update(visible=True), gr.update(value=victory_html)
316
 
317
  return state, stats_ui, gr.update(value=msg), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update()
318
 
319
-
320
  custom_css = """
321
  @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;700&display=swap');
322
  body, .gradio-container { background-color: #0B1120 !important; font-family: 'Outfit', sans-serif !important; color: #e2e8f0 !important; }
@@ -341,7 +339,6 @@ h1 { text-align: center; color: #38bdf8; text-shadow: 0 0 15px rgba(56, 189, 248
341
  @keyframes floatUp { to { transform: translateY(-30px); opacity: 0; } }
342
 
343
  .drip-pod { background: rgba(15, 23, 42, 0.6); border-radius: 24px; border: 1px solid rgba(56, 189, 248, 0.2); padding: 30px 20px; display: flex; flex-direction: column; align-items: center; box-shadow: inset 0 0 40px rgba(0,0,0,0.5); }
344
- .drip-audio { background: transparent !important; border: none !important; box-shadow: none !important; width: 100%; max-width: 300px; filter: invert(1) hue-rotate(180deg) brightness(1.5); margin-bottom: 15px;}
345
  .feedback-box { background: rgba(56, 189, 248, 0.1); border-left: 4px solid #38bdf8; padding: 15px; border-radius: 8px; font-size: 1.05em; color: #e2e8f0; width: 100%; text-align: left; line-height: 1.4; box-sizing: border-box;}
346
 
347
  .input-row { align-items: stretch !important; margin: 10px 0; }
@@ -391,7 +388,8 @@ with gr.Blocks(css=custom_css, title="EcoQueryQuest") as demo:
391
  with gr.Row():
392
  with gr.Column(scale=1, elem_classes=["drip-pod"]):
393
  drip_html = gr.HTML(get_drip_visuals(10.0))
394
- drip_audio = gr.Audio(label="Drip's Voice", autoplay=True, interactive=False, elem_classes=["drip-audio"])
 
395
  drip_feedback = gr.HTML("<div class='feedback-box'>Waiting for your first query...</div>")
396
 
397
  with gr.Column(scale=2):
@@ -425,6 +423,5 @@ with gr.Blocks(css=custom_css, title="EcoQueryQuest") as demo:
425
  outputs=[game_state, stats_html, alt_feedback, alternatives_group, main_game_ui, victory_ui, victory_display]
426
  )
427
 
428
- # Launch with CSS parameter mapping directly to demo launch block
429
  if __name__ == "__main__":
430
  demo.launch(css=custom_css)
 
190
  </tr>
191
  """
192
 
 
193
  confetti_elements = "".join([f'<div class="confetti-piece" style="left: {random.randint(0, 100)}%; background-color: hsl({random.randint(0, 360)}, 100%, 60%); animation-duration: {random.uniform(2.5, 5)}s; animation-delay: {random.uniform(0, 2)}s;"></div>' for _ in range(60)])
194
 
195
  return f"""
 
285
  if state["points"] >= 500 or state["water"] <= 0:
286
  state["game_over"] = True
287
  victory_html = generate_victory_dashboard(state)
288
+ return (state, stats_ui, drip_ui, audio_path, impact_ui, gr.update(), gr.update(visible=False),
289
  gr.update(), gr.update(), gr.update(), gr.update(), gr.update(value=""),
290
  gr.update(visible=False), gr.update(visible=True), gr.update(value=victory_html))
291
 
 
311
  if state["points"] >= 500:
312
  state["game_over"] = True
313
  victory_html = generate_victory_dashboard(state)
314
+ return state, stats_ui, gr.update(), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(value=victory_html)
315
 
316
  return state, stats_ui, gr.update(value=msg), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update()
317
 
 
318
  custom_css = """
319
  @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;700&display=swap');
320
  body, .gradio-container { background-color: #0B1120 !important; font-family: 'Outfit', sans-serif !important; color: #e2e8f0 !important; }
 
339
  @keyframes floatUp { to { transform: translateY(-30px); opacity: 0; } }
340
 
341
  .drip-pod { background: rgba(15, 23, 42, 0.6); border-radius: 24px; border: 1px solid rgba(56, 189, 248, 0.2); padding: 30px 20px; display: flex; flex-direction: column; align-items: center; box-shadow: inset 0 0 40px rgba(0,0,0,0.5); }
 
342
  .feedback-box { background: rgba(56, 189, 248, 0.1); border-left: 4px solid #38bdf8; padding: 15px; border-radius: 8px; font-size: 1.05em; color: #e2e8f0; width: 100%; text-align: left; line-height: 1.4; box-sizing: border-box;}
343
 
344
  .input-row { align-items: stretch !important; margin: 10px 0; }
 
388
  with gr.Row():
389
  with gr.Column(scale=1, elem_classes=["drip-pod"]):
390
  drip_html = gr.HTML(get_drip_visuals(10.0))
391
+ # Set visible=False on the Audio component so it stays completely hidden while still autoplaying!
392
+ drip_audio = gr.Audio(label="Drip's Voice", autoplay=True, interactive=False, visible=False)
393
  drip_feedback = gr.HTML("<div class='feedback-box'>Waiting for your first query...</div>")
394
 
395
  with gr.Column(scale=2):
 
423
  outputs=[game_state, stats_html, alt_feedback, alternatives_group, main_game_ui, victory_ui, victory_display]
424
  )
425
 
 
426
  if __name__ == "__main__":
427
  demo.launch(css=custom_css)