From 0a290927a0cd1b8548ac5cf635cce105f24515b4 Mon Sep 17 00:00:00 2001 From: Torantulino Date: Sun, 2 Apr 2023 09:55:44 +0100 Subject: [PATCH 1/3] Reformats with "Black" formatter. --- scripts/ai_functions.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/ai_functions.py b/scripts/ai_functions.py index 0bd6c139..09cdb079 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.""" From abdc7f447ce58d570af512874c4e32259bad6793 Mon Sep 17 00:00:00 2001 From: Torantulino Date: Sun, 2 Apr 2023 09:56:53 +0100 Subject: [PATCH 2/3] Adds comment to call_ai_function. --- scripts/ai_functions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ai_functions.py b/scripts/ai_functions.py index 09cdb079..38daf84c 100644 --- a/scripts/ai_functions.py +++ b/scripts/ai_functions.py @@ -3,6 +3,7 @@ import json import openai +# This is a magic function that can do anything with no-code. See https://github.com/Torantulino/AI-Functions for more info. def call_ai_function(function, args, description, model="gpt-4"): # parse args to comma seperated string args = ", ".join(args) From 01b3ef2f662c79459299a7b120792f56a8c6f4ab Mon Sep 17 00:00:00 2001 From: Torantulino Date: Sun, 2 Apr 2023 08:58:19 +0000 Subject: [PATCH 3/3] Automated changes --- scripts/ai_functions.py | 3 ++- scripts/keys.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/ai_functions.py b/scripts/ai_functions.py index 38daf84c..b79c4dbc 100644 --- a/scripts/ai_functions.py +++ b/scripts/ai_functions.py @@ -3,7 +3,8 @@ import json import openai -# This is a magic function that can do anything with no-code. See https://github.com/Torantulino/AI-Functions for more info. +# This is a magic function that can do anything with no-code. See +# https://github.com/Torantulino/AI-Functions for more info. def call_ai_function(function, args, description, model="gpt-4"): # parse args to comma seperated string args = ", ".join(args) diff --git a/scripts/keys.py b/scripts/keys.py index 6dcf1e2a..1cd439cd 100644 --- a/scripts/keys.py +++ b/scripts/keys.py @@ -1,2 +1,5 @@ -OPENAI_API_KEY="YOUR-OPENAI-KEY" # Get yours from: https://beta.openai.com/account/api-keys -ELEVENLABS_API_KEY="YOUR-ELEVENLABS-KEY" # To access your ElevenLabs API key, head to https://elevenlabs.io, you can view your xi-api-key using the 'Profile' tab on the website. +# Get yours from: https://beta.openai.com/account/api-keys +OPENAI_API_KEY = "YOUR-OPENAI-KEY" +# To access your ElevenLabs API key, head to https://elevenlabs.io, you +# can view your xi-api-key using the 'Profile' tab on the website. +ELEVENLABS_API_KEY = "YOUR-ELEVENLABS-KEY"