Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -110,4 +110,32 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 110 |
task_id, question_text = item.get("task_id"), item.get("question")
|
| 111 |
if task_id and question_text:
|
| 112 |
submitted_answer = run_agent(agent_executor, question_text)
|
| 113 |
-
answers_payload.append({"task_id": task_id, "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
task_id, question_text = item.get("task_id"), item.get("question")
|
| 111 |
if task_id and question_text:
|
| 112 |
submitted_answer = run_agent(agent_executor, question_text)
|
| 113 |
+
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 114 |
+
|
| 115 |
+
submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
|
| 116 |
+
submit_url = f"https://agents-course-unit4-scoring.hf.space/submit"
|
| 117 |
+
try:
|
| 118 |
+
response = requests.post(submit_url, json=submission_data, timeout=120)
|
| 119 |
+
response.raise_for_status()
|
| 120 |
+
result_data = response.json()
|
| 121 |
+
final_status = (
|
| 122 |
+
f"Submission Successful!\n"
|
| 123 |
+
f"User: {result_data.get('username')}\n"
|
| 124 |
+
f"Overall Score: {result_data.get('score', 'N/A')}% "
|
| 125 |
+
f"({result_data.get('correct_count', '?')}/{result_data.get('total_attempted', '?')} correct)\n"
|
| 126 |
+
f"Message: {result_data.get('message', 'No message received.')}"
|
| 127 |
+
)
|
| 128 |
+
return final_status, pd.DataFrame(answers_payload)
|
| 129 |
+
except Exception as e:
|
| 130 |
+
return f"Error during submission: {e}", pd.DataFrame(answers_payload)
|
| 131 |
+
|
| 132 |
+
with gr.Blocks() as demo:
|
| 133 |
+
gr.Markdown("# Agent Evaluation Runner (LangGraph Final Version)")
|
| 134 |
+
gr.LoginButton()
|
| 135 |
+
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 136 |
+
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 137 |
+
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 138 |
+
run_button.click(fn=run_and_submit_all, outputs=[status_output, results_table])
|
| 139 |
+
|
| 140 |
+
if __name__ == "__main__":
|
| 141 |
+
demo.launch()
|