BoxOfColors commited on
Commit
0691643
Β·
1 Parent(s): efe424b

remove: HF token settings section and JS fallback

Browse files

ZeroGPU quota attribution works automatically via the HF JWT session
(confirmed in HAR β€” x-zerogpu-token/uuid headers present on all regen
calls). Manual token input is redundant.

Files changed (1) hide show
  1. app.py +2 -25
app.py CHANGED
@@ -2272,16 +2272,7 @@ _GLOBAL_JS = """
2272
  for (var k in zerogpuHeaders) { regenHeaders[k] = zerogpuHeaders[k]; }
2273
  console.log('[fireRegen] using zerogpu headers from parent frame');
2274
  } else {
2275
- // Fallback: try user-supplied HF token from Settings
2276
- var userHfToken = '';
2277
- var hfTokenEl = document.getElementById('hf_token_input');
2278
- if (hfTokenEl) { var inp = hfTokenEl.querySelector('input,textarea'); if (inp) userHfToken = (inp.value || '').trim(); }
2279
- if (userHfToken) {
2280
- regenHeaders['Authorization'] = 'Bearer ' + userHfToken;
2281
- console.log('[fireRegen] using HF token fallback for quota attribution');
2282
- } else {
2283
- console.warn('[fireRegen] no zerogpu headers or HF token β€” may use anonymous quota');
2284
- }
2285
  }
2286
  fetch('/gradio_api/queue/join', {
2287
  method: 'POST',
@@ -2484,19 +2475,6 @@ _GLOBAL_JS = """
2484
  """
2485
 
2486
  with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) as demo:
2487
- with gr.Accordion("βš™οΈ Settings (optional)", open=False):
2488
- gr.Markdown(
2489
- "**HF Token** β€” Paste your [Hugging Face token](https://huggingface.co/settings/tokens) here so that "
2490
- "segment regeneration uses your own ZeroGPU quota (PRO = 25 min/day) instead of the shared free pool. "
2491
- "The token is stored only in your browser and never sent anywhere except the Space's own API."
2492
- )
2493
- hf_token_input = gr.Textbox(
2494
- label="Hugging Face Token (optional)",
2495
- placeholder="hf_...",
2496
- type="password",
2497
- elem_id="hf_token_input",
2498
- max_lines=1,
2499
- )
2500
  gr.Markdown(
2501
  "# Generate Audio for Video\n"
2502
  "Choose a model and upload a video to generate synchronized audio.\n\n"
@@ -2757,10 +2735,9 @@ with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) a
2757
  api_name="xregen_hunyuan",
2758
  )
2759
 
2760
- # NOTE: ZeroGPU quota attribution is now handled via postMessage("zerogpu-headers")
2761
  # to the HF parent frame β€” the same mechanism Gradio's own JS client uses.
2762
  # This replaced the old x-ip-token relay approach which was unreliable.
2763
- # The HF token input in Settings is kept as a fallback.
2764
 
2765
  print("[startup] app.py fully loaded β€” regen handlers registered, SSR disabled")
2766
  demo.queue(max_size=10).launch(ssr_mode=False, height=900, allowed_paths=["/tmp"])
 
2272
  for (var k in zerogpuHeaders) { regenHeaders[k] = zerogpuHeaders[k]; }
2273
  console.log('[fireRegen] using zerogpu headers from parent frame');
2274
  } else {
2275
+ console.warn('[fireRegen] no zerogpu headers available β€” may use anonymous quota');
 
 
 
 
 
 
 
 
 
2276
  }
2277
  fetch('/gradio_api/queue/join', {
2278
  method: 'POST',
 
2475
  """
2476
 
2477
  with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
2478
  gr.Markdown(
2479
  "# Generate Audio for Video\n"
2480
  "Choose a model and upload a video to generate synchronized audio.\n\n"
 
2735
  api_name="xregen_hunyuan",
2736
  )
2737
 
2738
+ # NOTE: ZeroGPU quota attribution is handled via postMessage("zerogpu-headers")
2739
  # to the HF parent frame β€” the same mechanism Gradio's own JS client uses.
2740
  # This replaced the old x-ip-token relay approach which was unreliable.
 
2741
 
2742
  print("[startup] app.py fully loaded β€” regen handlers registered, SSR disabled")
2743
  demo.queue(max_size=10).launch(ssr_mode=False, height=900, allowed_paths=["/tmp"])