mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 06:24:20 +01:00
Apply autopep8 formatting to entire codebase
This commit is contained in:
@@ -28,6 +28,7 @@ def get_command(response):
|
||||
except Exception as e:
|
||||
return "Error:", str(e)
|
||||
|
||||
|
||||
def execute_command(command_name, arguments):
|
||||
try:
|
||||
if command_name == "google":
|
||||
@@ -41,7 +42,10 @@ def execute_command(command_name, arguments):
|
||||
elif command_name == "memory_ovr":
|
||||
return overwrite_memory(arguments["key"], arguments["string"])
|
||||
elif command_name == "start_agent":
|
||||
return start_agent(arguments["name"], arguments["task"], arguments["prompt"])
|
||||
return start_agent(
|
||||
arguments["name"],
|
||||
arguments["task"],
|
||||
arguments["prompt"])
|
||||
elif command_name == "message_agent":
|
||||
return message_agent(arguments["key"], arguments["message"])
|
||||
elif command_name == "list_agents":
|
||||
@@ -51,7 +55,9 @@ def execute_command(command_name, arguments):
|
||||
elif command_name == "navigate_website":
|
||||
return navigate_website(arguments["action"], arguments["username"])
|
||||
elif command_name == "register_account":
|
||||
return register_account(arguments["username"], arguments["website"])
|
||||
return register_account(
|
||||
arguments["username"],
|
||||
arguments["website"])
|
||||
elif command_name == "get_text_summary":
|
||||
return get_text_summary(arguments["url"])
|
||||
elif command_name == "get_hyperlinks":
|
||||
@@ -66,6 +72,9 @@ def execute_command(command_name, arguments):
|
||||
return delete_file(arguments["file"])
|
||||
elif command_name == "browse_website":
|
||||
return browse_website(arguments["url"])
|
||||
# TODO: Change these to take in a file rather than pasted code, if
|
||||
# non-file is given, return instructions "Input should be a python
|
||||
# filepath, write your code to file and try again"
|
||||
elif command_name == "evaluate_code":
|
||||
return ai.evaluate_code(arguments["code"])
|
||||
elif command_name == "improve_code":
|
||||
@@ -82,8 +91,11 @@ def execute_command(command_name, arguments):
|
||||
except Exception as e:
|
||||
return "Error: " + str(e)
|
||||
|
||||
|
||||
def get_datetime():
|
||||
return "Current date and time: " + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
return "Current date and time: " + \
|
||||
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
def google_search(query, num_results=8):
|
||||
search_results = []
|
||||
@@ -92,6 +104,7 @@ def google_search(query, num_results=8):
|
||||
|
||||
return json.dumps(search_results, ensure_ascii=False, indent=4)
|
||||
|
||||
|
||||
def browse_website(url):
|
||||
summary = get_text_summary(url)
|
||||
links = get_hyperlinks(url)
|
||||
@@ -104,20 +117,24 @@ def browse_website(url):
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def get_text_summary(url):
|
||||
text = browse.scrape_text(url)
|
||||
summary = browse.summarize_text(text)
|
||||
return """ "Result" : """ + summary
|
||||
|
||||
|
||||
def get_hyperlinks(url):
|
||||
link_list = browse.scrape_links(url)
|
||||
return link_list
|
||||
|
||||
|
||||
def commit_memory(string):
|
||||
_text = f"""Committing memory with string "{string}" """
|
||||
mem.permanent_memory.append(string)
|
||||
return _text
|
||||
|
||||
|
||||
def delete_memory(key):
|
||||
if key >= 0 and key < len(mem.permanent_memory):
|
||||
_text = "Deleting memory with key " + str(key)
|
||||
@@ -127,6 +144,8 @@ def delete_memory(key):
|
||||
else:
|
||||
print("Invalid key, cannot delete memory.")
|
||||
return None
|
||||
|
||||
|
||||
def overwrite_memory(key, string):
|
||||
if key >= 0 and key < len(mem.permanent_memory):
|
||||
_text = "Overwriting memory with key " + \
|
||||
@@ -138,10 +157,12 @@ def overwrite_memory(key, string):
|
||||
print("Invalid key, cannot overwrite memory.")
|
||||
return None
|
||||
|
||||
|
||||
def shutdown():
|
||||
print("Shutting down...")
|
||||
quit()
|
||||
|
||||
|
||||
def start_agent(name, task, prompt, model="gpt-3.5-turbo"):
|
||||
global cfg
|
||||
|
||||
@@ -164,6 +185,7 @@ def start_agent(name, task, prompt, model="gpt-3.5-turbo"):
|
||||
|
||||
return f"Agent {name} created with key {key}. First response: {agent_response}"
|
||||
|
||||
|
||||
def message_agent(key, message):
|
||||
global cfg
|
||||
agent_response = agents.message_agent(key, message)
|
||||
@@ -174,12 +196,14 @@ def message_agent(key, message):
|
||||
|
||||
return f"Agent {key} responded: {agent_response}"
|
||||
|
||||
|
||||
def list_agents():
|
||||
return agents.list_agents()
|
||||
|
||||
|
||||
def delete_agent(key):
|
||||
result = agents.delete_agent(key)
|
||||
if result == False:
|
||||
if not result:
|
||||
return f"Agent {key} does not exist."
|
||||
return f"Agent {key} deleted."
|
||||
|
||||
@@ -189,12 +213,15 @@ def navigate_website(action, username):
|
||||
print(_text)
|
||||
return "Command not implemented yet."
|
||||
|
||||
|
||||
def register_account(username, website):
|
||||
_text = "Registering account with username " + username + " and website " + website
|
||||
_text = "Registering account with username " + \
|
||||
username + " and website " + website
|
||||
print(_text)
|
||||
return "Command not implemented yet."
|
||||
|
||||
|
||||
def check_notifications(website):
|
||||
_text = "Checking notifications from " + website
|
||||
print(_text)
|
||||
return "Command not implemented yet."
|
||||
return "Command not implemented yet."
|
||||
|
||||
Reference in New Issue
Block a user