🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
create parent folder in Editor.create_file
黄伟韬58907d0dbb75
diff --git a/metagpt/tools/libs/editor.py b/metagpt/tools/libs/editor.pyindex ac92f31b6..c49d33a6e 100644--- a/metagpt/tools/libs/editor.py+++ b/metagpt/tools/libs/editor.py@@ -352,13 +352,14 @@ class Editor(BaseModel):"""Creates and opens a new file with the given name.Args:- filename: str: The name of the file to create.+ filename: str: The name of the file to create. If the parent directory does not exist, it will be created."""filename = self._try_fix_path(filename)if filename.exists():raise FileExistsError(f"File '{filename}' already exists.")-+ if not filename.parent.exists():+ os.makedirs(filename.parent, exist_ok=True)with filename.open("w") as file:file.write("\n")