Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,23 +18,34 @@ def run_and_submit_all():
|
|
| 18 |
if not tasks:
|
| 19 |
return "No tasks loaded from metadata.jsonl. Make sure the file exists and is valid."
|
| 20 |
|
|
|
|
|
|
|
| 21 |
answers = []
|
| 22 |
-
for task in tasks:
|
|
|
|
|
|
|
| 23 |
try:
|
| 24 |
result = solve_task(task, model)
|
|
|
|
| 25 |
if not result.get("submitted_answer"): # Check empty responses
|
|
|
|
| 26 |
result["submitted_answer"] = "ERROR: Empty model response"
|
|
|
|
|
|
|
|
|
|
| 27 |
answers.append(result)
|
|
|
|
| 28 |
except Exception as e:
|
|
|
|
| 29 |
answers.append({
|
| 30 |
"question_id": task.get("question_id", "UNKNOWN"),
|
| 31 |
"submitted_answer": f"ERROR: {str(e)}"
|
| 32 |
})
|
| 33 |
|
| 34 |
-
# Debug
|
| 35 |
if not answers:
|
| 36 |
-
return "
|
| 37 |
|
|
|
|
| 38 |
res = requests.post(
|
| 39 |
"https://agents-course-unit4-scoring.hf.space/submit",
|
| 40 |
headers={"Content-Type": "application/json"},
|
|
@@ -46,7 +57,10 @@ def run_and_submit_all():
|
|
| 46 |
)
|
| 47 |
|
| 48 |
if res.ok:
|
|
|
|
| 49 |
return json.dumps(res.json(), indent=2)
|
|
|
|
|
|
|
| 50 |
return f"Error submitting: {res.status_code} - {res.text}"
|
| 51 |
|
| 52 |
# Gradio interface
|
|
|
|
| 18 |
if not tasks:
|
| 19 |
return "No tasks loaded from metadata.jsonl. Make sure the file exists and is valid."
|
| 20 |
|
| 21 |
+
print(f"[INFO] Loaded {len(tasks)} tasks from metadata.jsonl")
|
| 22 |
+
|
| 23 |
answers = []
|
| 24 |
+
for i, task in enumerate(tasks):
|
| 25 |
+
print(f"[INFO] Solving task {i+1}/{len(tasks)}: {task.get('question_id', 'N/A')}")
|
| 26 |
+
|
| 27 |
try:
|
| 28 |
result = solve_task(task, model)
|
| 29 |
+
|
| 30 |
if not result.get("submitted_answer"): # Check empty responses
|
| 31 |
+
print("[WARN] Empty model response detected")
|
| 32 |
result["submitted_answer"] = "ERROR: Empty model response"
|
| 33 |
+
else:
|
| 34 |
+
print(f"Answer: {result['submitted_answer'][:100]}...")
|
| 35 |
+
|
| 36 |
answers.append(result)
|
| 37 |
+
|
| 38 |
except Exception as e:
|
| 39 |
+
print(f"[ERROR] Task failed: {e}")
|
| 40 |
answers.append({
|
| 41 |
"question_id": task.get("question_id", "UNKNOWN"),
|
| 42 |
"submitted_answer": f"ERROR: {str(e)}"
|
| 43 |
})
|
| 44 |
|
|
|
|
| 45 |
if not answers:
|
| 46 |
+
return "No answers generated. Check model response."
|
| 47 |
|
| 48 |
+
print("[INFO] Submitting answers to GAIA benchmark API...")
|
| 49 |
res = requests.post(
|
| 50 |
"https://agents-course-unit4-scoring.hf.space/submit",
|
| 51 |
headers={"Content-Type": "application/json"},
|
|
|
|
| 57 |
)
|
| 58 |
|
| 59 |
if res.ok:
|
| 60 |
+
print(" Submission successful.")
|
| 61 |
return json.dumps(res.json(), indent=2)
|
| 62 |
+
|
| 63 |
+
print(f"[ERROR] Submission failed: {res.status_code} - {res.text}")
|
| 64 |
return f"Error submitting: {res.status_code} - {res.text}"
|
| 65 |
|
| 66 |
# Gradio interface
|