edbeeching commited on
Commit
cc8e33a
Β·
1 Parent(s): 002e03d

fix sign in

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -212,7 +212,7 @@ def main():
212
  # Add sign-in button at the top
213
  with gr.Row():
214
  gr.Markdown("") # Empty space for alignment
215
- login_button = gr.LoginButton(value="πŸ”‘ Sign in for PRO benefits", size="sm")
216
  gr.Markdown("") # Empty space for alignment
217
 
218
  pro_message = gr.Markdown(visible=False)
@@ -275,7 +275,7 @@ def main():
275
  with gr.Group():
276
  gr.Markdown("## Dataset information")
277
  # Dynamic user limit info - default to anonymous user
278
- user_limit_info = gr.Markdown(value="πŸ‘€ **Anonymous User**: You can generate up to 100 samples per request.", visible=True)
279
  with gr.Row():
280
  with gr.Column():
281
  input_dataset_name = gr.Textbox(label="Input Dataset Name", placeholder="e.g., simplescaling/s1K-1.1")
@@ -371,7 +371,7 @@ def main():
371
 
372
  def update_user_limits(oauth_token):
373
  if oauth_token is None:
374
- return "πŸ‘€ **Anonymous User**: You can generate up to 100 samples per request. [Sign in](javascript:void(0)) for PRO benefits (10,000 samples)."
375
 
376
  is_pro = verify_pro_status(oauth_token)
377
  if is_pro:
@@ -386,19 +386,25 @@ def main():
386
  # Update slider maximum based on user tier
387
  if oauth_token is None:
388
  max_samples = MAX_SAMPLES_FREE
 
389
  else:
390
  is_pro = verify_pro_status(oauth_token)
391
  max_samples = MAX_SAMPLES_PRO if is_pro else MAX_SAMPLES_FREE
 
 
 
 
392
 
393
  slider_update = gr.update(maximum=max_samples)
 
394
 
395
- return gr.update(visible=True), gr.update(visible=False), oauth_token, limit_msg, slider_update
396
 
397
 
398
  # Handle login state changes - LoginButton automatically handles auth state changes
399
  # The demo.load will handle both initial load and auth changes
400
 
401
- demo.load(control_access, inputs=None, outputs=[main_interface, pro_message, current_oauth_token, user_limit_info, num_output_samples])
402
  demo.queue(max_size=None, default_concurrency_limit=None).launch(show_error=True)
403
 
404
  if __name__ == "__main__":
 
212
  # Add sign-in button at the top
213
  with gr.Row():
214
  gr.Markdown("") # Empty space for alignment
215
+ login_button = gr.LoginButton(value="πŸ”‘ Sign in", size="sm")
216
  gr.Markdown("") # Empty space for alignment
217
 
218
  pro_message = gr.Markdown(visible=False)
 
275
  with gr.Group():
276
  gr.Markdown("## Dataset information")
277
  # Dynamic user limit info - default to anonymous user
278
+ user_limit_info = gr.Markdown(value="πŸ‘€ **Anonymous User**: You can generate up to 100 samples per request. Use the sign-in button above for PRO benefits (10,000 samples).", visible=True)
279
  with gr.Row():
280
  with gr.Column():
281
  input_dataset_name = gr.Textbox(label="Input Dataset Name", placeholder="e.g., simplescaling/s1K-1.1")
 
371
 
372
  def update_user_limits(oauth_token):
373
  if oauth_token is None:
374
+ return "πŸ‘€ **Anonymous User**: You can generate up to 100 samples per request. Use the sign-in button above for PRO benefits (10,000 samples)."
375
 
376
  is_pro = verify_pro_status(oauth_token)
377
  if is_pro:
 
386
  # Update slider maximum based on user tier
387
  if oauth_token is None:
388
  max_samples = MAX_SAMPLES_FREE
389
+ button_text = "πŸ”‘ Sign in for PRO benefits"
390
  else:
391
  is_pro = verify_pro_status(oauth_token)
392
  max_samples = MAX_SAMPLES_PRO if is_pro else MAX_SAMPLES_FREE
393
+ if is_pro:
394
+ button_text = f"✨ Signed in as PRO ({profile.name if profile else 'User'})"
395
+ else:
396
+ button_text = f"πŸ‘€ Signed in as {profile.name if profile else 'User'}"
397
 
398
  slider_update = gr.update(maximum=max_samples)
399
+ button_update = gr.update(value=button_text)
400
 
401
+ return gr.update(visible=True), gr.update(visible=False), oauth_token, limit_msg, slider_update, button_update
402
 
403
 
404
  # Handle login state changes - LoginButton automatically handles auth state changes
405
  # The demo.load will handle both initial load and auth changes
406
 
407
+ demo.load(control_access, inputs=None, outputs=[main_interface, pro_message, current_oauth_token, user_limit_info, num_output_samples, login_button])
408
  demo.queue(max_size=None, default_concurrency_limit=None).launch(show_error=True)
409
 
410
  if __name__ == "__main__":