Miquel Farré commited on
Commit
d879b66
·
1 Parent(s): 80bb3ea
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -47,13 +47,16 @@ def commit_signup(username: str, email: str, current_data: pd.DataFrame) -> Opti
47
  os.unlink(tmp.name)
48
  return str(e) # Return error message
49
 
50
- def join_waitlist(profile: gr.OAuthProfile | None) -> str:
51
  """Add user to the SmolVLM2 iPhone waitlist with retry logic for concurrent updates"""
52
 
53
- if profile is None:
54
  gr.Warning("Please log in to Hugging Face first!")
55
  return "Please log in with your Hugging Face account first!"
56
 
 
 
 
57
  for attempt in range(MAX_RETRIES):
58
  try:
59
  # Get current waitlist state
@@ -65,11 +68,11 @@ def join_waitlist(profile: gr.OAuthProfile | None) -> str:
65
  current_data = pd.DataFrame(columns=['userid', 'email', 'joined_at'])
66
 
67
  # Check if user already registered
68
- if profile.username in current_data['userid'].values:
69
  return "You're already on the waitlist! We'll keep you updated."
70
 
71
  # Try to commit the update
72
- error = commit_signup(profile.username, profile.email, current_data)
73
 
74
  if error is None: # Success
75
  return "Thanks for joining the waitlist! We'll keep you updated on SmolVLM2 iPhone app and source code release."
@@ -99,17 +102,16 @@ with gr.Blocks(title="SmolVLM2 Waitlist") as demo:
99
  - First look at the source code when available
100
  """)
101
 
102
- with gr.Row():
103
- gr.LoginButton()
104
 
105
  join_button = gr.Button("Join Waitlist", variant="primary")
106
  output = gr.Markdown(visible=False)
107
 
108
  join_button.click(
109
  fn=join_waitlist,
110
- inputs=gr.OAuthProfile(),
111
  outputs=output,
112
  )
113
 
114
  if __name__ == "__main__":
115
- demo.launch()
 
47
  os.unlink(tmp.name)
48
  return str(e) # Return error message
49
 
50
+ def join_waitlist(user: dict) -> str:
51
  """Add user to the SmolVLM2 iPhone waitlist with retry logic for concurrent updates"""
52
 
53
+ if not user or not user.get("username"):
54
  gr.Warning("Please log in to Hugging Face first!")
55
  return "Please log in with your Hugging Face account first!"
56
 
57
+ username = user["username"]
58
+ email = user.get("email", "")
59
+
60
  for attempt in range(MAX_RETRIES):
61
  try:
62
  # Get current waitlist state
 
68
  current_data = pd.DataFrame(columns=['userid', 'email', 'joined_at'])
69
 
70
  # Check if user already registered
71
+ if username in current_data['userid'].values:
72
  return "You're already on the waitlist! We'll keep you updated."
73
 
74
  # Try to commit the update
75
+ error = commit_signup(username, email, current_data)
76
 
77
  if error is None: # Success
78
  return "Thanks for joining the waitlist! We'll keep you updated on SmolVLM2 iPhone app and source code release."
 
102
  - First look at the source code when available
103
  """)
104
 
105
+ user = gr.State(value=None)
 
106
 
107
  join_button = gr.Button("Join Waitlist", variant="primary")
108
  output = gr.Markdown(visible=False)
109
 
110
  join_button.click(
111
  fn=join_waitlist,
112
+ inputs=user,
113
  outputs=output,
114
  )
115
 
116
  if __name__ == "__main__":
117
+ demo.queue().launch(auth=True, auth_message="Please login to join the waitlist")