Skip to content

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.

rename search_files to list_files (#3595)

Richard Bealesc1329c92fde6
diff --git a/autogpt/commands/file_operations.py b/autogpt/commands/file_operations.py
index e9afdaeae5..c54fb0547c 100644
--- a/autogpt/commands/file_operations.py
+++ b/autogpt/commands/file_operations.py
@@ -200,9 +200,9 @@ def delete_file(filename: str) -> str:
return f"Error: {str(e)}"
-@command("search_files", "Search Files", '"directory": "<directory>"')
-def search_files(directory: str) -> list[str]:
- """Search for files in a directory
+@command("list_files", "List Files in Directory", '"directory": "<directory>"')
+def list_files(directory: str) -> list[str]:
+ """lists files in a directory recursively
Args:
directory (str): The directory to search in
diff --git a/tests/unit/test_file_operations.py b/tests/unit/test_file_operations.py
index f324193a54..e7ba2f7190 100644
--- a/tests/unit/test_file_operations.py
+++ b/tests/unit/test_file_operations.py
@@ -13,9 +13,9 @@ from autogpt.commands.file_operations import (
check_duplicate_operation,
delete_file,
download_file,
+ list_files,
log_operation,
read_file,
- search_files,
split_file,
write_to_file,
)
@@ -113,7 +113,7 @@ def test_delete_missing_file(test_file):
assert True, "Failed to test delete_file"
-def test_search_files(config, workspace, test_directory):
+def test_list_files(config, workspace, test_directory):
# Case 1: Create files A and B, search for A, and ensure we don't return A and B
file_a = workspace.get_path("file_a.txt")
file_b = workspace.get_path("file_b.txt")
@@ -131,7 +131,7 @@ def test_search_files(config, workspace, test_directory):
with open(os.path.join(test_directory, file_a.name), "w") as f:
f.write("This is file A in the subdirectory.")
- files = search_files(str(workspace.root))
+ files = list_files(str(workspace.root))
assert file_a.name in files
assert file_b.name in files
assert os.path.join(Path(test_directory).name, file_a.name) in files
@@ -144,7 +144,7 @@ def test_search_files(config, workspace, test_directory):
# Case 2: Search for a file that does not exist and make sure we don't throw
non_existent_file = "non_existent_file.txt"
- files = search_files("")
+ files = list_files("")
assert non_existent_file not in files