Spaces:
Sleeping
Sleeping
Fix OAuth integration: Add LoginButton back and update function signature for proper HF Spaces deployment
Browse files
app.py
CHANGED
|
@@ -28,14 +28,21 @@ class BasicAgent:
|
|
| 28 |
return fixed_answer
|
| 29 |
|
| 30 |
|
| 31 |
-
def run_and_submit_all(
|
| 32 |
"""
|
| 33 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 34 |
and displays the results.
|
| 35 |
"""
|
| 36 |
# Determine HF Space Runtime URL and Repo URL
|
| 37 |
space_id = os.getenv("SPACE_ID", "unknown_space")
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
print(f"Running as user: {username}")
|
| 40 |
|
| 41 |
api_url = DEFAULT_API_URL
|
|
@@ -109,9 +116,13 @@ with gr.Blocks() as demo:
|
|
| 109 |
"""
|
| 110 |
**Instructions:**
|
| 111 |
|
| 112 |
-
|
|
|
|
| 113 |
"""
|
| 114 |
)
|
|
|
|
|
|
|
|
|
|
| 115 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 116 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 117 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
|
|
|
| 28 |
return fixed_answer
|
| 29 |
|
| 30 |
|
| 31 |
+
def run_and_submit_all(profile: gr.OAuthProfile | None = None):
|
| 32 |
"""
|
| 33 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 34 |
and displays the results.
|
| 35 |
"""
|
| 36 |
# Determine HF Space Runtime URL and Repo URL
|
| 37 |
space_id = os.getenv("SPACE_ID", "unknown_space")
|
| 38 |
+
|
| 39 |
+
if profile:
|
| 40 |
+
username = f"{profile.username}"
|
| 41 |
+
print(f"User logged in: {username}")
|
| 42 |
+
else:
|
| 43 |
+
print("User not logged in, using anonymous.")
|
| 44 |
+
username = "anonymous"
|
| 45 |
+
|
| 46 |
print(f"Running as user: {username}")
|
| 47 |
|
| 48 |
api_url = DEFAULT_API_URL
|
|
|
|
| 116 |
"""
|
| 117 |
**Instructions:**
|
| 118 |
|
| 119 |
+
1. Login to Hugging Face using the button below (required for submission)
|
| 120 |
+
2. Click 'Run Evaluation & Submit All Answers' to fetch, run the agent, and submit.
|
| 121 |
"""
|
| 122 |
)
|
| 123 |
+
|
| 124 |
+
gr.LoginButton()
|
| 125 |
+
|
| 126 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 127 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 128 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|