mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 22:14:28 +01:00
linted changes
This commit is contained in:
@@ -5,16 +5,17 @@ import data
|
|||||||
class AIConfig:
|
class AIConfig:
|
||||||
"""
|
"""
|
||||||
A class object that contains the configuration information for the AI
|
A class object that contains the configuration information for the AI
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
ai_name (str): The name of the AI.
|
ai_name (str): The name of the AI.
|
||||||
ai_role (str): The description of the AI's role.
|
ai_role (str): The description of the AI's role.
|
||||||
ai_goals (list): The list of objectives the AI is supposed to complete.
|
ai_goals (list): The list of objectives the AI is supposed to complete.
|
||||||
"""
|
"""
|
||||||
def __init__(self, ai_name:str="", ai_role:str="", ai_goals:list=[]) -> None:
|
|
||||||
|
def __init__(self, ai_name: str="", ai_role: str="", ai_goals: list=[]) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize a class instance
|
Initialize a class instance
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
ai_name (str): The name of the AI.
|
ai_name (str): The name of the AI.
|
||||||
ai_role (str): The description of the AI's role.
|
ai_role (str): The description of the AI's role.
|
||||||
@@ -30,15 +31,15 @@ class AIConfig:
|
|||||||
SAVE_FILE = "../ai_settings.yaml"
|
SAVE_FILE = "../ai_settings.yaml"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls:object, config_file:str=SAVE_FILE) -> object:
|
def load(cls: object, config_file: str=SAVE_FILE) -> object:
|
||||||
"""
|
"""
|
||||||
Returns class object with parameters (ai_name, ai_role, ai_goals) loaded from yaml file if yaml file exists,
|
Returns class object with parameters (ai_name, ai_role, ai_goals) loaded from yaml file if yaml file exists,
|
||||||
else returns class with no parameters.
|
else returns class with no parameters.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
cls (class object): An AIConfig Class object.
|
cls (class object): An AIConfig Class object.
|
||||||
config_file (int): The path to the config yaml file. DEFAULT: "../ai_settings.yaml"
|
config_file (int): The path to the config yaml file. DEFAULT: "../ai_settings.yaml"
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
cls (object): A instance of given cls object
|
cls (object): A instance of given cls object
|
||||||
"""
|
"""
|
||||||
@@ -54,13 +55,13 @@ class AIConfig:
|
|||||||
|
|
||||||
return cls(ai_name, ai_role, ai_goals)
|
return cls(ai_name, ai_role, ai_goals)
|
||||||
|
|
||||||
def save(self, config_file:str=SAVE_FILE) -> None:
|
def save(self, config_file: str=SAVE_FILE) -> None:
|
||||||
"""
|
"""
|
||||||
Saves the class parameters to the specified file yaml file path as a yaml file.
|
Saves the class parameters to the specified file yaml file path as a yaml file.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
config_file(str): The path to the config yaml file. DEFAULT: "../ai_settings.yaml"
|
config_file(str): The path to the config yaml file. DEFAULT: "../ai_settings.yaml"
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
@@ -71,10 +72,10 @@ class AIConfig:
|
|||||||
def construct_full_prompt(self) -> str:
|
def construct_full_prompt(self) -> str:
|
||||||
"""
|
"""
|
||||||
Returns a prompt to the user with the class information in an organized fashion.
|
Returns a prompt to the user with the class information in an organized fashion.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
None
|
None
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
full_prompt (str): A string containing the intitial prompt for the user including the ai_name, ai_role and ai_goals.
|
full_prompt (str): A string containing the intitial prompt for the user including the ai_name, ai_role and ai_goals.
|
||||||
"""
|
"""
|
||||||
@@ -88,6 +89,7 @@ class AIConfig:
|
|||||||
full_prompt += f"\n\n{data.load_prompt()}"
|
full_prompt += f"\n\n{data.load_prompt()}"
|
||||||
return full_prompt
|
return full_prompt
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import doctest
|
import doctest
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
@@ -9,7 +9,7 @@ cfg = Config()
|
|||||||
def evaluate_code(code: str) -> List[str]:
|
def evaluate_code(code: str) -> List[str]:
|
||||||
"""
|
"""
|
||||||
A function that takes in a string and returns a response from create chat completion api call.
|
A function that takes in a string and returns a response from create chat completion api call.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
code (str): Code to be evaluated.
|
code (str): Code to be evaluated.
|
||||||
Returns:
|
Returns:
|
||||||
@@ -20,14 +20,14 @@ def evaluate_code(code: str) -> List[str]:
|
|||||||
description_string = """Analyzes the given code and returns a list of suggestions for improvements."""
|
description_string = """Analyzes the given code and returns a list of suggestions for improvements."""
|
||||||
|
|
||||||
result_string = call_ai_function(function_string, args, description_string)
|
result_string = call_ai_function(function_string, args, description_string)
|
||||||
|
|
||||||
return result_string
|
return result_string
|
||||||
|
|
||||||
|
|
||||||
def improve_code(suggestions: List[str], code: str) -> str:
|
def improve_code(suggestions: List[str], code: str) -> str:
|
||||||
"""
|
"""
|
||||||
A function that takes in code and suggestions and returns a response from create chat completion api call.
|
A function that takes in code and suggestions and returns a response from create chat completion api call.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
suggestions (List): A list of suggestions around what needs to be improved.
|
suggestions (List): A list of suggestions around what needs to be improved.
|
||||||
code (str): Code to be improved.
|
code (str): Code to be improved.
|
||||||
@@ -47,7 +47,7 @@ def improve_code(suggestions: List[str], code: str) -> str:
|
|||||||
def write_tests(code: str, focus: List[str]) -> str:
|
def write_tests(code: str, focus: List[str]) -> str:
|
||||||
"""
|
"""
|
||||||
A function that takes in code and focus topics and returns a response from create chat completion api call.
|
A function that takes in code and focus topics and returns a response from create chat completion api call.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
focus (List): A list of suggestions around what needs to be improved.
|
focus (List): A list of suggestions around what needs to be improved.
|
||||||
code (str): Code for test cases to be generated against.
|
code (str): Code for test cases to be generated against.
|
||||||
@@ -62,5 +62,3 @@ def write_tests(code: str, focus: List[str]) -> str:
|
|||||||
|
|
||||||
result_string = call_ai_function(function_string, args, description_string)
|
result_string = call_ai_function(function_string, args, description_string)
|
||||||
return result_string
|
return result_string
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user