Spaces:
Sleeping
Sleeping
Commit ·
3dacb75
1
Parent(s): a33dabb
added a function to download the element
Browse files- Utils/__init__.py +2 -0
- Utils/download_GAIA_file.py +18 -0
- app.py +2 -2
Utils/__init__.py
CHANGED
|
@@ -12,8 +12,10 @@ from Utils.chains import (
|
|
| 12 |
Base64ImageContent, Base64AudioContent, UrlImageContent,
|
| 13 |
Message, Content, ROLES_PROMPTS, IMAGE_MIME_TYPES
|
| 14 |
)
|
|
|
|
| 15 |
|
| 16 |
__all__ = [
|
|
|
|
| 17 |
'save_results_to_csv',
|
| 18 |
'bytes_to_base64',
|
| 19 |
'open_file_bytes',
|
|
|
|
| 12 |
Base64ImageContent, Base64AudioContent, UrlImageContent,
|
| 13 |
Message, Content, ROLES_PROMPTS, IMAGE_MIME_TYPES
|
| 14 |
)
|
| 15 |
+
from Utils.download_GAIA_file import get_file_path_by_task_id
|
| 16 |
|
| 17 |
__all__ = [
|
| 18 |
+
'get_file_path_by_task_id',
|
| 19 |
'save_results_to_csv',
|
| 20 |
'bytes_to_base64',
|
| 21 |
'open_file_bytes',
|
Utils/download_GAIA_file.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset, DownloadConfig
|
| 2 |
+
|
| 3 |
+
# ⚠️ GAIA ha uno script Python custom → trust_remote_code=True
|
| 4 |
+
ds = load_dataset(
|
| 5 |
+
"gaia-benchmark/GAIA",
|
| 6 |
+
name="2023_level1", # oppure 2023_all, 2023_level2, …
|
| 7 |
+
split="validation",
|
| 8 |
+
trust_remote_code=True, # esegue GAIA.py e usa il DownloadManager
|
| 9 |
+
download_config=DownloadConfig(
|
| 10 |
+
resume_download=False # evita path “fantasma”
|
| 11 |
+
),
|
| 12 |
+
cache_dir="~/.cache/hf_gaia" # dove vuoi tu
|
| 13 |
+
)
|
| 14 |
+
ds_df = ds.to_pandas()
|
| 15 |
+
|
| 16 |
+
def get_file_path_by_task_id(task_id : str) -> str:
|
| 17 |
+
row = ds_df[ds_df['task_id'] == '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3'].to_dict() or {}
|
| 18 |
+
return row.get("file_path", "")
|
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import inspect
|
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
from agent import AgentGraph as Alfred
|
| 9 |
-
|
| 10 |
|
| 11 |
# (Keep Constants as is)
|
| 12 |
# --- Constants ---
|
|
@@ -91,7 +91,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 91 |
print(50 * '*')
|
| 92 |
print(3 * '\n')
|
| 93 |
if file_name or file_path:
|
| 94 |
-
question_text += f"
|
| 95 |
if not task_id or question_text is None:
|
| 96 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 97 |
continue
|
|
|
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
from agent import AgentGraph as Alfred
|
| 9 |
+
from Utils import get_file_path_by_task_id
|
| 10 |
|
| 11 |
# (Keep Constants as is)
|
| 12 |
# --- Constants ---
|
|
|
|
| 91 |
print(50 * '*')
|
| 92 |
print(3 * '\n')
|
| 93 |
if file_name or file_path:
|
| 94 |
+
question_text += f"You can access the file {file_name} at path '{get_file_path_by_task_id(task_id)}' to answer the question"
|
| 95 |
if not task_id or question_text is None:
|
| 96 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 97 |
continue
|