mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-02-10 16:54:20 +01:00
Adds write_to_file command.
This commit is contained in:
@@ -50,6 +50,8 @@ def execute_command(command_name, arguments):
|
||||
return register_account(arguments["username"], arguments["website"])
|
||||
elif command_name == "get_text_summary":
|
||||
return get_text_summary(arguments["url"])
|
||||
elif command_name == "write_to_file":
|
||||
return write_to_file(arguments["file"], arguments["content"])
|
||||
else:
|
||||
return f"unknown command {command_name}"
|
||||
# All other errors, return "Error: + error message"
|
||||
@@ -103,6 +105,21 @@ def overwrite_memory(key, string):
|
||||
else:
|
||||
print("Invalid key, cannot overwrite memory.")
|
||||
return None
|
||||
|
||||
def write_to_file(filename, content):
|
||||
try:
|
||||
f = open(filename, "w")
|
||||
f.write(content)
|
||||
f.close()
|
||||
except Exception as e:
|
||||
return "Error: " + str(e)
|
||||
return "File written to successfully."
|
||||
|
||||
def shutdown():
|
||||
print("Shutting down...")
|
||||
quit()
|
||||
|
||||
|
||||
|
||||
|
||||
### TODO: Not Yet Implemented: ###
|
||||
|
||||
@@ -17,6 +17,7 @@ COMMANDS:
|
||||
10. Delete GPT Agent: "delete_agent", args: "key": "<key>"
|
||||
9. Navigate & Perform: "navigate_website", args: "action": "click_button/input_text/register_account", "text/username": "<text>/<username>"
|
||||
11. Get Text Summary: "get_text_summary", args: "url": "<url>"
|
||||
13. Write to file: "write_to_file", args: "file": "<file>", "text": "<text>"
|
||||
|
||||
RESOURCES:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user