Spaces:
Sleeping
Sleeping
Joachim M. Vis commited on
Upload app.py
Browse files
app.py
CHANGED
|
@@ -18,26 +18,20 @@ if VERBOSE:
|
|
| 18 |
else:
|
| 19 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
| 20 |
|
| 21 |
-
def run_and_submit_all(
|
| 22 |
"""
|
| 23 |
Fetches all questions, runs the GAIA Agent on them, submits all answers,
|
| 24 |
and displays the results with progress tracking.
|
| 25 |
|
| 26 |
Args:
|
| 27 |
-
|
| 28 |
progress: Gradio progress tracker
|
| 29 |
|
| 30 |
Returns:
|
| 31 |
Tuple containing status message and results dataframe
|
| 32 |
"""
|
| 33 |
space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
| 34 |
-
|
| 35 |
-
if not profile:
|
| 36 |
-
logger.warning("User not logged in.")
|
| 37 |
-
return "Please Login to Hugging Face with the button. OAuth login is required for assessment submission.", None
|
| 38 |
-
|
| 39 |
-
username = f"{profile.username}"
|
| 40 |
-
logger.info(f"User logged in: {username}")
|
| 41 |
|
| 42 |
api_url = DEFAULT_API_URL
|
| 43 |
questions_url = f"{api_url}/questions"
|
|
@@ -217,67 +211,52 @@ def run_and_submit_all(profile: Optional[gr.OAuthProfile] = None, progress=gr.Pr
|
|
| 217 |
space_host = os.getenv("SPACE_HOST")
|
| 218 |
|
| 219 |
# Import HfApi for OAuth functionality
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
try:
|
| 229 |
-
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 230 |
-
gr.Markdown("# GAIA Agent Evaluation Runner")
|
| 231 |
-
with gr.Tabs():
|
| 232 |
-
with gr.TabItem("Run Evaluation"):
|
| 233 |
-
gr.Markdown(
|
| 234 |
-
"""
|
| 235 |
-
**Instructions:**
|
| 236 |
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
except Exception as e:
|
| 257 |
-
logger.error(f"Error creating Gradio interface: {e}")
|
| 258 |
-
# Fallback to a simpler interface without OAuth
|
| 259 |
-
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 260 |
-
gr.Markdown("# GAIA Agent Evaluation Runner (Simplified Mode)")
|
| 261 |
-
gr.Markdown("**Note:** Running in simplified mode without OAuth authentication.")
|
| 262 |
-
run_button = gr.Button("Run Evaluation & Submit All Answers", variant="primary", size="lg")
|
| 263 |
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
)
|
| 270 |
-
|
| 271 |
-
results_accordion = gr.Accordion("Results", open=False, elem_id="results_accordion")
|
| 272 |
-
with results_accordion:
|
| 273 |
-
results_table = gr.DataFrame(
|
| 274 |
-
label="Questions and Agent Answers",
|
| 275 |
-
wrap=True,
|
| 276 |
-
elem_id="results_table"
|
| 277 |
)
|
| 278 |
|
| 279 |
-
|
| 280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
gr.Markdown("### Result Statistics")
|
| 282 |
stats_output = gr.JSON(label="Statistics", visible=True)
|
| 283 |
|
|
@@ -338,6 +317,7 @@ except Exception as e:
|
|
| 338 |
|
| 339 |
run_button.click(
|
| 340 |
fn=run_and_submit_all,
|
|
|
|
| 341 |
outputs=[status_output, results_table]
|
| 342 |
).then(
|
| 343 |
fn=lambda df: {
|
|
@@ -353,16 +333,6 @@ except Exception as e:
|
|
| 353 |
outputs=[results_accordion]
|
| 354 |
)
|
| 355 |
|
| 356 |
-
# Add note that OAuth is required
|
| 357 |
-
gr.Markdown(
|
| 358 |
-
"""
|
| 359 |
-
## [WARNING] Important Note
|
| 360 |
-
|
| 361 |
-
This GAIA Assessment requires OAuth login for submission to the leaderboard.
|
| 362 |
-
Please make sure to log in with your Hugging Face account before running the evaluation.
|
| 363 |
-
"""
|
| 364 |
-
)
|
| 365 |
-
|
| 366 |
if __name__ == "__main__":
|
| 367 |
space_host_startup = os.getenv("SPACE_HOST")
|
| 368 |
space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
|
|
|
|
| 18 |
else:
|
| 19 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
| 20 |
|
| 21 |
+
def run_and_submit_all(username: str = "anonymous", progress=gr.Progress()) -> Tuple[str, Optional[pd.DataFrame]]:
|
| 22 |
"""
|
| 23 |
Fetches all questions, runs the GAIA Agent on them, submits all answers,
|
| 24 |
and displays the results with progress tracking.
|
| 25 |
|
| 26 |
Args:
|
| 27 |
+
username: Username for submission (default: anonymous)
|
| 28 |
progress: Gradio progress tracker
|
| 29 |
|
| 30 |
Returns:
|
| 31 |
Tuple containing status message and results dataframe
|
| 32 |
"""
|
| 33 |
space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
|
| 34 |
+
logger.info(f"Running with username: {username}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
api_url = DEFAULT_API_URL
|
| 37 |
questions_url = f"{api_url}/questions"
|
|
|
|
| 211 |
space_host = os.getenv("SPACE_HOST")
|
| 212 |
|
| 213 |
# Import HfApi for OAuth functionality
|
| 214 |
+
# Create Gradio interface without OAuth
|
| 215 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 216 |
+
gr.Markdown("# GAIA Agent Evaluation Runner")
|
| 217 |
+
with gr.Tabs():
|
| 218 |
+
with gr.TabItem("Run Evaluation"):
|
| 219 |
+
gr.Markdown(
|
| 220 |
+
"""
|
| 221 |
+
**Instructions:**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
+
1. Enter your username (optional) for submission tracking.
|
| 224 |
+
2. Click 'Run Evaluation & Submit All Answers' to fetch questions, run the GAIA agent, submit answers, and see the score.
|
| 225 |
+
3. The progress bar will show you the current status of the evaluation.
|
| 226 |
+
4. Results will appear in the table below once processing is complete.
|
| 227 |
|
| 228 |
+
**Note:** Running the evaluation may take some time as the agent processes all questions. Please be patient.
|
| 229 |
+
"""
|
| 230 |
+
)
|
| 231 |
|
| 232 |
+
with gr.Row():
|
| 233 |
+
with gr.Column(scale=1):
|
| 234 |
+
username_input = gr.Textbox(
|
| 235 |
+
label="Username (optional)",
|
| 236 |
+
placeholder="Enter username for submission",
|
| 237 |
+
value="anonymous"
|
| 238 |
+
)
|
| 239 |
+
with gr.Column(scale=2):
|
| 240 |
+
run_button = gr.Button("Run Evaluation & Submit All Answers",
|
| 241 |
+
variant="primary", size="lg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
+
status_output = gr.Textbox(
|
| 244 |
+
label="Run Status / Submission Result",
|
| 245 |
+
lines=6,
|
| 246 |
+
interactive=False,
|
| 247 |
+
elem_id="status_output"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
)
|
| 249 |
|
| 250 |
+
results_accordion = gr.Accordion("Results", open=False, elem_id="results_accordion")
|
| 251 |
+
with results_accordion:
|
| 252 |
+
results_table = gr.DataFrame(
|
| 253 |
+
label="Questions and Agent Answers",
|
| 254 |
+
wrap=True,
|
| 255 |
+
elem_id="results_table"
|
| 256 |
+
)
|
| 257 |
+
|
| 258 |
+
with gr.Row():
|
| 259 |
+
with gr.Column():
|
| 260 |
gr.Markdown("### Result Statistics")
|
| 261 |
stats_output = gr.JSON(label="Statistics", visible=True)
|
| 262 |
|
|
|
|
| 317 |
|
| 318 |
run_button.click(
|
| 319 |
fn=run_and_submit_all,
|
| 320 |
+
inputs=[username_input],
|
| 321 |
outputs=[status_output, results_table]
|
| 322 |
).then(
|
| 323 |
fn=lambda df: {
|
|
|
|
| 333 |
outputs=[results_accordion]
|
| 334 |
)
|
| 335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
if __name__ == "__main__":
|
| 337 |
space_host_startup = os.getenv("SPACE_HOST")
|
| 338 |
space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
|