Claude commited on
Commit
203d50e
·
unverified ·
1 Parent(s): 9b62d57

Show HF_TOKEN detection status in Step 1

Browse files

Evaluated at container startup, so a Space operator can immediately see
whether the HF_TOKEN secret reached the process or whether it's missing,
misnamed, or awaiting a restart - instead of discovering it via a failed
chat call.

Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -320,6 +320,20 @@ with gr.Blocks(title="Document Intelligence — OCR & Structured Data Extraction
320
  with gr.Row(elem_id="quick-prompts"):
321
  quick_buttons = {label: gr.Button(label, size="sm") for label in QUICK_PROMPTS}
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  with gr.Accordion("Use your own Hugging Face token (optional)", open=False):
324
  gr.Markdown("Only needed if this Space's `HF_TOKEN` secret isn't set, or you want to use your own.")
325
  hf_token_input = gr.Textbox(label="Hugging Face token", type="password", placeholder="hf_...", show_label=False)
 
320
  with gr.Row(elem_id="quick-prompts"):
321
  quick_buttons = {label: gr.Button(label, size="sm") for label in QUICK_PROMPTS}
322
 
323
+ # Evaluated at container startup - tells the operator at a glance
324
+ # whether the HF_TOKEN secret actually reached this process.
325
+ _token_detected = bool(os.environ.get("HF_TOKEN"))
326
+ gr.Markdown(
327
+ '<div class="sample-note">Space token status: '
328
+ + ("<strong>HF_TOKEN detected</strong> - the assistant is ready to use."
329
+ if _token_detected else
330
+ "<strong>HF_TOKEN not detected.</strong> The secret is missing, misnamed "
331
+ "(it must be exactly <code>HF_TOKEN</code>, saved as a Secret, not a Variable), "
332
+ "or the Space hasn't been restarted since it was added. You can still paste "
333
+ "a token below, or skip the assistant and use the manual settings in Step 2.")
334
+ + "</div>"
335
+ )
336
+
337
  with gr.Accordion("Use your own Hugging Face token (optional)", open=False):
338
  gr.Markdown("Only needed if this Space's `HF_TOKEN` secret isn't set, or you want to use your own.")
339
  hf_token_input = gr.Textbox(label="Hugging Face token", type="password", placeholder="hf_...", show_label=False)