Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -297,17 +297,24 @@ class SmartAgent:
|
|
| 297 |
logging.info("SmartAgent resources cleaned up.")
|
| 298 |
|
| 299 |
# --- Main Run and Submit Function (Modified to use SmartAgent) ---
|
| 300 |
-
def run_and_submit_all(
|
| 301 |
"""
|
| 302 |
Fetches all questions, runs the SmartAgent on them, submits all answers,
|
| 303 |
and displays the results.
|
| 304 |
"""
|
| 305 |
-
|
| 306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
yield "Please Login to Hugging Face with the button.", None
|
| 308 |
return
|
| 309 |
|
| 310 |
-
username = f"{profile.username}"
|
| 311 |
logging.info(f"User logged in: {username}")
|
| 312 |
|
| 313 |
api_url = DEFAULT_API_URL # This is used for questions, submit, agent management, and tool code
|
|
@@ -472,10 +479,10 @@ with gr.Blocks() as demo:
|
|
| 472 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 473 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 474 |
|
| 475 |
-
# The click event
|
| 476 |
run_button.click(
|
| 477 |
fn=run_and_submit_all,
|
| 478 |
-
inputs=[
|
| 479 |
outputs=[status_output, results_table],
|
| 480 |
show_progress=True, # Show Gradio's internal progress bar
|
| 481 |
)
|
|
|
|
| 297 |
logging.info("SmartAgent resources cleaned up.")
|
| 298 |
|
| 299 |
# --- Main Run and Submit Function (Modified to use SmartAgent) ---
|
| 300 |
+
def run_and_submit_all():
|
| 301 |
"""
|
| 302 |
Fetches all questions, runs the SmartAgent on them, submits all answers,
|
| 303 |
and displays the results.
|
| 304 |
"""
|
| 305 |
+
# Get the current user from Gradio's OAuth system
|
| 306 |
+
try:
|
| 307 |
+
user_info = gr.user_info()
|
| 308 |
+
if not user_info or not user_info.get("username"):
|
| 309 |
+
logging.info("User not logged in.")
|
| 310 |
+
yield "Please Login to Hugging Face with the button.", None
|
| 311 |
+
return
|
| 312 |
+
username = user_info["username"]
|
| 313 |
+
except Exception as e:
|
| 314 |
+
logging.error(f"Error getting user info: {e}")
|
| 315 |
yield "Please Login to Hugging Face with the button.", None
|
| 316 |
return
|
| 317 |
|
|
|
|
| 318 |
logging.info(f"User logged in: {username}")
|
| 319 |
|
| 320 |
api_url = DEFAULT_API_URL # This is used for questions, submit, agent management, and tool code
|
|
|
|
| 479 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 480 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 481 |
|
| 482 |
+
# The click event passes the profile from the login state
|
| 483 |
run_button.click(
|
| 484 |
fn=run_and_submit_all,
|
| 485 |
+
inputs=[], # No inputs needed - profile comes from OAuth
|
| 486 |
outputs=[status_output, results_table],
|
| 487 |
show_progress=True, # Show Gradio's internal progress bar
|
| 488 |
)
|