Update app.py
Browse files
app.py
CHANGED
@@ -237,8 +237,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
237 |
print(f"Skipping item with missing task_id or question: {item}")
|
238 |
continue
|
239 |
try:
|
240 |
-
|
241 |
-
submitted_answer = msg["content"][0]["text"]
|
242 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
243 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
244 |
except Exception as e:
|
@@ -304,11 +303,9 @@ with gr.Blocks() as demo:
|
|
304 |
gr.Markdown(
|
305 |
"""
|
306 |
**Instructions:**
|
307 |
-
|
308 |
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
309 |
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
310 |
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
311 |
-
|
312 |
---
|
313 |
**Disclaimers:**
|
314 |
Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
|
@@ -324,20 +321,9 @@ with gr.Blocks() as demo:
|
|
324 |
# Removed max_rows=10 from DataFrame constructor
|
325 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
326 |
|
327 |
-
# # 1) First handler: register the user/run event, skip the queue so it happens immediately
|
328 |
-
# run_button.click(
|
329 |
-
# fn=lambda: None, # no-op or a quick “start” callback
|
330 |
-
# inputs=[],
|
331 |
-
# outputs=[],
|
332 |
-
# queue=False
|
333 |
-
# ).then(
|
334 |
-
# # 2) Second handler: your long‐running generator
|
335 |
-
# fn=run_and_submit_all, # this function must `yield` (status, table)
|
336 |
-
# outputs=[status_output, results_table]
|
337 |
-
# )
|
338 |
run_button.click(
|
339 |
fn=run_and_submit_all,
|
340 |
-
outputs=[status_output, results_table]
|
341 |
)
|
342 |
|
343 |
if __name__ == "__main__":
|
@@ -345,7 +331,6 @@ if __name__ == "__main__":
|
|
345 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|
346 |
space_host_startup = os.getenv("SPACE_HOST")
|
347 |
space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
|
348 |
-
hf_token = os.getenv("HF_TOKEN")
|
349 |
|
350 |
if space_host_startup:
|
351 |
print(f"✅ SPACE_HOST found: {space_host_startup}")
|
@@ -362,9 +347,5 @@ if __name__ == "__main__":
|
|
362 |
|
363 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
364 |
|
365 |
-
# Test the agent
|
366 |
-
# agent = BasicAgent(hf_token=hf_token).agent
|
367 |
-
# agent.run("What is 2+2?")
|
368 |
-
|
369 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
370 |
demo.launch(debug=True, share=False)
|
|
|
237 |
print(f"Skipping item with missing task_id or question: {item}")
|
238 |
continue
|
239 |
try:
|
240 |
+
submitted_answer = agent(question_text)
|
|
|
241 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
242 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
243 |
except Exception as e:
|
|
|
303 |
gr.Markdown(
|
304 |
"""
|
305 |
**Instructions:**
|
|
|
306 |
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
307 |
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
308 |
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
|
|
309 |
---
|
310 |
**Disclaimers:**
|
311 |
Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
|
|
|
321 |
# Removed max_rows=10 from DataFrame constructor
|
322 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
run_button.click(
|
325 |
fn=run_and_submit_all,
|
326 |
+
outputs=[status_output, results_table]
|
327 |
)
|
328 |
|
329 |
if __name__ == "__main__":
|
|
|
331 |
# Check for SPACE_HOST and SPACE_ID at startup for information
|
332 |
space_host_startup = os.getenv("SPACE_HOST")
|
333 |
space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
|
|
|
334 |
|
335 |
if space_host_startup:
|
336 |
print(f"✅ SPACE_HOST found: {space_host_startup}")
|
|
|
347 |
|
348 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
349 |
|
|
|
|
|
|
|
|
|
350 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
351 |
demo.launch(debug=True, share=False)
|