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.
Remove unused function `split_file` from file_operations.py (#4658)
Reinier van der Leera9d177eeeb7b
diff --git a/autogpt/commands/file_operations.py b/autogpt/commands/file_operations.pyindex 5d9649be5f..a0a6153905 100644--- a/autogpt/commands/file_operations.py+++ b/autogpt/commands/file_operations.py@@ -119,38 +119,6 @@ def log_operation()-def split_file(- content: str, max_length: int = 4000, overlap: int = 0-) -> Generator[str, None, None]:- """- Split text into chunks of a specified maximum length with a specified overlap- between chunks.-- :param content: The input text to be split into chunks- :param max_length: The maximum length of each chunk,- default is 4000 (about 1k token)- :param overlap: The number of overlapping characters between chunks,- default is no overlap- :return: A generator yielding chunks of text- """- start = 0- content_length = len(content)-- while start < content_length:- end = start + max_length- if end + overlap < content_length:- chunk = content[start : end + max(overlap - 1, 0)]- else:- chunk = content[start:content_length]-- # Account for the case where the last chunk is shorter than the overlap, so it has already been consumed- if len(chunk) <= overlap:- break-- yield chunk- start += max_length - overlap--@command("read_file", "Read a file", '"filename": "<filename>"')def read_file(filename: str, agent: Agent) -> str:"""Read a file and return the contentsdiff --git a/tests/unit/test_file_operations.py b/tests/unit/test_file_operations.pyindex d3e6991d4b..27af937374 100644--- a/tests/unit/test_file_operations.py+++ b/tests/unit/test_file_operations.py@@ -188,43 +188,6 @@ def test_log_operation_with_checksum(agent: Agent):assert f"log_test: path/to/test #ABCDEF\n" in content- "max_length, overlap, content, expected",- [- (- 4,- 1,- "abcdefghij",- ["abcd", "defg", "ghij"],- ),- (- 4,- 0,- "abcdefghijkl",- ["abcd", "efgh", "ijkl"],- ),- (- 4,- 0,- "abcdefghijklm",- ["abcd", "efgh", "ijkl", "m"],- ),- (- 4,- 0,- "abcdefghijk",- ["abcd", "efgh", "ijk"],- ),- ],-)-# Test splitting a file into chunks-def test_split_file(max_length, overlap, content, expected):- assert (- list(file_ops.split_file(content, max_length=max_length, overlap=overlap))- == expected- )--def test_read_file(mock_MemoryItem_from_text,test_file_with_content_path: Path,