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 delete file
Merwane Hamadib6d9c3ab0335
diff --git a/autogpt/agents/base.py b/autogpt/agents/base.pyindex c0133ea7c3..029b07a05a 100644--- a/autogpt/agents/base.py+++ b/autogpt/agents/base.py@@ -11,7 +11,7 @@ if TYPE_CHECKING:from autogpt.llm.base import ChatModelResponse, ChatSequence, Messagefrom autogpt.llm.providers.openai import OPEN_AI_CHAT_MODELS, get_openai_command_specsfrom autogpt.llm.utils import count_message_tokens, create_chat_completion-from autogpt.logs import logger+from autogpt.logs import CURRENT_CONTEXT_FILE_NAME, loggerfrom autogpt.memory.message_history import MessageHistoryfrom autogpt.prompts.prompt import DEFAULT_TRIGGERING_PROMPT@@ -105,7 +105,13 @@ class BaseAgent(metaclass=ABCMeta):prompt: ChatSequence = self.construct_prompt(instruction)prompt = self.on_before_think(prompt, instruction)-+ self.log_cycle_handler.log_cycle(+ self.ai_config.ai_name,+ self.created_at,+ self.cycle_count,+ prompt.raw(),+ CURRENT_CONTEXT_FILE_NAME,+ )raw_response = create_chat_completion(prompt,self.config,diff --git a/autogpt/commands/file_operations.py b/autogpt/commands/file_operations.pyindex 939b7dc181..715a90aebf 100644--- a/autogpt/commands/file_operations.py+++ b/autogpt/commands/file_operations.py@@ -274,37 +274,6 @@ def append_to_file(return f"Error: {err}"-@command(- "delete_file",- "Deletes a file",- {- "filename": {- "type": "string",- "description": "The name of the file to delete",- "required": True,- }- },-)-@sanitize_path_arg("filename")-def delete_file(filename: str, agent: Agent) -> str:- """Delete a file-- Args:- filename (str): The name of the file to delete-- Returns:- str: A message indicating success or failure- """- if is_duplicate_operation("delete", filename, agent):- return "Error: File has already been deleted."- try:- os.remove(filename)- log_operation("delete", filename, agent)- return "File deleted successfully."- except Exception as err:- return f"Error: {err}"--@command("list_files","Lists Files in a Directory",diff --git a/autogpt/core/planning/templates.py b/autogpt/core/planning/templates.pyindex e28f2ed75d..59792f6564 100644--- a/autogpt/core/planning/templates.py+++ b/autogpt/core/planning/templates.py@@ -17,7 +17,6 @@ ABILITIES = ('analyze_code: Analyze Code, args: "code": "<full_code_string>"','execute_python_file: Execute Python File, args: "filename": "<filename>"','append_to_file: Append to file, args: "filename": "<filename>", "text": "<text>"',- 'delete_file: Delete file, args: "filename": "<filename>"','list_files: List Files in Directory, args: "directory": "<directory>"','read_file: Read a file, args: "filename": "<filename>"','write_to_file: Write to file, args: "filename": "<filename>", "text": "<text>"',diff --git a/tests/unit/test_file_operations.py b/tests/unit/test_file_operations.pyindex d7d870a592..b3f1fb8f82 100644--- a/tests/unit/test_file_operations.py+++ b/tests/unit/test_file_operations.py@@ -282,24 +282,6 @@ def test_append_to_file_uses_checksum_from_appended_file()-def test_delete_file(test_file_with_content_path: Path, agent: Agent):- result = file_ops.delete_file(str(test_file_with_content_path), agent=agent)- assert result == "File deleted successfully."- assert os.path.exists(test_file_with_content_path) is False---def test_delete_missing_file(agent: Agent):- filename = "path/to/file/which/does/not/exist"- # confuse the log- file_ops.log_operation("write", filename, agent=agent, checksum="fake")- try:- os.remove(agent.workspace.get_path(filename))- except FileNotFoundError as err:- assert str(err) in file_ops.delete_file(filename, agent=agent)- return- assert False, f"Failed to test delete_file; {filename} not expected to exist"--def test_list_files(workspace: Workspace, test_directory: Path, agent: Agent):# Case 1: Create files A and B, search for A, and ensure we don't return A and Bfile_a = workspace.get_path("file_a.txt")