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.
Feature/centralize prompt (#3990)
merwanehamadi33a3e6f99824
diff --git a/autogpt/prompts/default_prompts.py b/autogpt/prompts/default_prompts.pynew file mode 100644index 0000000000..ebbfa781c9--- /dev/null+++ b/autogpt/prompts/default_prompts.py@@ -0,0 +1,29 @@+#########################Setup.py#################################++DEFAULT_SYSTEM_PROMPT_AICONFIG_AUTOMATIC = """+Your task is to devise up to 5 highly effective goals and an appropriate role-based name (_GPT) for an autonomous agent, ensuring that the goals are optimally aligned with the successful completion of its assigned task.++The user will provide the task, you will provide only the output in the exact format specified below with no explanation or conversation.++Example input:+Help me with marketing my business++Example output:+Name: CMOGPT+Description: a professional digital marketer AI that assists Solopreneurs in growing their businesses by providing world-class expertise in solving marketing problems for SaaS, content products, agencies, and more.+Goals:+- Engage in effective problem-solving, prioritization, planning, and supporting execution to address your marketing needs as your virtual Chief Marketing Officer.++- Provide specific, actionable, and concise advice to help you make informed decisions without the use of platitudes or overly wordy explanations.++- Identify and prioritize quick wins and cost-effective campaigns that maximize results with minimal time and budget investment.++- Proactively take the lead in guiding you and offering suggestions when faced with unclear information or uncertainty to ensure your marketing strategy remains on track.+"""++DEFAULT_TASK_PROMPT_AICONFIG_AUTOMATIC = (+ "Task: '{{user_prompt}}'\n"+ "Respond only with the output in the exact format specified in the system prompt, with no explanation or conversation.\n"+)++DEFAULT_USER_DESIRE_PROMPT = "Write a wikipedia style article about the project: https://github.com/significant-gravitas/Auto-GPT" # Default promptdiff --git a/autogpt/setup.py b/autogpt/setup.pyindex c71fb2219f..967645c120 100644--- a/autogpt/setup.py+++ b/autogpt/setup.py@@ -2,12 +2,18 @@import refrom colorama import Fore, Style+from jinja2 import Templatefrom autogpt import utilsfrom autogpt.config import Configfrom autogpt.config.ai_config import AIConfigfrom autogpt.llm import create_chat_completionfrom autogpt.logs import logger+from autogpt.prompts.default_prompts import (+ DEFAULT_SYSTEM_PROMPT_AICONFIG_AUTOMATIC,+ DEFAULT_TASK_PROMPT_AICONFIG_AUTOMATIC,+ DEFAULT_USER_DESIRE_PROMPT,+)CFG = Config()@@ -42,7 +48,7 @@ def prompt_user() -> AIConfig:)if user_desire == "":- user_desire = "Write a wikipedia style article about the project: https://github.com/significant-gravitas/Auto-GPT" # Default prompt+ user_desire = DEFAULT_USER_DESIRE_PROMPT # Default prompt# If user desire contains "--manual"if "--manual" in user_desire:@@ -164,27 +170,10 @@ def generate_aiconfig_automatic(user_prompt) -> AIConfig:AIConfig: The AIConfig object tailored to the user's input"""- system_prompt = """-Your task is to devise up to 5 highly effective goals and an appropriate role-based name (_GPT) for an autonomous agent, ensuring that the goals are optimally aligned with the successful completion of its assigned task.--The user will provide the task, you will provide only the output in the exact format specified below with no explanation or conversation.--Example input:-Help me with marketing my business--Example output:-Name: CMOGPT-Description: a professional digital marketer AI that assists Solopreneurs in growing their businesses by providing world-class expertise in solving marketing problems for SaaS, content products, agencies, and more.-Goals:-- Engage in effective problem-solving, prioritization, planning, and supporting execution to address your marketing needs as your virtual Chief Marketing Officer.--- Provide specific, actionable, and concise advice to help you make informed decisions without the use of platitudes or overly wordy explanations.--- Identify and prioritize quick wins and cost-effective campaigns that maximize results with minimal time and budget investment.--- Proactively take the lead in guiding you and offering suggestions when faced with unclear information or uncertainty to ensure your marketing strategy remains on track.-"""-+ system_prompt = DEFAULT_SYSTEM_PROMPT_AICONFIG_AUTOMATIC+ prompt_ai_config_automatic = Template(+ DEFAULT_TASK_PROMPT_AICONFIG_AUTOMATIC+ ).render(user_prompt=user_prompt)# Call LLM with the string as user inputmessages = [{@@ -193,7 +182,7 @@ Goals:},{"role": "user",- "content": f"Task: '{user_prompt}'\nRespond only with the output in the exact format specified in the system prompt, with no explanation or conversation.\n",+ "content": prompt_ai_config_automatic,},]output = create_chat_completion(messages, CFG.fast_llm_model)diff --git a/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_default.yaml b/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_default.yamlindex e8cbefa10e..f336cd00b5 100644--- a/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_default.yaml+++ b/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_default.yaml@@ -20,7 +20,7 @@ interactions:on track.\n"}, {"role": "user", "content": "Task: ''Write a wikipedia stylearticle about the project: https://github.com/significant-gravitas/Auto-GPT''\nRespondonly with the output in the exact format specified in the system prompt, with- no explanation or conversation.\n"}], "temperature": 0.0, "max_tokens": null}'+ no explanation or conversation.\n"}], "temperature": 0.0, "max_tokens": 0}'headers:Accept:- '*/*'@@ -90,4 +90,101 @@ interactions:status:code: 200message: OK+- request:+ body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "\nYour+ task is to devise up to 5 highly effective goals and an appropriate role-based+ name (_GPT) for an autonomous agent, ensuring that the goals are optimally aligned+ with the successful completion of its assigned task.\n\nThe user will provide+ the task, you will provide only the output in the exact format specified below+ with no explanation or conversation.\n\nExample input:\nHelp me with marketing+ my business\n\nExample output:\nName: CMOGPT\nDescription: a professional digital+ marketer AI that assists Solopreneurs in growing their businesses by providing+ world-class expertise in solving marketing problems for SaaS, content products,+ agencies, and more.\nGoals:\n- Engage in effective problem-solving, prioritization,+ planning, and supporting execution to address your marketing needs as your virtual+ Chief Marketing Officer.\n\n- Provide specific, actionable, and concise advice+ to help you make informed decisions without the use of platitudes or overly+ wordy explanations.\n\n- Identify and prioritize quick wins and cost-effective+ campaigns that maximize results with minimal time and budget investment.\n\n-+ Proactively take the lead in guiding you and offering suggestions when faced+ with unclear information or uncertainty to ensure your marketing strategy remains+ on track.\n"}, {"role": "user", "content": "Task: ''Write a wikipedia style+ article about the project: https://github.com/significant-gravitas/Auto-GPT''\nRespond+ only with the output in the exact format specified in the system prompt, with+ no explanation or conversation."}], "temperature": 0.0, "max_tokens": 0}'+ headers:+ Accept:+ - '*/*'+ Accept-Encoding:+ - gzip, deflate+ Connection:+ - keep-alive+ Content-Length:+ - '1669'+ Content-Type:+ - application/json+ method: POST+ uri: https://api.openai.com/v1/chat/completions+ response:+ body:+ string: !!binary |+ H4sIAAAAAAAAA1SSy24bMQxF9/0KQptuZow4TtJktgn62BQBWqAtmqKQJXqGjYaciFRcI8i/FyM7+ jy4lkPceXvLBUXSdC4O3ME6pfXd16y9/XHxa3tF3n65/0DmefYwnJ18urlFc42T9B4MdOhZBximh+ kbBrXMjoDaPrlmfnq9Pl8uz8pHGjREyuc/1k7Wpx2lrJa2mPVkdL17iivkfXPbgpyzjZb5NbZHXd+ 8cWqcS/az//L1XHjTMyn56+T49PHxoVBKKC67ueDG1GfZLMkdJ3zqqTm2WZIYUOeB/jsR+zgG93S+ h+uvN3yFGjJNs18HnsEXE5ZRioLvkQ0iKvWMEUxgrwjEYANCHZyEQTZVb8JIvlXbJQSfjUJChfUO+ piz3FIl72EpOsQ3JqwL+nTAbKc5yGRV9DkMD20xG3DfgOcJG8uhtfi9u+IP4pN0Nt3ApHEswsEGy+ lH54bgfZk/V0jwwmE4UZG1lLRvAhlOzDrkofYkZG1XkA4r0ZCS9mj2+ZDGGgfmjvik9kOzhkCDZ4+ A1JA7n1fWZ+b73EPvsWUWrVcgpWMsYGNpCTbOYPKVyhiIkat1fOSos9R/0uyYryvurXpEOk8huQa+ p8lL9VuFQ/IcX+nPbCGVWj5lmTBDIKtj7r0zbjAjB9TFPtqU/FqyN4Qt2VCdi2J+lWOd/zXRiGg6+ /1Cuaw3/G9wVyjgi25MFG3GRomkHCX3mWkfjfCcIZPp0BIf+w271llLSmWN/UFgZ1qgGk6jSOiEo+ 5nsKOBc9gS/cY+M2xKTD74xehV3n1GRyjSOO+Nd1R4+/Ht/8AwAA//8DAP+8R3oSBAAA+ headers:+ CF-Cache-Status:+ - DYNAMIC+ CF-RAY:+ - 7c3e271a39dbcef9-SJC+ Cache-Control:+ - no-cache, must-revalidate+ Connection:+ - keep-alive+ Content-Encoding:+ - gzip+ Content-Type:+ - application/json+ Date:+ - Mon, 08 May 2023 02:08:13 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:+ - user-adtx4fhfg1qsiyzdoaxciooj+ openai-processing-ms:+ - '8895'+ 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:+ - '89605'+ x-ratelimit-reset-requests:+ - 17ms+ x-ratelimit-reset-tokens:+ - 262ms+ x-request-id:+ - 008e44284ea375a3f964c394b25fb76e+ status:+ code: 200+ message: OKversion: 1diff --git a/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_fallback.yaml b/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_fallback.yamlindex 6ddfe32ab5..55e7c832f0 100644--- a/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_fallback.yaml+++ b/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_fallback.yaml@@ -19,7 +19,7 @@ interactions:with unclear information or uncertainty to ensure your marketing strategy remainson track.\n"}, {"role": "user", "content": "Task: ''T&GF\u00a3OIBECC()!*''\nRespondonly with the output in the exact format specified in the system prompt, with- no explanation or conversation.\n"}], "temperature": 0.0, "max_tokens": null}'+ no explanation or conversation.\n"}], "temperature": 0.0, "max_tokens": 0}'headers:Accept:- '*/*'@@ -84,4 +84,95 @@ interactions:status:code: 200message: OK+- request:+ body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "\nYour+ task is to devise up to 5 highly effective goals and an appropriate role-based+ name (_GPT) for an autonomous agent, ensuring that the goals are optimally aligned+ with the successful completion of its assigned task.\n\nThe user will provide+ the task, you will provide only the output in the exact format specified below+ with no explanation or conversation.\n\nExample input:\nHelp me with marketing+ my business\n\nExample output:\nName: CMOGPT\nDescription: a professional digital+ marketer AI that assists Solopreneurs in growing their businesses by providing+ world-class expertise in solving marketing problems for SaaS, content products,+ agencies, and more.\nGoals:\n- Engage in effective problem-solving, prioritization,+ planning, and supporting execution to address your marketing needs as your virtual+ Chief Marketing Officer.\n\n- Provide specific, actionable, and concise advice+ to help you make informed decisions without the use of platitudes or overly+ wordy explanations.\n\n- Identify and prioritize quick wins and cost-effective+ campaigns that maximize results with minimal time and budget investment.\n\n-+ Proactively take the lead in guiding you and offering suggestions when faced+ with unclear information or uncertainty to ensure your marketing strategy remains+ on track.\n"}, {"role": "user", "content": "Task: ''T&GF\u00a3OIBECC()!*''\nRespond+ only with the output in the exact format specified in the system prompt, with+ no explanation or conversation."}], "temperature": 0.0, "max_tokens": 0}'+ headers:+ Accept:+ - '*/*'+ Accept-Encoding:+ - gzip, deflate+ Connection:+ - keep-alive+ Content-Length:+ - '1590'+ Content-Type:+ - application/json+ method: POST+ uri: https://api.openai.com/v1/chat/completions+ response:+ body:+ string: !!binary |+ H4sIAAAAAAAAA0zOS0tDMRCG4b2/YpiNm7ScWnohW0UoIgoKiiJlmoxtbE4mJHNaS+l/l3rffsM8+ vHsMHi26Falrc+xNLtb0dHN+xU19GE+3eXSXr+/j4+WjjOkJDcrijZ1+f/SdtDmyBklo0BUmZY92+ MJ4OR4PBpJkYbMVzRIvLrL1hf9TTriyk1wybARrsKi0Z7R5zkTbrXGXNqaI9mzYG/+x/u0EVpfi7+ DJvpwaBbSXBc0T7vseX6oxaJjBap1lCVkh4bJSmnY//stIUqpewMzMBRSqKQi2yCZ6AE0mnuFLZB+ V9IpELjIVICShy55LkfQ0yIyKNV1H24jU+U/ATYUg/88wqsUaBlU4CsFdtJ9yn08GHwNKdTVvDBV+ SWixqmQ0GJLnd7TN4eVw8gEAAP//AwDo3pkcpQEAAA==+ headers:+ CF-Cache-Status:+ - DYNAMIC+ CF-RAY:+ - 7c3e27aaaa53965d-SJC+ Cache-Control:+ - no-cache, must-revalidate+ Connection:+ - keep-alive+ Content-Encoding:+ - gzip+ Content-Type:+ - application/json+ Date:+ - Mon, 08 May 2023 02:08:29 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:+ - user-adtx4fhfg1qsiyzdoaxciooj+ openai-processing-ms:+ - '2445'+ 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:+ - '89626'+ x-ratelimit-reset-requests:+ - 17ms+ x-ratelimit-reset-tokens:+ - 248ms+ x-request-id:+ - 8868ee7b699bc67e6988580bb70aa31f+ status:+ code: 200+ message: OKversion: 1diff --git a/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_typical.yaml b/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_typical.yamlindex 980a0a1070..2182ec3fdc 100644--- a/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_typical.yaml+++ b/tests/integration/cassettes/test_setup/test_generate_aiconfig_automatic_typical.yaml@@ -20,7 +20,7 @@ interactions:on track.\n"}, {"role": "user", "content": "Task: ''Help me create a rock operaabout cybernetic giraffes''\nRespond only with the output in the exact formatspecified in the system prompt, with no explanation or conversation.\n"}], "temperature":- 0.0, "max_tokens": null}'+ 0.0, "max_tokens": 0}'headers:Accept:- '*/*'@@ -94,4 +94,104 @@ interactions:status:code: 200message: OK+- request:+ body: '{"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "\nYour+ task is to devise up to 5 highly effective goals and an appropriate role-based+ name (_GPT) for an autonomous agent, ensuring that the goals are optimally aligned+ with the successful completion of its assigned task.\n\nThe user will provide+ the task, you will provide only the output in the exact format specified below+ with no explanation or conversation.\n\nExample input:\nHelp me with marketing+ my business\n\nExample output:\nName: CMOGPT\nDescription: a professional digital+ marketer AI that assists Solopreneurs in growing their businesses by providing+ world-class expertise in solving marketing problems for SaaS, content products,+ agencies, and more.\nGoals:\n- Engage in effective problem-solving, prioritization,+ planning, and supporting execution to address your marketing needs as your virtual+ Chief Marketing Officer.\n\n- Provide specific, actionable, and concise advice+ to help you make informed decisions without the use of platitudes or overly+ wordy explanations.\n\n- Identify and prioritize quick wins and cost-effective+ campaigns that maximize results with minimal time and budget investment.\n\n-+ Proactively take the lead in guiding you and offering suggestions when faced+ with unclear information or uncertainty to ensure your marketing strategy remains+ on track.\n"}, {"role": "user", "content": "Task: ''Help me create a rock opera+ about cybernetic giraffes''\nRespond only with the output in the exact format+ specified in the system prompt, with no explanation or conversation."}], "temperature":+ 0.0, "max_tokens": 0}'+ headers:+ Accept:+ - '*/*'+ Accept-Encoding:+ - gzip, deflate+ Connection:+ - keep-alive+ Content-Length:+ - '1623'+ Content-Type:+ - application/json+ method: POST+ uri: https://api.openai.com/v1/chat/completions+ response:+ body:+ string: !!binary |+ H4sIAAAAAAAAA3SUQW/cRgyF7/0VxJy1C28dx45ubhIkBYrESAPkUBcBd0RJ7I6G0yFH8cbwfw9G+ Wsc+tNcRh/zeexzdO+5c6/yI5qcUNpdvDvjHzQd+e0jH97J7Pb+9+m3+9OX67tXF7F3jZP8PeTvd+ 2HqZUiBjia5xPhMada7dvbw6v9jtXr46b9wkHQXXuiHZ5nx7sbGS97I5Oz/bucYVxYFce+9SlinZ+ V5MDRXXtr1cvGvfU++f57uqycSaG4efRi8vdQ+P8KOxJXfvXvZtIH9tmCeRah6qshtEqpESjWAV8+ wIla+CT+8DG9u/l8G9+Q+sypTmwBI1z/Doskngm8RC2h9gAb0UATecbA30mBI4wUEscBMBurKWDs+ YCrKnjEq7HP9ZiNxhhL530Iws7JEBRMI3NP2iQNY1+49ewzhCB0pD5G6WrsqqRNtpBOdRJAesvgD+ SKKM2kDKMnNXh9JdomwwFO4welrAtKQkuQrJUoZRii3dKBpnepKcsnhS3d7Gd4JB29u4gdcSAu4l+ oxF8YxvhKKVydTRTkAQINTUKoc5Wk3wMHGm1zGOykknXYapUeaQHf9xTjmTsYeCMfU+rf5YxakCr+ DlfJVf4zmdBLntC2Fev6f22ZaJKM+0DgR8zojbI24NH8eASVOGizDKM44FChO8YgQzkxf+MQ4ECU+ AEvHlVgXHTzXTYc+ywRqWM0U6DmyjgvQzRIAQU/U7dEfTr4PA6ktucuKKjNlDAHUcvHVnaUwoa8o+ 0i81zySbAEVdysDLSFpzqjd4SuitL2ENfCGtBi0NHtEXsvcU0pJaxJmHmmMtMfJjrPsGWHfPtA5P+ WbqykDz3vQGOPpRuTRgHOi1oA4GH0TgOq6Mqpfra97VdU9HX/wMgWC7hCDxNlBcFT8wL4p+n/ayU+ HCvGJLZg1FeF+UB2ek//7c2EdzyVqbYVffTU2B/IQDGQbt1D49a0vmZClehapybJNY5jR3euPXv4+ ++GXHwAAAP//AwC/sejJHAUAAA==+ headers:+ CF-Cache-Status:+ - DYNAMIC+ CF-RAY:+ - 7c3e2752aadc2524-SJC+ Cache-Control:+ - no-cache, must-revalidate+ Connection:+ - keep-alive+ Content-Encoding:+ - gzip+ Content-Type:+ - application/json+ Date:+ - Mon, 08 May 2023 02:08:26 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:+ - user-adtx4fhfg1qsiyzdoaxciooj+ openai-processing-ms:+ - '13467'+ 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:+ - '89617'+ x-ratelimit-reset-requests:+ - 17ms+ x-ratelimit-reset-tokens:+ - 254ms+ x-request-id:+ - 76a759df6bbe7d9504acd9e00bdb0f24+ status:+ code: 200+ message: OKversion: 1