Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Enh: load_file to recognize .traj ending

Kilian Lieret340ea6757e03
diff --git a/sweagent/utils/files.py b/sweagent/utils/files.py
index e10f868e..e78ecbb0 100644
--- a/sweagent/utils/files.py
+++ b/sweagent/utils/files.py
@@ -5,17 +5,19 @@ from typing import Any
import yaml
-def load_file(path: Path | None) -> Any:
+def load_file(path: Path | str | None) -> Any:
"""Load files based on their extension."""
if path is None:
return None
+ if isinstance(path, str):
+ path = Path(path)
if not path.exists():
raise FileNotFoundError(path)
if path.is_dir():
from datasets import load_from_disk
return load_from_disk(path)
- if path.suffix == ".json":
+ if path.suffix in [".json", ".traj"]:
return json.loads(path.read_text())
if path.suffix == ".jsonl":
return [json.loads(line) for line in path.read_text().splitlines() if line.strip()]