Spaces:
Sleeping
Sleeping
Fix UI and evaluation functionality with simplified app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import pandas as pd
|
|
| 5 |
import logging
|
| 6 |
import time
|
| 7 |
import traceback
|
| 8 |
-
from typing import Dict, Any, Optional, Tuple, List
|
| 9 |
|
| 10 |
# (Keep Constants as is)
|
| 11 |
# --- Constants ---
|
|
@@ -33,7 +33,7 @@ def initialize_agent():
|
|
| 33 |
return None
|
| 34 |
|
| 35 |
# Important: Match the exact signature from the template
|
| 36 |
-
def run_and_submit_all(profile
|
| 37 |
"""
|
| 38 |
Fetches all questions, runs the GAIA Agent on them, submits all answers,
|
| 39 |
and displays the results.
|
|
@@ -41,9 +41,14 @@ def run_and_submit_all(profile: gr.OAuthProfile | None = None):
|
|
| 41 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 42 |
space_id = os.getenv("SPACE_ID", "")
|
| 43 |
|
|
|
|
| 44 |
if profile:
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
else:
|
| 48 |
logger.warning("User not logged in.")
|
| 49 |
return "Please Login to Hugging Face with the button.", None
|
|
@@ -221,18 +226,20 @@ with gr.Blocks() as demo:
|
|
| 221 |
"""
|
| 222 |
)
|
| 223 |
|
| 224 |
-
# Create login button
|
| 225 |
login_btn = gr.LoginButton()
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 230 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 231 |
|
| 232 |
-
#
|
|
|
|
|
|
|
|
|
|
| 233 |
run_button.click(
|
| 234 |
fn=run_and_submit_all,
|
| 235 |
-
inputs=
|
| 236 |
outputs=[status_output, results_table]
|
| 237 |
)
|
| 238 |
|
|
|
|
| 5 |
import logging
|
| 6 |
import time
|
| 7 |
import traceback
|
| 8 |
+
from typing import Dict, Any, Optional, Tuple, List, Union
|
| 9 |
|
| 10 |
# (Keep Constants as is)
|
| 11 |
# --- Constants ---
|
|
|
|
| 33 |
return None
|
| 34 |
|
| 35 |
# Important: Match the exact signature from the template
|
| 36 |
+
def run_and_submit_all(profile=None):
|
| 37 |
"""
|
| 38 |
Fetches all questions, runs the GAIA Agent on them, submits all answers,
|
| 39 |
and displays the results.
|
|
|
|
| 41 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 42 |
space_id = os.getenv("SPACE_ID", "")
|
| 43 |
|
| 44 |
+
# Check if user is signed in
|
| 45 |
if profile:
|
| 46 |
+
if hasattr(profile, 'username'):
|
| 47 |
+
username = profile.username
|
| 48 |
+
logger.info(f"User logged in: {username}")
|
| 49 |
+
else:
|
| 50 |
+
username = str(profile)
|
| 51 |
+
logger.info(f"Using provided username: {username}")
|
| 52 |
else:
|
| 53 |
logger.warning("User not logged in.")
|
| 54 |
return "Please Login to Hugging Face with the button.", None
|
|
|
|
| 226 |
"""
|
| 227 |
)
|
| 228 |
|
| 229 |
+
# Create login button
|
| 230 |
login_btn = gr.LoginButton()
|
| 231 |
+
|
| 232 |
+
# Output text and result areas
|
|
|
|
| 233 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 234 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 235 |
|
| 236 |
+
# Run button
|
| 237 |
+
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 238 |
+
|
| 239 |
+
# Set up event handler (simplified)
|
| 240 |
run_button.click(
|
| 241 |
fn=run_and_submit_all,
|
| 242 |
+
inputs=login_btn, # Connect login button directly
|
| 243 |
outputs=[status_output, results_table]
|
| 244 |
)
|
| 245 |
|