Update app.py
Browse files216 unmodified lines217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253216 unmodified linesdef dataset_fallback_file(task_id: str, hf_token: str):"""Use the gated GAIA validation metadata to locate the exact attachment."""try:from datasets import load_datasetds = load_dataset(GAIA_DATASET,"2023_level1",split="validation",token=hf_token,)matches = ds.filter(lambda row: row["task_id"] == task_id)if len(matches) == 0:return Nonefile_path = matches[0].get("file_path")if not file_path:return Nonereturn hf_hub_download(repo_id=GAIA_DATASET,repo_type="dataset",filename=file_path,token=hf_token,)except Exception as exc:print(f"GAIA dataset fallback unavailable for "f"{task_id}: {type(exc).__name__}: {exc}")raisedef download_task_file(task_id: str, hf_token: str):return download_scoring_file(task_id) or dataset_fallback_file(task_id, hf_token)216 unmodified lines217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270216 unmodified linesdef dataset_fallback_file(task_id: str, hf_token: str):"""Use the GAIA validation dataset to locate the exact attachment."""try:from datasets import load_datasetif not hf_token:raise RuntimeError("HF_TOKEN is empty.")ds = load_dataset(GAIA_DATASET,"2023_level1",split="validation",token=hf_token,)matches = ds.filter(lambda row: row["task_id"] == task_id)if len(matches) == 0:raise RuntimeError(f"Task ID {task_id} was not found in the GAIA validation dataset.")file_path = matches[0].get("file_path")if not file_path:raise RuntimeError(f"Task {task_id} exists, but file_path is empty.")print(f"GAIA attachment file_path: {file_path}")downloaded = hf_hub_download(repo_id=GAIA_DATASET,repo_type="dataset",filename=file_path,token=hf_token,)print(f"GAIA attachment downloaded: {downloaded}")return downloadedexcept Exception as exc:raise RuntimeError(f"GAIA dataset attachment fallback failed: "f"{type(exc).__name__}: {exc}") from excdef download_task_file(task_id: str, hf_token: str):return download_scoring_file(task_id) or dataset_fallback_file(task_id, hf_token)
app.py+28-11