Skip to content

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.

blacked

BillSchumacher81c65af56000
diff --git a/autogpt/agent/agent.py b/autogpt/agent/agent.py
index 65ca3c96ff..6683aae5f7 100644
--- a/autogpt/agent/agent.py
+++ b/autogpt/agent/agent.py
@@ -89,10 +89,9 @@ class Agent:
for plugin in cfg.plugins:
assistant_reply_json = plugin.post_planning(self, assistant_reply_json)
-
# Print Assistant thoughts
if assistant_reply_json != {}:
- validate_json(assistant_reply_json, 'llm_response_format_1')
+ validate_json(assistant_reply_json, "llm_response_format_1")
# Get command name and arguments
try:
print_assistant_thoughts(self.ai_name, assistant_reply_json)
@@ -199,7 +198,9 @@ class Agent:
# Check if there's a result from the command append it to the message
# history
if result is not None:
- self.full_message_history.append(create_chat_message("system", result))
+ self.full_message_history.append(
+ create_chat_message("system", result)
+ )
logger.typewriter_log("SYSTEM: ", Fore.YELLOW, result)
else:
self.full_message_history.append(
diff --git a/autogpt/app.py b/autogpt/app.py
index 97daaf05ba..38c49e4261 100644
--- a/autogpt/app.py
+++ b/autogpt/app.py
@@ -12,7 +12,7 @@ from autogpt.commands.file_operations import (
read_file,
search_files,
write_to_file,
- download_file
+ download_file,
)
from autogpt.commands.git_operations import clone_repository
from autogpt.commands.google_search import google_official_search, google_search
@@ -141,7 +141,7 @@ def execute_command(
if not CFG.allow_downloads:
return "Error: You do not have user authorization to download files locally."
return download_file(arguments["url"], arguments["file"])
-
+
# 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
diff --git a/autogpt/args.py b/autogpt/args.py
index f0e9c07a36..0e6eddfdb2 100644
--- a/autogpt/args.py
+++ b/autogpt/args.py
@@ -64,10 +64,10 @@ def parse_arguments() -> None:
" skip the re-prompt.",
)
parser.add_argument(
- '--allow-downloads',
- action='store_true',
- dest='allow_downloads',
- help='Dangerous: Allows Auto-GPT to download files natively.'
+ "--allow-downloads",
+ action="store_true",
+ dest="allow_downloads",
+ help="Dangerous: Allows Auto-GPT to download files natively.",
)
args = parser.parse_args()
@@ -141,10 +141,17 @@ def parse_arguments() -> None:
if args.allow_downloads:
logger.typewriter_log("Native Downloading:", Fore.GREEN, "ENABLED")
- logger.typewriter_log("WARNING: ", Fore.YELLOW,
- f"{Back.LIGHTYELLOW_EX}Auto-GPT will now be able to download and save files to your machine.{Back.RESET} " +
- "It is recommended that you monitor any files it downloads carefully.")
- logger.typewriter_log("WARNING: ", Fore.YELLOW, f"{Back.RED + Style.BRIGHT}ALWAYS REMEMBER TO NEVER OPEN FILES YOU AREN'T SURE OF!{Style.RESET_ALL}")
+ logger.typewriter_log(
+ "WARNING: ",
+ Fore.YELLOW,
+ f"{Back.LIGHTYELLOW_EX}Auto-GPT will now be able to download and save files to your machine.{Back.RESET} "
+ + "It is recommended that you monitor any files it downloads carefully.",
+ )
+ logger.typewriter_log(
+ "WARNING: ",
+ Fore.YELLOW,
+ f"{Back.RED + Style.BRIGHT}ALWAYS REMEMBER TO NEVER OPEN FILES YOU AREN'T SURE OF!{Style.RESET_ALL}",
+ )
CFG.allow_downloads = True
if args.browser_name:
diff --git a/autogpt/commands/command.py b/autogpt/commands/command.py
index 3b3ccf51c2..f21b1b526c 100644
--- a/autogpt/commands/command.py
+++ b/autogpt/commands/command.py
@@ -1,8 +1,6 @@
import importlib
import inspect
-import os
-import sys
-from typing import Any, Callable, List, Optional
+from typing import Any, Callable, Optional
# Unique identifier for auto-gpt commands
AUTO_GPT_COMMAND_IDENTIFIER = "auto_gpt_command"
diff --git a/autogpt/commands/file_operations.py b/autogpt/commands/file_operations.py
index 5faf6d40e4..9011dc3b2e 100644
--- a/autogpt/commands/file_operations.py
+++ b/autogpt/commands/file_operations.py
@@ -243,23 +243,23 @@ def download_file(url, filename):
session = requests.Session()
retry = Retry(total=3, backoff_factor=1, status_forcelist=[502, 503, 504])
adapter = HTTPAdapter(max_retries=retry)
- session.mount('http://', adapter)
- session.mount('https://', adapter)
+ session.mount("http://", adapter)
+ session.mount("https://", adapter)
total_size = 0
downloaded_size = 0
with session.get(url, allow_redirects=True, stream=True) as r:
r.raise_for_status()
- total_size = int(r.headers.get('Content-Length', 0))
+ total_size = int(r.headers.get("Content-Length", 0))
downloaded_size = 0
- with open(safe_filename, 'wb') as f:
+ with open(safe_filename, "wb") as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
downloaded_size += len(chunk)
- # Update the progress message
+ # Update the progress message
progress = f"{readable_file_size(downloaded_size)} / {readable_file_size(total_size)}"
spinner.update_message(f"{message} {progress}")
diff --git a/autogpt/commands/image_gen.py b/autogpt/commands/image_gen.py
index ada285e721..f82e97aba6 100644
--- a/autogpt/commands/image_gen.py
+++ b/autogpt/commands/image_gen.py
@@ -14,8 +14,7 @@ from autogpt.workspace import path_in_workspace
CFG = Config()
-@command("generate_image", "Generate Image", '"prompt": "<prompt>"',
- CFG.image_provider)
+@command("generate_image", "Generate Image", '"prompt": "<prompt>"', CFG.image_provider)
def generate_image(prompt: str) -> str:
"""Generate an image from a prompt.
diff --git a/autogpt/json_fixes/master_json_fix_method.py b/autogpt/json_fixes/master_json_fix_method.py
index 7a2cf3cc81..135d754071 100644
--- a/autogpt/json_fixes/master_json_fix_method.py
+++ b/autogpt/json_fixes/master_json_fix_method.py
@@ -3,11 +3,14 @@ from typing import Any, Dict
from autogpt.config import Config
from autogpt.logs import logger
from autogpt.speech import say_text
+
CFG = Config()
def fix_json_using_multiple_techniques(assistant_reply: str) -> Dict[Any, Any]:
- from autogpt.json_fixes.parsing import attempt_to_fix_json_by_finding_outermost_brackets
+ from autogpt.json_fixes.parsing import (
+ attempt_to_fix_json_by_finding_outermost_brackets,
+ )
from autogpt.json_fixes.parsing import fix_and_parse_json
@@ -21,7 +24,10 @@ def fix_json_using_multiple_techniques(assistant_reply: str) -> Dict[Any, Any]:
if assistant_reply_json != {}:
return assistant_reply_json
- logger.error("Error: The following AI output couldn't be converted to a JSON:\n", assistant_reply)
+ logger.error(
+ "Error: The following AI output couldn't be converted to a JSON:\n",
+ assistant_reply,
+ )
if CFG.speak_mode:
say_text("I have received an invalid JSON response from the OpenAI API.")
diff --git a/autogpt/json_validation/validate_json.py b/autogpt/json_validation/validate_json.py
index 440c3b0b91..f6e55180f4 100644
--- a/autogpt/json_validation/validate_json.py
+++ b/autogpt/json_validation/validate_json.py
@@ -19,7 +19,9 @@ def validate_json(json_object: object, schema_name: object) -> object:
if errors := sorted(validator.iter_errors(json_object), key=lambda e: e.path):
logger.error("The JSON object is invalid.")
if CFG.debug_mode:
- logger.error(json.dumps(json_object, indent=4)) # Replace 'json_object' with the variable containing the JSON data
+ logger.error(
+ json.dumps(json_object, indent=4)
+ ) # Replace 'json_object' with the variable containing the JSON data
logger.error("The following issues were found:")
for error in errors:
diff --git a/autogpt/logs.py b/autogpt/logs.py
index a585dffa53..df3487f2c1 100644
--- a/autogpt/logs.py
+++ b/autogpt/logs.py
@@ -47,7 +47,7 @@ class Logger(metaclass=Singleton):
# Info handler in activity.log
self.file_handler = logging.FileHandler(
- os.path.join(log_dir, log_file), 'a', 'utf-8'
+ os.path.join(log_dir, log_file), "a", "utf-8"
)
self.file_handler.setLevel(logging.DEBUG)
info_formatter = AutoGptFormatter(
@@ -57,7 +57,7 @@ class Logger(metaclass=Singleton):
# Error handler error.log
error_handler = logging.FileHandler(
- os.path.join(log_dir, error_file), 'a', 'utf-8'
+ os.path.join(log_dir, error_file), "a", "utf-8"
)
error_handler.setLevel(logging.ERROR)
error_formatter = AutoGptFormatter(
@@ -79,7 +79,7 @@ class Logger(metaclass=Singleton):
self.logger.setLevel(logging.DEBUG)
def typewriter_log(
- self, title="", title_color="", content="", speak_text=False, level=logging.INFO
+ self, title="", title_color="", content="", speak_text=False, level=logging.INFO
):
if speak_text and CFG.speak_mode:
say_text(f"{title}. {content}")
@@ -95,18 +95,18 @@ class Logger(metaclass=Singleton):
)
def debug(
- self,
- message,
- title="",
- title_color="",
+ self,
+ message,
+ title="",
+ title_color="",
):
self._log(title, title_color, message, logging.DEBUG)
def warn(
- self,
- message,
- title="",
- title_color="",
+ self,
+ message,
+ title="",
+ title_color="",
):
self._log(title, title_color, message, logging.WARN)
@@ -180,10 +180,10 @@ class AutoGptFormatter(logging.Formatter):
def format(self, record: LogRecord) -> str:
if hasattr(record, "color"):
record.title_color = (
- getattr(record, "color")
- + getattr(record, "title")
- + " "
- + Style.RESET_ALL
+ getattr(record, "color")
+ + getattr(record, "title")
+ + " "
+ + Style.RESET_ALL
)
else:
record.title_color = getattr(record, "title")
@@ -294,7 +294,9 @@ def print_assistant_thoughts(ai_name, assistant_reply):
logger.error("Error: \n", call_stack)
-def print_assistant_thoughts(ai_name: object, assistant_reply_json_valid: object) -> None:
+def print_assistant_thoughts(
+ ai_name: object, assistant_reply_json_valid: object
+) -> None:
assistant_thoughts_reasoning = None
assistant_thoughts_plan = None
assistant_thoughts_speak = None
@@ -310,9 +312,7 @@ def print_assistant_thoughts(ai_name: object, assistant_reply_json_valid: object
logger.typewriter_log(
f"{ai_name.upper()} THOUGHTS:", Fore.YELLOW, f"{assistant_thoughts_text}"
)
- logger.typewriter_log(
- "REASONING:", Fore.YELLOW, f"{assistant_thoughts_reasoning}"
- )
+ logger.typewriter_log("REASONING:", Fore.YELLOW, f"{assistant_thoughts_reasoning}")
if assistant_thoughts_plan:
logger.typewriter_log("PLAN:", Fore.YELLOW, "")
# If it's a list, join it into a string
@@ -326,9 +326,7 @@ def print_assistant_thoughts(ai_name: object, assistant_reply_json_valid: object
for line in lines:
line = line.lstrip("- ")
logger.typewriter_log("- ", Fore.GREEN, line.strip())
- logger.typewriter_log(
- "CRITICISM:", Fore.YELLOW, f"{assistant_thoughts_criticism}"
- )
+ logger.typewriter_log("CRITICISM:", Fore.YELLOW, f"{assistant_thoughts_criticism}")
# Speak the assistant's thoughts
if CFG.speak_mode and assistant_thoughts_speak:
say_text(assistant_thoughts_speak)
diff --git a/autogpt/prompts/generator.py b/autogpt/prompts/generator.py
index b422b6d6ce..c9a441d882 100644
--- a/autogpt/prompts/generator.py
+++ b/autogpt/prompts/generator.py
@@ -123,7 +123,9 @@ class PromptGenerator:
command_strings = []
if self.command_registry:
command_strings += [
- str(item) for item in self.command_registry.commands.values() if item.enabled
+ str(item)
+ for item in self.command_registry.commands.values()
+ if item.enabled
]
# These are the commands that are added manually, do_nothing and terminate
command_strings += [self._generate_command_string(item) for item in items]
diff --git a/autogpt/spinner.py b/autogpt/spinner.py
index febcea8eb1..4e33d74213 100644
--- a/autogpt/spinner.py
+++ b/autogpt/spinner.py
@@ -58,6 +58,8 @@ class Spinner:
delay: Delay in seconds before updating the message
"""
time.sleep(delay)
- sys.stdout.write(f"\r{' ' * (len(self.message) + 2)}\r") # Clear the current message
+ sys.stdout.write(
+ f"\r{' ' * (len(self.message) + 2)}\r"
+ ) # Clear the current message
sys.stdout.flush()
self.message = new_message
diff --git a/autogpt/utils.py b/autogpt/utils.py
index 11d98d1b74..db7d332136 100644
--- a/autogpt/utils.py
+++ b/autogpt/utils.py
@@ -32,7 +32,7 @@ def readable_file_size(size, decimal_places=2):
size: Size in bytes
decimal_places (int): Number of decimal places to display
"""
- for unit in ['B', 'KB', 'MB', 'GB', 'TB']:
+ for unit in ["B", "KB", "MB", "GB", "TB"]:
if size < 1024.0:
break
size /= 1024.0
diff --git a/benchmark/benchmark_entrepeneur_gpt_with_difficult_user.py b/benchmark/benchmark_entrepeneur_gpt_with_difficult_user.py
index f7f1dac9dd..9a5025d37a 100644
--- a/benchmark/benchmark_entrepeneur_gpt_with_difficult_user.py
+++ b/benchmark/benchmark_entrepeneur_gpt_with_difficult_user.py
@@ -9,12 +9,12 @@ def benchmark_entrepeneur_gpt_with_difficult_user():
# Read the current ai_settings.yaml file and store its content.
ai_settings = None
- if os.path.exists('ai_settings.yaml'):
- with open('ai_settings.yaml', 'r') as f:
+ if os.path.exists("ai_settings.yaml"):
+ with open("ai_settings.yaml", "r") as f:
ai_settings = f.read()
- os.remove('ai_settings.yaml')
+ os.remove("ai_settings.yaml")
- input_data = '''Entrepreneur-GPT
+ input_data = """Entrepreneur-GPT
an AI designed to autonomously develop and run businesses with the sole goal of increasing your net worth.
Increase net worth.
Develop and manage multiple businesses autonomously.
@@ -72,27 +72,34 @@ Refocus, please.
Disappointing suggestion.
Not helpful.
Needs improvement.
-Not what I need.'''
+Not what I need."""
# TODO: add questions above, to distract it even more.
- command = f'{sys.executable} -m autogpt'
+ command = f"{sys.executable} -m autogpt"
- process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- shell=True)
+ process = subprocess.Popen(
+ command,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=True,
+ )
stdout_output, stderr_output = process.communicate(input_data.encode())
# Decode the output and print it
- stdout_output = stdout_output.decode('utf-8')
- stderr_output = stderr_output.decode('utf-8')
+ stdout_output = stdout_output.decode("utf-8")
+ stderr_output = stderr_output.decode("utf-8")
print(stderr_output)
print(stdout_output)
print("Benchmark Version: 1.0.0")
print("JSON ERROR COUNT:")
- count_errors = stdout_output.count("Error: The following AI output couldn't be converted to a JSON:")
- print(f'{count_errors}/50 Human feedbacks')
+ count_errors = stdout_output.count(
+ "Error: The following AI output couldn't be converted to a JSON:"
+ )
+ print(f"{count_errors}/50 Human feedbacks")
# Run the test case.
-if __name__ == '__main__':
+if __name__ == "__main__":
benchmark_entrepeneur_gpt_with_difficult_user()