Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -506,38 +506,39 @@ class GaiaRunner:
|
|
| 506 |
_session.mount("https://", _adapter)
|
| 507 |
_session.mount("http://", _adapter)
|
| 508 |
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
ุชูุฒูู ุงูู
ุฑูู ุงูู
ุฑุชุจุท ุจุงูุณุคุงู ู
ู GAIA API ูุชุฎุฒููู ู
ุญูููุง (ุฅู ูุฌุฏ).
|
| 513 |
-
ุฅุฐุง ูู
ููุฌุฏ ุงูู
ุฑูู ุฃู ูุดู ุงูุชุญู
ููุ ุชุนูุฏ ุงูุฏุงูุฉ None.
|
| 514 |
-
"""
|
| 515 |
-
task_id = task.get("task_id")
|
| 516 |
-
file_name = task.get("file_name")
|
| 517 |
|
| 518 |
-
|
| 519 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
|
| 521 |
-
|
| 522 |
-
|
| 523 |
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
|
|
|
|
|
|
|
| 528 |
try:
|
| 529 |
r = requests.get(url, timeout=30)
|
| 530 |
-
if r.status_code == 404:
|
| 531 |
-
print(f"[GAIA] No attachment found on server for task {task_id} (404).")
|
| 532 |
-
return None
|
| 533 |
r.raise_for_status()
|
| 534 |
with open(local_path, "wb") as f:
|
| 535 |
f.write(r.content)
|
| 536 |
print(f"[GAIA] Attachment downloaded: {local_path}")
|
| 537 |
-
return local_path
|
| 538 |
except Exception as e:
|
| 539 |
-
print(f"[GAIA] Failed to download attachment
|
| 540 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
|
| 542 |
# -------------------- LangGraph Integration --------------------
|
| 543 |
if LANGGRAPH_AVAILABLE:
|
|
|
|
| 506 |
_session.mount("https://", _adapter)
|
| 507 |
_session.mount("http://", _adapter)
|
| 508 |
|
| 509 |
+
# @staticmethod
|
| 510 |
+
ATTACHMENTS_DIR = "attachments"
|
| 511 |
+
os.makedirs(ATTACHMENTS_DIR, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 512 |
|
| 513 |
+
def download_gaia_attachment(task: dict) -> str:
|
| 514 |
+
"""
|
| 515 |
+
ุชูุฒูู ุงูู
ุฑูู ุงูู
ุฑุชุจุท ุจุงูุณุคุงู ู
ู GAIA API ูุชุฎุฒููู ู
ุญูููุง.
|
| 516 |
+
"""
|
| 517 |
+
task_id = task.get("task_id")
|
| 518 |
+
file_name = task.get("file_name")
|
| 519 |
|
| 520 |
+
if not task_id or not file_name:
|
| 521 |
+
return None # ูุง ููุฌุฏ ู
ุฑูู
|
| 522 |
|
| 523 |
+
# ุฑุงุจุท API ูุชุญู
ูู ุงูู
ูู
|
| 524 |
+
url = f"https://agents-course-unit4-scoring.hf.space/files/{task_id}"
|
| 525 |
+
local_path = os.path.join(ATTACHMENTS_DIR, file_name)
|
| 526 |
|
| 527 |
+
# ุชูุฒูู ุงูู
ูู ุฅุฐุง ูู
ููู ู
ูุฌูุฏูุง ู
ุญูููุง
|
| 528 |
+
if not os.path.exists(local_path):
|
| 529 |
try:
|
| 530 |
r = requests.get(url, timeout=30)
|
|
|
|
|
|
|
|
|
|
| 531 |
r.raise_for_status()
|
| 532 |
with open(local_path, "wb") as f:
|
| 533 |
f.write(r.content)
|
| 534 |
print(f"[GAIA] Attachment downloaded: {local_path}")
|
|
|
|
| 535 |
except Exception as e:
|
| 536 |
+
print(f"[GAIA] Failed to download attachment: {e}")
|
| 537 |
return None
|
| 538 |
+
else:
|
| 539 |
+
print(f"[GAIA] Attachment already exists: {local_path}")
|
| 540 |
+
|
| 541 |
+
return local_path
|
| 542 |
|
| 543 |
# -------------------- LangGraph Integration --------------------
|
| 544 |
if LANGGRAPH_AVAILABLE:
|