Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

fix one line content (\\n issue) for editor

garylin2099d57d4f3c01bb
diff --git a/metagpt/tools/libs/editor.py b/metagpt/tools/libs/editor.py
index 23df02edd..eba1a1eac 100644
--- a/metagpt/tools/libs/editor.py
+++ b/metagpt/tools/libs/editor.py
@@ -1,4 +1,5 @@
import os
+import re
import shutil
import subprocess
@@ -26,6 +27,9 @@ class Editor:
def write(self, path: str, content: str):
"""Write the whole content to a file. When used, make sure content arg contains the full content of the file."""
+ if len(re.findall(r"\\n", content)) >= 5:
+ # A very raw rule to correct the content: Many \\n suggests all new line characters are mistaken as \\n whereas the correct one should be \n
+ content = content.replace("\\n", "\n")
directory = os.path.dirname(path)
if directory and not os.path.exists(directory):
os.makedirs(directory)