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.

Update file_operations.py

Andres Caicedo1d10236a63e4
diff --git a/scripts/file_operations.py b/scripts/file_operations.py
index 65664e609d..cb0546168c 100644
--- a/scripts/file_operations.py
+++ b/scripts/file_operations.py
@@ -3,6 +3,7 @@ import os.path
# Set a dedicated folder for file I/O
working_directory = "auto_gpt_workspace"
+
# Create the directory if it doesn't exist
if not os.path.exists(working_directory):
os.makedirs(working_directory)
@@ -35,8 +36,10 @@ def write_to_file(filename, text):
try:
filepath = safe_join(working_directory, filename)
directory = os.path.dirname(filepath)
+
if not os.path.exists(directory):
os.makedirs(directory)
+
with open(filepath, "w") as f:
f.write(text)
return "File written to successfully."