Update app.py
Browse files
app.py
CHANGED
|
@@ -609,12 +609,30 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 609 |
|
| 610 |
# Download the attachment (if the task has one) and point the agent at it.
|
| 611 |
# download_attachment never raises; it returns None if there is no file.
|
|
|
|
|
|
|
|
|
|
| 612 |
attachment_path = download_attachment(api_url, task_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 613 |
agent_question = question_text
|
| 614 |
if attachment_path:
|
| 615 |
agent_question += (
|
| 616 |
-
f"\n\nAn attached file for this task
|
| 617 |
-
f"{attachment_path}
|
|
|
|
|
|
|
| 618 |
)
|
| 619 |
|
| 620 |
try:
|
|
|
|
| 609 |
|
| 610 |
# Download the attachment (if the task has one) and point the agent at it.
|
| 611 |
# download_attachment never raises; it returns None if there is no file.
|
| 612 |
+
# The /questions endpoint includes "file_name" only for tasks that have an
|
| 613 |
+
# attachment, so we know in advance whether a file is required.
|
| 614 |
+
expected_file = item.get("file_name")
|
| 615 |
attachment_path = download_attachment(api_url, task_id)
|
| 616 |
+
|
| 617 |
+
if expected_file and not attachment_path:
|
| 618 |
+
# The task needs a file but the server didn't give us one. Running the
|
| 619 |
+
# agent would only produce a guess or a refusal, so skip it cleanly.
|
| 620 |
+
print(f"Task {task_id} requires '{expected_file}' but it could not be downloaded; skipping.")
|
| 621 |
+
results_log.append({
|
| 622 |
+
"Task ID": task_id,
|
| 623 |
+
"Question": question_text,
|
| 624 |
+
"Submitted Answer": "",
|
| 625 |
+
"Status": f"ATTACHMENT MISSING: {expected_file}",
|
| 626 |
+
})
|
| 627 |
+
continue
|
| 628 |
+
|
| 629 |
agent_question = question_text
|
| 630 |
if attachment_path:
|
| 631 |
agent_question += (
|
| 632 |
+
f"\n\nAn attached file for this task (original name: "
|
| 633 |
+
f"{expected_file or os.path.basename(attachment_path)}) is saved "
|
| 634 |
+
f"locally at: {attachment_path}\n"
|
| 635 |
+
f"Use the read_attachment tool to read it."
|
| 636 |
)
|
| 637 |
|
| 638 |
try:
|