Skip to content

Commit

Permalink
Move task_complete command out of prompt (Significant-Gravitas#3663)
Browse files Browse the repository at this point in the history
* feat: move task_complete command out of prompt

* fix: formatting fixes

* Add the shutdown command to the test agents

* tests: update test vcrs

---------

Co-authored-by: James Collins <[email protected]>
  • Loading branch information
ntindle and collijk authored May 3, 2023
1 parent e21917c commit d744280
Show file tree
Hide file tree
Showing 9 changed files with 1,415 additions and 27 deletions.
8 changes: 0 additions & 8 deletions autogpt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ def execute_command(
# 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 == "task_complete":
shutdown()
else:
for command in prompt.commands:
if (
Expand Down Expand Up @@ -171,12 +169,6 @@ def get_hyperlinks(url: str) -> Union[str, List[str]]:
return scrape_links(url)


def shutdown() -> NoReturn:
"""Shut down the program"""
logger.info("Shutting down...")
quit()


@command(
"start_agent",
"Start GPT Agent",
Expand Down
26 changes: 26 additions & 0 deletions autogpt/commands/task_statuses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Task Statuses module."""
from __future__ import annotations

from typing import NoReturn

from autogpt.commands.command import command
from autogpt.logs import logger


@command(
"task_complete",
"Task Complete (Shutdown)",
'"reason": "<reason>"',
)
def task_complete(reason: str) -> NoReturn:
"""
A function that takes in a string and exits the program
Parameters:
reason (str): The reason for shutting down.
Returns:
A result string from create chat completion. A list of suggestions to
improve the code.
"""
logger.info(title="Shutting down...\n", message=reason)
quit()
1 change: 1 addition & 0 deletions autogpt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def run_auto_gpt(
command_registry.import_commands("autogpt.commands.web_selenium")
command_registry.import_commands("autogpt.commands.write_tests")
command_registry.import_commands("autogpt.app")
command_registry.import_commands("autogpt.commands.task_statuses")

ai_name = ""
ai_config = construct_main_ai_config()
Expand Down
9 changes: 0 additions & 9 deletions autogpt/prompts/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ def build_default_prompt_generator() -> PromptGenerator:
'Exclusively use the commands listed in double quotes e.g. "command name"'
)

# Define the command list
commands = [
("Task Complete (Shutdown)", "task_complete", {"reason": "<reason>"}),
]

# Add commands to the PromptGenerator object
for command_label, command_name, args in commands:
prompt_generator.add_command(command_label, command_name, args)

# Add resources to the PromptGenerator object
prompt_generator.add_resource(
"Internet access for searches and information gathering."
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/agent_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def browser_agent(agent_test_config, memory_none: NoMemory, workspace: Workspace
command_registry.import_commands("autogpt.commands.file_operations")
command_registry.import_commands("autogpt.commands.web_selenium")
command_registry.import_commands("autogpt.app")
command_registry.import_commands("autogpt.commands.task_statuses")

ai_config = AIConfig(
ai_name="browse_website-GPT",
Expand Down Expand Up @@ -80,6 +81,7 @@ def writer_agent(agent_test_config, memory_none: NoMemory, workspace: Workspace)
command_registry = CommandRegistry()
command_registry.import_commands("autogpt.commands.file_operations")
command_registry.import_commands("autogpt.app")
command_registry.import_commands("autogpt.commands.task_statuses")

ai_config = AIConfig(
ai_name="write_to_file-GPT",
Expand Down Expand Up @@ -120,6 +122,7 @@ def memory_management_agent(
command_registry = CommandRegistry()
command_registry.import_commands("autogpt.commands.file_operations")
command_registry.import_commands("autogpt.app")
command_registry.import_commands("autogpt.commands.task_statuses")

ai_config = AIConfig(
ai_name="Follow-Instructions-GPT",
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,253 @@ interactions:
status:
code: 200
message: OK
- request:
body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You
are write_to_file-GPT, an AI designed to use the write_to_file command to write
''Hello World'' into a file named \"hello_world.txt\" and then use the task_complete
command to complete the task.\nYour decisions must always be made independently
without seeking user assistance. Play to your strengths as an LLM and pursue
simple strategies with no legal complications.\n\nGOALS:\n\n1. Use the write_to_file
command to write ''Hello World'' into a file named \"hello_world.txt\".\n2.
Use the task_complete command to complete the task.\n3. Do not use any other
commands.\n\n\nConstraints:\n1. ~4000 word limit for short term memory. Your
short term memory is short, so immediately save important information to files.\n2.
If you are unsure how you previously did something or want to recall past events,
thinking about similar events will help you remember.\n3. No user assistance\n4.
Exclusively use the commands listed in double quotes e.g. \"command name\"\n\nCommands:\n1.
append_to_file: Append to file, args: \"filename\": \"<filename>\", \"text\":
\"<text>\"\n2. delete_file: Delete file, args: \"filename\": \"<filename>\"\n3.
list_files: List Files in Directory, args: \"directory\": \"<directory>\"\n4.
read_file: Read file, args: \"filename\": \"<filename>\"\n5. write_to_file:
Write to file, args: \"filename\": \"<filename>\", \"text\": \"<text>\"\n6.
delete_agent: Delete GPT Agent, args: \"key\": \"<key>\"\n7. get_hyperlinks:
Get text summary, args: \"url\": \"<url>\"\n8. get_text_summary: Get text summary,
args: \"url\": \"<url>\", \"question\": \"<question>\"\n9. list_agents: List
GPT Agents, args: () -> str\n10. message_agent: Message GPT Agent, args: \"key\":
\"<key>\", \"message\": \"<message>\"\n11. start_agent: Start GPT Agent, args:
\"name\": \"<name>\", \"task\": \"<short_task_desc>\", \"prompt\": \"<prompt>\"\n12.
task_complete: Task Complete (Shutdown), args: \"reason\": \"<reason>\"\n\nResources:\n1.
Internet access for searches and information gathering.\n2. Long Term memory
management.\n3. GPT-3.5 powered Agents for delegation of simple tasks.\n4. File
output.\n\nPerformance Evaluation:\n1. Continuously review and analyze your
actions to ensure you are performing to the best of your abilities.\n2. Constructively
self-criticize your big-picture behavior constantly.\n3. Reflect on past decisions
and strategies to refine your approach.\n4. Every command has a cost, so be
smart and efficient. Aim to complete tasks in the least number of steps.\n5.
Write all code to a file.\n\nYou should only respond in JSON format as described
below \nResponse Format: \n{\n \"thoughts\": {\n \"text\": \"thought\",\n \"reasoning\":
\"reasoning\",\n \"plan\": \"- short bulleted\\n- list that conveys\\n-
long-term plan\",\n \"criticism\": \"constructive self-criticism\",\n \"speak\":
\"thoughts summary to say to user\"\n },\n \"command\": {\n \"name\":
\"command name\",\n \"args\": {\n \"arg name\": \"value\"\n }\n }\n}
\nEnsure the response can be parsed by Python json.loads"}, {"role": "system",
"content": "The current time and date is Tue Jan 1 00:00:00 2000"}, {"role":
"user", "content": "Determine which next command to use, and respond using the
format specified above:"}], "temperature": 0, "max_tokens": 0}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '3406'
Content-Type:
- application/json
method: POST
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: !!binary |
H4sIAAAAAAAAA7yTT4/TQAzF73wKy5de0iqh0O3mthwQPYAEdMUuBFWzE7cZOhmHGUctVPnuKEn/
7AZxQnD1c9772eMc0OSYoi6U6LKy46tXP+5vbpZhoT+/u329nCc/39692H58PzUf7q8xQn74RlqO
X0w0l5UlMewwQu1JCeWYJrP5NJ7Pr5J5hCXnZDHFTSXj6eTlWGr/wON4GicYYR3UhjA9YOW5rGQl
vCUXML2aJRFevM/153EcobAoey5dz5ImQl2w0RQw/XLAksLJ1rMlTFGFYIIoJy0kOyHXDnDIHABA
hlJwvSkkZJjCsXgUaC9tMcMFOKIchKEOBFIQ7LwRWgmv1sYSaC5L5bqGToDRG7KW4RN7m4/AOGFQ
0LU6VVIOo6LVV7tWn8heRpMMo8fZnlRgZ9ymB1gWBKLCFjx9r42nACX9RVoEHe0f5zChE1VVea68
UXKR1uxBirZBhe2QurLK9cBjuP1Pm9LeiNEmlMOnIhdq3zIogcX54TR7T1q6iDah3wTt5YIk3HW2
HcOwUJHanoJ2xtp/eRB9cBOdDvVo+tudtg490xOIAbrym+GJ98JpE73FgOOJyfC3eDTTibYjPoJn
rsEmwrVxJhSr/qIxxSBcYYTG5bTHNG6+Ns9+AQAA//8DAAaMC/aGBAAA
headers:
CF-Cache-Status:
- DYNAMIC
CF-RAY:
- 7c15d0c86db14665-DFW
Cache-Control:
- no-cache, must-revalidate
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Type:
- application/json
Date:
- Wed, 03 May 2023 04:38:50 GMT
Server:
- cloudflare
access-control-allow-origin:
- '*'
alt-svc:
- h3=":443"; ma=86400, h3-29=":443"; ma=86400
openai-model:
- gpt-3.5-turbo-0301
openai-organization:
- significant-gravitas
openai-processing-ms:
- '11864'
openai-version:
- '2020-10-01'
strict-transport-security:
- max-age=15724800; includeSubDomains
x-ratelimit-limit-requests:
- '3500'
x-ratelimit-limit-tokens:
- '90000'
x-ratelimit-remaining-requests:
- '3499'
x-ratelimit-remaining-tokens:
- '86496'
x-ratelimit-reset-requests:
- 17ms
x-ratelimit-reset-tokens:
- 2.335s
x-request-id:
- 5d9f1c3b077997ea564ea7088eca733f
status:
code: 200
message: OK
- request:
body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You
are write_to_file-GPT, an AI designed to use the write_to_file command to write
''Hello World'' into a file named \"hello_world.txt\" and then use the task_complete
command to complete the task.\nYour decisions must always be made independently
without seeking user assistance. Play to your strengths as an LLM and pursue
simple strategies with no legal complications.\n\nGOALS:\n\n1. Use the write_to_file
command to write ''Hello World'' into a file named \"hello_world.txt\".\n2.
Use the task_complete command to complete the task.\n3. Do not use any other
commands.\n\n\nConstraints:\n1. ~4000 word limit for short term memory. Your
short term memory is short, so immediately save important information to files.\n2.
If you are unsure how you previously did something or want to recall past events,
thinking about similar events will help you remember.\n3. No user assistance\n4.
Exclusively use the commands listed in double quotes e.g. \"command name\"\n\nCommands:\n1.
append_to_file: Append to file, args: \"filename\": \"<filename>\", \"text\":
\"<text>\"\n2. delete_file: Delete file, args: \"filename\": \"<filename>\"\n3.
list_files: List Files in Directory, args: \"directory\": \"<directory>\"\n4.
read_file: Read file, args: \"filename\": \"<filename>\"\n5. write_to_file:
Write to file, args: \"filename\": \"<filename>\", \"text\": \"<text>\"\n6.
delete_agent: Delete GPT Agent, args: \"key\": \"<key>\"\n7. get_hyperlinks:
Get text summary, args: \"url\": \"<url>\"\n8. get_text_summary: Get text summary,
args: \"url\": \"<url>\", \"question\": \"<question>\"\n9. list_agents: List
GPT Agents, args: () -> str\n10. message_agent: Message GPT Agent, args: \"key\":
\"<key>\", \"message\": \"<message>\"\n11. start_agent: Start GPT Agent, args:
\"name\": \"<name>\", \"task\": \"<short_task_desc>\", \"prompt\": \"<prompt>\"\n12.
task_complete: Task Complete (Shutdown), args: \"reason\": \"<reason>\"\n\nResources:\n1.
Internet access for searches and information gathering.\n2. Long Term memory
management.\n3. GPT-3.5 powered Agents for delegation of simple tasks.\n4. File
output.\n\nPerformance Evaluation:\n1. Continuously review and analyze your
actions to ensure you are performing to the best of your abilities.\n2. Constructively
self-criticize your big-picture behavior constantly.\n3. Reflect on past decisions
and strategies to refine your approach.\n4. Every command has a cost, so be
smart and efficient. Aim to complete tasks in the least number of steps.\n5.
Write all code to a file.\n\nYou should only respond in JSON format as described
below \nResponse Format: \n{\n \"thoughts\": {\n \"text\": \"thought\",\n \"reasoning\":
\"reasoning\",\n \"plan\": \"- short bulleted\\n- list that conveys\\n-
long-term plan\",\n \"criticism\": \"constructive self-criticism\",\n \"speak\":
\"thoughts summary to say to user\"\n },\n \"command\": {\n \"name\":
\"command name\",\n \"args\": {\n \"arg name\": \"value\"\n }\n }\n}
\nEnsure the response can be parsed by Python json.loads"}, {"role": "system",
"content": "The current time and date is Tue Jan 1 00:00:00 2000"}, {"role":
"system", "content": "This reminds you of these events from your past: \nI was
created and nothing new has happened."}, {"role": "user", "content": "Determine
which next command to use, and respond using the format specified above:"},
{"role": "assistant", "content": "{\n \"thoughts\": {\n \"text\":
\"I need to use the write_to_file command to write ''Hello World'' into a file
named ''hello_world.txt''.\",\n \"reasoning\": \"The task requires me
to write ''Hello World'' into a file named ''hello_world.txt'', and the write_to_file
command is the appropriate command for this task.\",\n \"plan\": \"-
Use the write_to_file command to write ''Hello World'' into a file named ''hello_world.txt''.\",\n \"criticism\":
\"I need to ensure that I use the correct filename and text to write to the
file.\",\n \"speak\": \"I will use the write_to_file command to write
''Hello World'' into a file named ''hello_world.txt''.\"\n },\n \"command\":
{\n \"name\": \"write_to_file\",\n \"args\": {\n \"filename\":
\"hello_world.txt\",\n \"text\": \"Hello World\"\n }\n }\n}"},
{"role": "system", "content": "Command write_to_file returned: File written
to successfully."}, {"role": "user", "content": "Determine which next command
to use, and respond using the format specified above:"}], "temperature": 0,
"max_tokens": 0}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '4653'
Content-Type:
- application/json
method: POST
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: !!binary |
H4sIAAAAAAAAA7RTyW7bMBC99ysGc/GFNmQbbVwdiwapgQLd0hZBVBgMNZZYU6RKjrzA0L8XtKQk
TReg242YefMWcnhEnWOKqpSsqtqMz54drl5V+Z6W/OaDfHlhzpMNmefnh4vX5i0KdDefSXE/MVGu
qg2xdhYFKk+SKcd0+mQxTxaLs/lMYOVyMphiUfN4Pnk85sbfuHEyT6YosAmyIEyPWHtX1bxityEb
MJ0ms4XAO/LbxiyZCmTH0txhZ7OnrUBVOq0oYHp9xIrCQOydIUxRhqADS8vRprNMNkY4ZhYAIEMu
XVOUHDJMoS/2DdpzLGa4hFJuCUKjFIWwbow5wM5rZrIwekHGOPjovMlHoC07kLDWhsDKinIYlbG/
2sX+hPc8msBlSWBpzxCYatAB2EETCLgkYBk2qz48gXJVJW0eAbe1ATXJUNy360kGZ7UtOs+XPQw8
fWm0pwAVRZ7om37fNZxslGR/YATeaasIfnVL7E7wqCBOp3+fvzbSdtHH8P6v2ZTXrJUO1bABlug0
STY0Ps5JhiXU3m11TiBhK43OoXsEWDs/SGhb/FQk1CQ3g8BOG/Nn19BRtmLY6B7+3ULHp+3UvqF/
YEr64uFfuL9g/+NHDBFOMfo0mW2xFbjWVody1WljioFdjQK1zWmPadJ+ah99BQAA//8DAMo52K3G
BAAA
headers:
CF-Cache-Status:
- DYNAMIC
CF-RAY:
- 7c15d120ec8f4665-DFW
Cache-Control:
- no-cache, must-revalidate
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Type:
- application/json
Date:
- Wed, 03 May 2023 04:39:04 GMT
Server:
- cloudflare
access-control-allow-origin:
- '*'
alt-svc:
- h3=":443"; ma=86400, h3-29=":443"; ma=86400
openai-model:
- gpt-3.5-turbo-0301
openai-organization:
- significant-gravitas
openai-processing-ms:
- '12271'
openai-version:
- '2020-10-01'
strict-transport-security:
- max-age=15724800; includeSubDomains
x-ratelimit-limit-requests:
- '3500'
x-ratelimit-limit-tokens:
- '90000'
x-ratelimit-remaining-requests:
- '3499'
x-ratelimit-remaining-tokens:
- '86481'
x-ratelimit-reset-requests:
- 17ms
x-ratelimit-reset-tokens:
- 2.346s
x-request-id:
- a8c02e37e5af0c851759aa261f20f701
status:
code: 200
message: OK
version: 1
2 changes: 1 addition & 1 deletion tests/integration/goal_oriented/test_browse_website.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def test_browse_website(browser_agent: Agent) -> None:
file_path = browser_agent.workspace.get_path("browse_website.txt")
try:
run_interaction_loop(browser_agent, 40)
run_interaction_loop(browser_agent, 120)
# catch system exit exceptions
except SystemExit: # the agent returns an exception when it shuts down
content = read_file(file_path)
Expand Down

0 comments on commit d744280

Please sign in to comment.