AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
can now put file extensions or names in files data
Silen Naihin7604ae07bb6d
diff --git a/agbenchmark/Challenge.py b/agbenchmark/Challenge.pyindex 9828a0e9e5..d159296b14 100644--- a/agbenchmark/Challenge.py+++ b/agbenchmark/Challenge.py@@ -1,5 +1,5 @@import os-from typing import Optional+import globfrom agbenchmark.challenges.define_task_types import Ground@@ -14,6 +14,26 @@ class Challenge:with open(workspace_dir, "r") as f:return f.read()+ @staticmethod+ def open_files(workspace: str, file_patterns: list):+ script_dir = os.path.abspath(workspace)+ files_contents = []++ for file_pattern in file_patterns:+ # Check if it is a file extension+ if file_pattern.startswith("."):+ # Find all files with the given extension in the workspace+ matching_files = glob.glob(os.path.join(script_dir, "*" + file_pattern))+ else:+ # Otherwise, it is a specific file+ matching_files = [os.path.join(script_dir, file_pattern)]++ for file_path in matching_files:+ with open(file_path, "r") as f:+ files_contents.append(f.read())++ return files_contents+@staticmethoddef write_to_file(workspace: str, filename: str, content: str):script_dir = os.path.abspath(workspace)diff --git a/agbenchmark/challenges/retrieval/r1/r1_test.py b/agbenchmark/challenges/retrieval/r1/r1_test.pyindex 489d298fbc..2a7d92a71b 100644--- a/agbenchmark/challenges/retrieval/r1/r1_test.py+++ b/agbenchmark/challenges/retrieval/r1/r1_test.py@@ -23,10 +23,12 @@ class TestRetrieval1(RetrievalChallenge):indirect=True,)def test_retrieval(self, workspace, current_challenge_data):- file = self.open_file(workspace, data.ground.files[0])+ files_contents = self.open_files(workspace, data.ground.files)- score = self.scoring(file, data.ground)+ scores = []+ for file_content in files_contents:+ score = self.scoring(file_content, data.ground)+ print("Your score is:", score)+ scores.append(score)- print("You score is:", score)-- assert score+ assert 1 in scoresdiff --git a/agbenchmark/tests/basic_abilities/read_file/read_file_test.py b/agbenchmark/tests/basic_abilities/read_file/read_file_test.pyindex 7d14228c89..90946670c0 100644--- a/agbenchmark/tests/basic_abilities/read_file/read_file_test.py+++ b/agbenchmark/tests/basic_abilities/read_file/read_file_test.py@@ -32,10 +32,12 @@ class TestReadFile(BasicChallenge):)@pytest.mark.depends(on=data.dependencies)def test_read_file(self, workspace):- file = self.open_file(workspace, data.ground.files[0])+ files_contents = self.open_files(workspace, data.ground.files)- score = self.scoring(file, data.ground)+ scores = []+ for file_content in files_contents:+ score = self.scoring(file_content, data.ground)+ print("Your score is:", score)+ scores.append(score)- print("You score is:", score)-- assert score+ assert 1 in scoresdiff --git a/agbenchmark/tests/basic_abilities/write_file/w_file_data.json b/agbenchmark/tests/basic_abilities/write_file/w_file_data.jsonindex 1d26210815..037c5bd887 100644--- a/agbenchmark/tests/basic_abilities/write_file/w_file_data.json+++ b/agbenchmark/tests/basic_abilities/write_file/w_file_data.json@@ -6,7 +6,7 @@"answer": "Washington","should_contain": ["Washington"],"should_not_contain": ["New York", "Los Angeles", "San Francisco"],- "files": ["file_to_check.txt"]+ "files": [".txt"]},"mock_func": "basic_write_file_mock","info": {diff --git a/agbenchmark/tests/basic_abilities/write_file/write_file_test.py b/agbenchmark/tests/basic_abilities/write_file/write_file_test.pyindex 330128898b..187378ff1c 100644--- a/agbenchmark/tests/basic_abilities/write_file/write_file_test.py+++ b/agbenchmark/tests/basic_abilities/write_file/write_file_test.py@@ -23,10 +23,12 @@ class TestWriteFile(BasicChallenge):)@pytest.mark.depends(name="test_write_file")def test_write_file(self, workspace):- file = self.open_file(workspace, data.ground.files[0])+ files_contents = self.open_files(workspace, data.ground.files)- score = self.scoring(file, data.ground)+ scores = []+ for file_content in files_contents:+ score = self.scoring(file_content, data.ground)+ print("Your score is:", score)+ scores.append(score)- print("You score is:", score)-- assert score+ assert 1 in scoresdiff --git a/agbenchmark/tests/regression/regression_tests.json b/agbenchmark/tests/regression/regression_tests.jsonindex 9e26dfeeb6..c84fc9c990 100644--- a/agbenchmark/tests/regression/regression_tests.json+++ b/agbenchmark/tests/regression/regression_tests.json@@ -1 +1,14 @@-{}\ No newline at end of file+{+ "TestWriteFile": {+ "difficulty": "basic",+ "dependencies": [],+ "test": "agbenchmark/tests/basic_abilities/write_file/write_file_test.py::TestWriteFile::test_write_file[regression_data0-server_response0]"+ },+ "TestReadFile": {+ "difficulty": "basic",+ "dependencies": [+ "test_write_file"+ ],+ "test": "agbenchmark/tests/basic_abilities/read_file/read_file_test.py::TestReadFile::test_read_file[regression_data0-server_response0]"+ }+}\ No newline at end of file