Adds write_to_file command.

This commit is contained in:
Torantulino
2023-03-30 10:08:13 +01:00
parent 0c9bbbd20c
commit acbf0dc701
2 changed files with 18 additions and 0 deletions

View File

@@ -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: ###

View File

@@ -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: