AutoGPT/autogpt/setup.py

219 lines
7.3 KiB
Python
Raw Normal View History

2023-04-17 12:25:49 +00:00
"""Set up the AI and its goals"""
Automatic prompting (#2896) * Add automatic ai prompting * Tweak the default prompt. * Print agent info upon creation. * Improve system prompt * Switch to fast_llm_model by default * Add format output command to user prompt. This vastly improves formatting success rate. * Add fallback to manual mode if llm output cannot be parsed (or other error). * Add unit test to cover ai creation setup. * Replace redundent prompt with manual mode instructions. * Add missing docstrings and typing. * Runs black on changes. * Runs isort * Update Python version and benchmark file in benchmark.yml * Refactor main function and imports in cli.py * Update import statement in ai_config.py * Add set_temperature and set_memory_backend methods in config.py * Remove unused import in prompt.py * Add goal oriented tasks workflow * Added agent_utils to create agent * added pytest and vcrpy * added write file cassette * created goal oriented task write file with cassettes to not pay openai tokens * solve conflicts * add ability set azure because github workflow needs it off * solve conflicts in cli.py * black because linter fails * solve conflict * setup github action to v3 Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * fix conflicts Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * Plugins: debug line always printed in plugin load * add decorator to tests Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * move decorator higher up Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * merge --------- Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwane.hamadi@redica.com> Co-authored-by: Richard Beales <rich@richbeales.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com> Co-authored-by: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com>
2023-04-23 05:36:10 +00:00
import re
from colorama import Fore, Style
2023-04-17 20:41:42 +00:00
from autogpt import utils
Automatic prompting (#2896) * Add automatic ai prompting * Tweak the default prompt. * Print agent info upon creation. * Improve system prompt * Switch to fast_llm_model by default * Add format output command to user prompt. This vastly improves formatting success rate. * Add fallback to manual mode if llm output cannot be parsed (or other error). * Add unit test to cover ai creation setup. * Replace redundent prompt with manual mode instructions. * Add missing docstrings and typing. * Runs black on changes. * Runs isort * Update Python version and benchmark file in benchmark.yml * Refactor main function and imports in cli.py * Update import statement in ai_config.py * Add set_temperature and set_memory_backend methods in config.py * Remove unused import in prompt.py * Add goal oriented tasks workflow * Added agent_utils to create agent * added pytest and vcrpy * added write file cassette * created goal oriented task write file with cassettes to not pay openai tokens * solve conflicts * add ability set azure because github workflow needs it off * solve conflicts in cli.py * black because linter fails * solve conflict * setup github action to v3 Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * fix conflicts Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * Plugins: debug line always printed in plugin load * add decorator to tests Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * move decorator higher up Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * merge --------- Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwane.hamadi@redica.com> Co-authored-by: Richard Beales <rich@richbeales.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com> Co-authored-by: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com>
2023-04-23 05:36:10 +00:00
from autogpt.config import Config
from autogpt.config.ai_config import AIConfig
from autogpt.llm import create_chat_completion
from autogpt.logs import logger
Automatic prompting (#2896) * Add automatic ai prompting * Tweak the default prompt. * Print agent info upon creation. * Improve system prompt * Switch to fast_llm_model by default * Add format output command to user prompt. This vastly improves formatting success rate. * Add fallback to manual mode if llm output cannot be parsed (or other error). * Add unit test to cover ai creation setup. * Replace redundent prompt with manual mode instructions. * Add missing docstrings and typing. * Runs black on changes. * Runs isort * Update Python version and benchmark file in benchmark.yml * Refactor main function and imports in cli.py * Update import statement in ai_config.py * Add set_temperature and set_memory_backend methods in config.py * Remove unused import in prompt.py * Add goal oriented tasks workflow * Added agent_utils to create agent * added pytest and vcrpy * added write file cassette * created goal oriented task write file with cassettes to not pay openai tokens * solve conflicts * add ability set azure because github workflow needs it off * solve conflicts in cli.py * black because linter fails * solve conflict * setup github action to v3 Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * fix conflicts Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * Plugins: debug line always printed in plugin load * add decorator to tests Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * move decorator higher up Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * merge --------- Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwane.hamadi@redica.com> Co-authored-by: Richard Beales <rich@richbeales.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com> Co-authored-by: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com>
2023-04-23 05:36:10 +00:00
CFG = Config()
def prompt_user() -> AIConfig:
"""Prompt the user for input
Returns:
Automatic prompting (#2896) * Add automatic ai prompting * Tweak the default prompt. * Print agent info upon creation. * Improve system prompt * Switch to fast_llm_model by default * Add format output command to user prompt. This vastly improves formatting success rate. * Add fallback to manual mode if llm output cannot be parsed (or other error). * Add unit test to cover ai creation setup. * Replace redundent prompt with manual mode instructions. * Add missing docstrings and typing. * Runs black on changes. * Runs isort * Update Python version and benchmark file in benchmark.yml * Refactor main function and imports in cli.py * Update import statement in ai_config.py * Add set_temperature and set_memory_backend methods in config.py * Remove unused import in prompt.py * Add goal oriented tasks workflow * Added agent_utils to create agent * added pytest and vcrpy * added write file cassette * created goal oriented task write file with cassettes to not pay openai tokens * solve conflicts * add ability set azure because github workflow needs it off * solve conflicts in cli.py * black because linter fails * solve conflict * setup github action to v3 Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * fix conflicts Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * Plugins: debug line always printed in plugin load * add decorator to tests Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * move decorator higher up Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * merge --------- Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwane.hamadi@redica.com> Co-authored-by: Richard Beales <rich@richbeales.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com> Co-authored-by: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com>
2023-04-23 05:36:10 +00:00
AIConfig: The AIConfig object tailored to the user's input
"""
ai_name = ""
Automatic prompting (#2896) * Add automatic ai prompting * Tweak the default prompt. * Print agent info upon creation. * Improve system prompt * Switch to fast_llm_model by default * Add format output command to user prompt. This vastly improves formatting success rate. * Add fallback to manual mode if llm output cannot be parsed (or other error). * Add unit test to cover ai creation setup. * Replace redundent prompt with manual mode instructions. * Add missing docstrings and typing. * Runs black on changes. * Runs isort * Update Python version and benchmark file in benchmark.yml * Refactor main function and imports in cli.py * Update import statement in ai_config.py * Add set_temperature and set_memory_backend methods in config.py * Remove unused import in prompt.py * Add goal oriented tasks workflow * Added agent_utils to create agent * added pytest and vcrpy * added write file cassette * created goal oriented task write file with cassettes to not pay openai tokens * solve conflicts * add ability set azure because github workflow needs it off * solve conflicts in cli.py * black because linter fails * solve conflict * setup github action to v3 Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * fix conflicts Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * Plugins: debug line always printed in plugin load * add decorator to tests Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * move decorator higher up Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * merge --------- Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwane.hamadi@redica.com> Co-authored-by: Richard Beales <rich@richbeales.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com> Co-authored-by: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com>
2023-04-23 05:36:10 +00:00
ai_config = None
# Construct the prompt
logger.typewriter_log(
"Welcome to Auto-GPT! ",
Fore.GREEN,
2023-04-18 12:54:06 +00:00
"run with '--help' for more information.",
speak_text=True,
)
Automatic prompting (#2896) * Add automatic ai prompting * Tweak the default prompt. * Print agent info upon creation. * Improve system prompt * Switch to fast_llm_model by default * Add format output command to user prompt. This vastly improves formatting success rate. * Add fallback to manual mode if llm output cannot be parsed (or other error). * Add unit test to cover ai creation setup. * Replace redundent prompt with manual mode instructions. * Add missing docstrings and typing. * Runs black on changes. * Runs isort * Update Python version and benchmark file in benchmark.yml * Refactor main function and imports in cli.py * Update import statement in ai_config.py * Add set_temperature and set_memory_backend methods in config.py * Remove unused import in prompt.py * Add goal oriented tasks workflow * Added agent_utils to create agent * added pytest and vcrpy * added write file cassette * created goal oriented task write file with cassettes to not pay openai tokens * solve conflicts * add ability set azure because github workflow needs it off * solve conflicts in cli.py * black because linter fails * solve conflict * setup github action to v3 Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * fix conflicts Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * Plugins: debug line always printed in plugin load * add decorator to tests Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * move decorator higher up Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * merge --------- Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwane.hamadi@redica.com> Co-authored-by: Richard Beales <rich@richbeales.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com> Co-authored-by: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com>
2023-04-23 05:36:10 +00:00
# Get user desire
logger.typewriter_log(
"Create an AI-Assistant:",
Fore.GREEN,
"input '--manual' to enter manual mode.",
speak_text=True,
)
user_desire = utils.clean_input(
f"{Fore.LIGHTBLUE_EX}I want Auto-GPT to{Style.RESET_ALL}: "
)
if user_desire == "":
user_desire = "Write a wikipedia style article about the project: https://github.com/significant-gravitas/Auto-GPT" # Default prompt
# If user desire contains "--manual"
if "--manual" in user_desire:
logger.typewriter_log(
"Manual Mode Selected",
Fore.GREEN,
speak_text=True,
)
return generate_aiconfig_manual()
else:
try:
return generate_aiconfig_automatic(user_desire)
except Exception as e:
logger.typewriter_log(
"Unable to automatically generate AI Config based on user desire.",
Fore.RED,
"Falling back to manual mode.",
speak_text=True,
)
return generate_aiconfig_manual()
def generate_aiconfig_manual() -> AIConfig:
"""
Interactively create an AI configuration by prompting the user to provide the name, role, and goals of the AI.
This function guides the user through a series of prompts to collect the necessary information to create
an AIConfig object. The user will be asked to provide a name and role for the AI, as well as up to five
goals. If the user does not provide a value for any of the fields, default values will be used.
Returns:
AIConfig: An AIConfig object containing the user-defined or default AI name, role, and goals.
"""
# Manual Setup Intro
2023-04-18 12:54:06 +00:00
logger.typewriter_log(
"Create an AI-Assistant:",
Fore.GREEN,
"Enter the name of your AI and its role below. Entering nothing will load"
" defaults.",
speak_text=True,
)
# Get AI Name from User
logger.typewriter_log(
"Name your AI: ", Fore.GREEN, "For example, 'Entrepreneur-GPT'"
)
ai_name = utils.clean_input("AI Name: ")
if ai_name == "":
ai_name = "Entrepreneur-GPT"
logger.typewriter_log(
f"{ai_name} here!", Fore.LIGHTBLUE_EX, "I am at your service.", speak_text=True
)
# Get AI Role from User
logger.typewriter_log(
"Describe your AI's role: ",
Fore.GREEN,
"For example, 'an AI designed to autonomously develop and run businesses with"
" the sole goal of increasing your net worth.'",
)
ai_role = utils.clean_input(f"{ai_name} is: ")
if ai_role == "":
ai_role = "an AI designed to autonomously develop and run businesses with the"
" sole goal of increasing your net worth."
# Enter up to 5 goals for the AI
logger.typewriter_log(
"Enter up to 5 goals for your AI: ",
Fore.GREEN,
"For example: \nIncrease net worth, Grow Twitter Account, Develop and manage"
" multiple businesses autonomously'",
)
logger.info("Enter nothing to load defaults, enter nothing when finished.")
ai_goals = []
for i in range(5):
ai_goal = utils.clean_input(f"{Fore.LIGHTBLUE_EX}Goal{Style.RESET_ALL} {i+1}: ")
if ai_goal == "":
break
ai_goals.append(ai_goal)
if not ai_goals:
ai_goals = [
"Increase net worth",
"Grow Twitter Account",
"Develop and manage multiple businesses autonomously",
]
Make Auto-GPT aware of its running cost (#762) * Implemented running cost counter for chat completions This data is known to the AI as additional system context, and is printed out to the user * Added comments to api_manager.py * Added user-defined API budget. The user is now prompted if they want to give the AI a budget for API calls. If they enter nothing, there is no monetary limit, but if they define a budget then the AI will be told to shut down gracefully once it has come within 1 cent of its limit, and to shut down immediately once it has exceeded its limit. If a budget is defined, Auto-GPT is always aware of how much it was given and how much remains to be spent. * Chat completion calls are now done through api_manager. Total running cost is printed. * Implemented api budget setting and tracking User can now configure a maximum api budget, and the AI is aware of that and its remaining budget. The AI is instructed to shut down when exceeding the budget. * Update autogpt/api_manager.py Change "per token" to "per 1000 tokens" in a comment on the api cost Co-authored-by: Rob Luke <code@robertluke.net> * Fixed lint errors * Include embedding costs * Add embedding completion cost * lint * Added 'requires_api_key' decorator to test_commands.py, switched to a valid chat completions model * Refactor API manager, add debug mode, and add tests - Extract model costs to to avoid duplication - Add debug mode parameter to ApiManager class - Move debug mode configuration to - Log AI response and budget messages in debug mode - Implement 'test_api_manager.py' * Fixed test_setup failing. An extra user input is needed for api budget * Linting --------- Co-authored-by: Rob Luke <code@robertluke.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com>
2023-04-23 21:04:31 +00:00
# Get API Budget from User
logger.typewriter_log(
"Enter your budget for API calls: ",
Fore.GREEN,
"For example: $1.50",
)
logger.info("Enter nothing to let the AI run without monetary limit")
Make Auto-GPT aware of its running cost (#762) * Implemented running cost counter for chat completions This data is known to the AI as additional system context, and is printed out to the user * Added comments to api_manager.py * Added user-defined API budget. The user is now prompted if they want to give the AI a budget for API calls. If they enter nothing, there is no monetary limit, but if they define a budget then the AI will be told to shut down gracefully once it has come within 1 cent of its limit, and to shut down immediately once it has exceeded its limit. If a budget is defined, Auto-GPT is always aware of how much it was given and how much remains to be spent. * Chat completion calls are now done through api_manager. Total running cost is printed. * Implemented api budget setting and tracking User can now configure a maximum api budget, and the AI is aware of that and its remaining budget. The AI is instructed to shut down when exceeding the budget. * Update autogpt/api_manager.py Change "per token" to "per 1000 tokens" in a comment on the api cost Co-authored-by: Rob Luke <code@robertluke.net> * Fixed lint errors * Include embedding costs * Add embedding completion cost * lint * Added 'requires_api_key' decorator to test_commands.py, switched to a valid chat completions model * Refactor API manager, add debug mode, and add tests - Extract model costs to to avoid duplication - Add debug mode parameter to ApiManager class - Move debug mode configuration to - Log AI response and budget messages in debug mode - Implement 'test_api_manager.py' * Fixed test_setup failing. An extra user input is needed for api budget * Linting --------- Co-authored-by: Rob Luke <code@robertluke.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com>
2023-04-23 21:04:31 +00:00
api_budget_input = utils.clean_input(
f"{Fore.LIGHTBLUE_EX}Budget{Style.RESET_ALL}: $"
)
if api_budget_input == "":
api_budget = 0.0
else:
try:
api_budget = float(api_budget_input.replace("$", ""))
except ValueError:
logger.typewriter_log(
"Invalid budget input. Setting budget to unlimited.", Fore.RED
)
api_budget = 0.0
return AIConfig(ai_name, ai_role, ai_goals, api_budget)
Automatic prompting (#2896) * Add automatic ai prompting * Tweak the default prompt. * Print agent info upon creation. * Improve system prompt * Switch to fast_llm_model by default * Add format output command to user prompt. This vastly improves formatting success rate. * Add fallback to manual mode if llm output cannot be parsed (or other error). * Add unit test to cover ai creation setup. * Replace redundent prompt with manual mode instructions. * Add missing docstrings and typing. * Runs black on changes. * Runs isort * Update Python version and benchmark file in benchmark.yml * Refactor main function and imports in cli.py * Update import statement in ai_config.py * Add set_temperature and set_memory_backend methods in config.py * Remove unused import in prompt.py * Add goal oriented tasks workflow * Added agent_utils to create agent * added pytest and vcrpy * added write file cassette * created goal oriented task write file with cassettes to not pay openai tokens * solve conflicts * add ability set azure because github workflow needs it off * solve conflicts in cli.py * black because linter fails * solve conflict * setup github action to v3 Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * fix conflicts Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * Plugins: debug line always printed in plugin load * add decorator to tests Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * move decorator higher up Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * merge --------- Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwane.hamadi@redica.com> Co-authored-by: Richard Beales <rich@richbeales.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com> Co-authored-by: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com>
2023-04-23 05:36:10 +00:00
def generate_aiconfig_automatic(user_prompt) -> AIConfig:
"""Generates an AIConfig object from the given string.
Returns:
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.
"""
# Call LLM with the string as user input
messages = [
{
"role": "system",
"content": system_prompt,
},
{
"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",
},
]
output = create_chat_completion(messages, CFG.fast_llm_model)
# Debug LLM Output
logger.debug(f"AI Config Generator Raw Output: {output}")
# Parse the output
ai_name = re.search(r"Name(?:\s*):(?:\s*)(.*)", output, re.IGNORECASE).group(1)
ai_role = (
re.search(
r"Description(?:\s*):(?:\s*)(.*?)(?:(?:\n)|Goals)",
output,
re.IGNORECASE | re.DOTALL,
)
.group(1)
.strip()
)
ai_goals = re.findall(r"(?<=\n)-\s*(.*)", output)
Make Auto-GPT aware of its running cost (#762) * Implemented running cost counter for chat completions This data is known to the AI as additional system context, and is printed out to the user * Added comments to api_manager.py * Added user-defined API budget. The user is now prompted if they want to give the AI a budget for API calls. If they enter nothing, there is no monetary limit, but if they define a budget then the AI will be told to shut down gracefully once it has come within 1 cent of its limit, and to shut down immediately once it has exceeded its limit. If a budget is defined, Auto-GPT is always aware of how much it was given and how much remains to be spent. * Chat completion calls are now done through api_manager. Total running cost is printed. * Implemented api budget setting and tracking User can now configure a maximum api budget, and the AI is aware of that and its remaining budget. The AI is instructed to shut down when exceeding the budget. * Update autogpt/api_manager.py Change "per token" to "per 1000 tokens" in a comment on the api cost Co-authored-by: Rob Luke <code@robertluke.net> * Fixed lint errors * Include embedding costs * Add embedding completion cost * lint * Added 'requires_api_key' decorator to test_commands.py, switched to a valid chat completions model * Refactor API manager, add debug mode, and add tests - Extract model costs to to avoid duplication - Add debug mode parameter to ApiManager class - Move debug mode configuration to - Log AI response and budget messages in debug mode - Implement 'test_api_manager.py' * Fixed test_setup failing. An extra user input is needed for api budget * Linting --------- Co-authored-by: Rob Luke <code@robertluke.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com>
2023-04-23 21:04:31 +00:00
api_budget = 0.0 # TODO: parse api budget using a regular expression
Automatic prompting (#2896) * Add automatic ai prompting * Tweak the default prompt. * Print agent info upon creation. * Improve system prompt * Switch to fast_llm_model by default * Add format output command to user prompt. This vastly improves formatting success rate. * Add fallback to manual mode if llm output cannot be parsed (or other error). * Add unit test to cover ai creation setup. * Replace redundent prompt with manual mode instructions. * Add missing docstrings and typing. * Runs black on changes. * Runs isort * Update Python version and benchmark file in benchmark.yml * Refactor main function and imports in cli.py * Update import statement in ai_config.py * Add set_temperature and set_memory_backend methods in config.py * Remove unused import in prompt.py * Add goal oriented tasks workflow * Added agent_utils to create agent * added pytest and vcrpy * added write file cassette * created goal oriented task write file with cassettes to not pay openai tokens * solve conflicts * add ability set azure because github workflow needs it off * solve conflicts in cli.py * black because linter fails * solve conflict * setup github action to v3 Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * fix conflicts Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * Plugins: debug line always printed in plugin load * add decorator to tests Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * move decorator higher up Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> * merge --------- Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwanehamadi@gmail.com> Co-authored-by: Merwane Hamadi <merwane.hamadi@redica.com> Co-authored-by: Richard Beales <rich@richbeales.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com> Co-authored-by: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com>
2023-04-23 05:36:10 +00:00
Make Auto-GPT aware of its running cost (#762) * Implemented running cost counter for chat completions This data is known to the AI as additional system context, and is printed out to the user * Added comments to api_manager.py * Added user-defined API budget. The user is now prompted if they want to give the AI a budget for API calls. If they enter nothing, there is no monetary limit, but if they define a budget then the AI will be told to shut down gracefully once it has come within 1 cent of its limit, and to shut down immediately once it has exceeded its limit. If a budget is defined, Auto-GPT is always aware of how much it was given and how much remains to be spent. * Chat completion calls are now done through api_manager. Total running cost is printed. * Implemented api budget setting and tracking User can now configure a maximum api budget, and the AI is aware of that and its remaining budget. The AI is instructed to shut down when exceeding the budget. * Update autogpt/api_manager.py Change "per token" to "per 1000 tokens" in a comment on the api cost Co-authored-by: Rob Luke <code@robertluke.net> * Fixed lint errors * Include embedding costs * Add embedding completion cost * lint * Added 'requires_api_key' decorator to test_commands.py, switched to a valid chat completions model * Refactor API manager, add debug mode, and add tests - Extract model costs to to avoid duplication - Add debug mode parameter to ApiManager class - Move debug mode configuration to - Log AI response and budget messages in debug mode - Implement 'test_api_manager.py' * Fixed test_setup failing. An extra user input is needed for api budget * Linting --------- Co-authored-by: Rob Luke <code@robertluke.net> Co-authored-by: Nicholas Tindle <nick@ntindle.com>
2023-04-23 21:04:31 +00:00
return AIConfig(ai_name, ai_role, ai_goals, api_budget)