Mtchmann commited on
Commit
84819df
·
verified ·
1 Parent(s): 8135034

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -89,6 +89,20 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
89
  Fetches all questions from the GAIA API, runs the Groq agent on each,
90
  and submits the answers under the authenticated user's profile.
91
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  # ... (Authentication Guard Clause remains the same) ...
93
 
94
  # Check for required API keys for the Groq agent
 
89
  Fetches all questions from the GAIA API, runs the Groq agent on each,
90
  and submits the answers under the authenticated user's profile.
91
  """
92
+ if profile is None:
93
+ yield "Error: Please log in with your Hugging Face account first."
94
+ return
95
+
96
+ # --- FIX: Define the 'username' variable ---
97
+ try:
98
+ api = HfApi()
99
+ hf_user = api.whoami(token=profile.token)
100
+ username = hf_user['name']
101
+ yield f"Authenticated as Hugging Face user: {username}"
102
+ except Exception as e:
103
+ yield f"Error during Hugging Face authentication: {e}"
104
+ return
105
+ # --- END FIX ---
106
  # ... (Authentication Guard Clause remains the same) ...
107
 
108
  # Check for required API keys for the Groq agent