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.

Reformats with "Black" formatter.

Torantulino0a290927a0cd
diff --git a/scripts/ai_functions.py b/scripts/ai_functions.py
index 0bd6c139a9..09cdb07979 100644
--- a/scripts/ai_functions.py
+++ b/scripts/ai_functions.py
@@ -6,19 +6,21 @@ import openai
def call_ai_function(function, args, description, model="gpt-4"):
# parse args to comma seperated string
args = ", ".join(args)
- messages = [{"role": "system",
- "content": f"You are now the following python function: ```# {description}\n{function}```\n\nOnly respond with your `return` value."},
- {"role": "user",
- "content": args}]
+ messages = [
+ {
+ "role": "system",
+ "content": f"You are now the following python function: ```# {description}\n{function}```\n\nOnly respond with your `return` value.",
+ },
+ {"role": "user", "content": args},
+ ]
response = openai.ChatCompletion.create(
- model=model,
- messages=messages,
- temperature=0
+ model=model, messages=messages, temperature=0
)
return response.choices[0].message["content"]
+
# Evaluating code
@@ -33,8 +35,11 @@ def evaluate_code(code: str) -> List[str]:
# Improving code
+
def improve_code(suggestions: List[str], code: str) -> str:
- function_string = "def generate_improved_code(suggestions: List[str], code: str) -> str:"
+ function_string = (
+ "def generate_improved_code(suggestions: List[str], code: str) -> str:"
+ )
args = [json.dumps(suggestions), code]
description_string = """Improves the provided code based on the suggestions provided, making no other changes."""
@@ -44,8 +49,11 @@ def improve_code(suggestions: List[str], code: str) -> str:
# Writing tests
+
def write_tests(code: str, focus: List[str]) -> str:
- function_string = "def create_test_cases(code: str, focus: Optional[str] = None) -> str:"
+ function_string = (
+ "def create_test_cases(code: str, focus: Optional[str] = None) -> str:"
+ )
args = [code, json.dumps(focus)]
description_string = """Generates test cases for the existing code, focusing on specific areas if required."""