merve HF Staff commited on
Commit
2b6939e
Β·
verified Β·
1 Parent(s): 0fb1929

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -238,6 +238,7 @@ def _k2_model_candidates() -> List[str]:
238
  """
239
  env_model = (os.getenv("KIMI_K2_MODEL") or "moonshotai/Kimi-K2-Instruct").strip()
240
  candidates = [env_model]
 
241
  seen = set()
242
  out = []
243
  for c in candidates:
@@ -472,7 +473,7 @@ def generate_wrapped_report(profile: gr.OAuthProfile) -> str:
472
 
473
  .username {{
474
  font-size: 1.5em;
475
- color: #8a4b00;
476
  margin-top: 10px;
477
  font-weight: 600;
478
  }}
@@ -843,11 +844,16 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
843
  .gradio-container {
844
  background: linear-gradient(135deg, #FFF4D6 0%, #FFE6B8 50%, #FFF9E6 100%);
845
  }
 
 
 
 
 
846
  """) as demo:
847
  gr.HTML("""
848
- <div style="text-align: center; padding: 20px; color: white;">
849
  <h1 style="font-size: 3em; margin: 0;">πŸŽ‰ HF Wrapped 2025 πŸŽ‰</h1>
850
- <p style="font-size: 1.2em;">Discover your Hugging Face journey this year!</p>
851
  </div>
852
  """)
853
 
@@ -857,10 +863,14 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
857
  output = gr.HTML(value=show_login_message())
858
 
859
  def _render(profile_obj: Optional[gr.OAuthProfile] = None):
 
860
  return generate_wrapped_report(profile_obj) if profile_obj is not None else show_login_message()
861
 
 
862
  demo.load(fn=_render, inputs=None, outputs=output)
863
 
 
 
864
  if hasattr(login_button, "click"):
865
  login_button.click(fn=_render, inputs=None, outputs=output)
866
 
 
238
  """
239
  env_model = (os.getenv("KIMI_K2_MODEL") or "moonshotai/Kimi-K2-Instruct").strip()
240
  candidates = [env_model]
241
+ # de-dupe while preserving order
242
  seen = set()
243
  out = []
244
  for c in candidates:
 
473
 
474
  .username {{
475
  font-size: 1.5em;
476
+ color: #8a4b00 !important;
477
  margin-top: 10px;
478
  font-weight: 600;
479
  }}
 
844
  .gradio-container {
845
  background: linear-gradient(135deg, #FFF4D6 0%, #FFE6B8 50%, #FFF9E6 100%);
846
  }
847
+
848
+ /* Force readable hero text even when HF host page is in dark mode */
849
+ .hf-hero, .hf-hero * {
850
+ color: #111 !important;
851
+ }
852
  """) as demo:
853
  gr.HTML("""
854
+ <div class="hf-hero" style="text-align: center; padding: 20px;">
855
  <h1 style="font-size: 3em; margin: 0;">πŸŽ‰ HF Wrapped 2025 πŸŽ‰</h1>
856
+ <p style="font-size: 1.2em; margin: 8px 0 0 0;">Discover your Hugging Face journey this year!</p>
857
  </div>
858
  """)
859
 
 
863
  output = gr.HTML(value=show_login_message())
864
 
865
  def _render(profile_obj: Optional[gr.OAuthProfile] = None):
866
+ # In Gradio versions that support OAuth, `profile_obj` is injected after login.
867
  return generate_wrapped_report(profile_obj) if profile_obj is not None else show_login_message()
868
 
869
+ # On load show the login message (and in some Gradio versions, this also receives the injected profile)
870
  demo.load(fn=_render, inputs=None, outputs=output)
871
 
872
+ # After login completes, clicking the login button will trigger a rerender.
873
+ # Older Gradio treats LoginButton as a button (click event), not a value component (change event).
874
  if hasattr(login_button, "click"):
875
  login_button.click(fn=_render, inputs=None, outputs=output)
876