Spaces:
Sleeping
Sleeping
edbeeching
commited on
Commit
Β·
ba02fde
1
Parent(s):
588fd75
fix sign in
Browse files
app.py
CHANGED
|
@@ -291,8 +291,8 @@ def main():
|
|
| 291 |
login_button = gr.LoginButton(value="π Sign in", size="sm")
|
| 292 |
gr.Markdown("") # Empty space for alignment
|
| 293 |
|
| 294 |
-
|
| 295 |
-
main_interface = gr.Column(visible=
|
| 296 |
|
| 297 |
# Store the current oauth token for use in submit_request
|
| 298 |
current_oauth_token = gr.State(None)
|
|
@@ -538,31 +538,42 @@ def main():
|
|
| 538 |
return "π€ **Free User**: You can generate up to 100 samples per request. [Upgrade to PRO](http://huggingface.co/subscribe/pro?source=synthetic-data-universe) for 10,000 samples."
|
| 539 |
|
| 540 |
def control_access(profile: Optional[gr.OAuthProfile] = None, oauth_token: Optional[gr.OAuthToken] = None):
|
| 541 |
-
#
|
| 542 |
-
limit_msg = update_user_limits(oauth_token)
|
| 543 |
-
|
| 544 |
-
# Update slider maximum based on user tier
|
| 545 |
if oauth_token is None:
|
| 546 |
-
|
| 547 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
else:
|
|
|
|
|
|
|
| 549 |
is_pro = verify_pro_status(oauth_token)
|
| 550 |
max_samples = MAX_SAMPLES_PRO if is_pro else MAX_SAMPLES_FREE
|
|
|
|
| 551 |
if is_pro:
|
| 552 |
button_text = f"β¨ Signed in as PRO ({profile.name if profile else 'User'})"
|
| 553 |
else:
|
| 554 |
button_text = f"π€ Signed in as {profile.name if profile else 'User'}"
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 560 |
|
| 561 |
|
| 562 |
# Handle login state changes - LoginButton automatically handles auth state changes
|
| 563 |
# The demo.load will handle both initial load and auth changes
|
| 564 |
|
| 565 |
-
demo.load(control_access, inputs=None, outputs=[main_interface,
|
| 566 |
demo.queue(max_size=None, default_concurrency_limit=None).launch(show_error=True)
|
| 567 |
|
| 568 |
if __name__ == "__main__":
|
|
|
|
| 291 |
login_button = gr.LoginButton(value="π Sign in", size="sm")
|
| 292 |
gr.Markdown("") # Empty space for alignment
|
| 293 |
|
| 294 |
+
signin_message = gr.Markdown("## π Sign In Required\n\nPlease sign in with your Hugging Face account to access the synthetic data generation service. Click the **Sign in** button above to continue.", visible=True)
|
| 295 |
+
main_interface = gr.Column(visible=False)
|
| 296 |
|
| 297 |
# Store the current oauth token for use in submit_request
|
| 298 |
current_oauth_token = gr.State(None)
|
|
|
|
| 538 |
return "π€ **Free User**: You can generate up to 100 samples per request. [Upgrade to PRO](http://huggingface.co/subscribe/pro?source=synthetic-data-universe) for 10,000 samples."
|
| 539 |
|
| 540 |
def control_access(profile: Optional[gr.OAuthProfile] = None, oauth_token: Optional[gr.OAuthToken] = None):
|
| 541 |
+
# Require users to be signed in
|
|
|
|
|
|
|
|
|
|
| 542 |
if oauth_token is None:
|
| 543 |
+
# User is not signed in - show sign-in prompt, hide main interface
|
| 544 |
+
return (
|
| 545 |
+
gr.update(visible=False), # main_interface
|
| 546 |
+
gr.update(visible=True), # signin_message
|
| 547 |
+
oauth_token, # current_oauth_token
|
| 548 |
+
"", # user_limit_info (empty when not signed in)
|
| 549 |
+
gr.update(), # num_output_samples (no change)
|
| 550 |
+
gr.update(value="π Sign in") # login_button
|
| 551 |
+
)
|
| 552 |
else:
|
| 553 |
+
# User is signed in - show main interface, hide sign-in prompt
|
| 554 |
+
limit_msg = update_user_limits(oauth_token)
|
| 555 |
is_pro = verify_pro_status(oauth_token)
|
| 556 |
max_samples = MAX_SAMPLES_PRO if is_pro else MAX_SAMPLES_FREE
|
| 557 |
+
|
| 558 |
if is_pro:
|
| 559 |
button_text = f"β¨ Signed in as PRO ({profile.name if profile else 'User'})"
|
| 560 |
else:
|
| 561 |
button_text = f"π€ Signed in as {profile.name if profile else 'User'}"
|
| 562 |
+
|
| 563 |
+
return (
|
| 564 |
+
gr.update(visible=True), # main_interface
|
| 565 |
+
gr.update(visible=False), # signin_message
|
| 566 |
+
oauth_token, # current_oauth_token
|
| 567 |
+
limit_msg, # user_limit_info
|
| 568 |
+
gr.update(maximum=max_samples), # num_output_samples
|
| 569 |
+
gr.update(value=button_text) # login_button
|
| 570 |
+
)
|
| 571 |
|
| 572 |
|
| 573 |
# Handle login state changes - LoginButton automatically handles auth state changes
|
| 574 |
# The demo.load will handle both initial load and auth changes
|
| 575 |
|
| 576 |
+
demo.load(control_access, inputs=None, outputs=[main_interface, signin_message, current_oauth_token, user_limit_info, num_output_samples, login_button])
|
| 577 |
demo.queue(max_size=None, default_concurrency_limit=None).launch(show_error=True)
|
| 578 |
|
| 579 |
if __name__ == "__main__":
|