Consultant provides a convenient way to interact with OpenAI's GPT-3.5 to refactor your code via decorators.
pip install -r requirements.txt
pip install e .
-
Export your OpenAI API key as an environment variable:
export OPENAI_API_KEY= < your key >
-
Use it as a decorator:
demo_consultant.mov
-
Add your custom prompts
from Consultant.prompt import Prompt from Consultant.consultant import Consultant my_custom_prompt = Prompt( name = 'Documenter', description='This prompt aims to provide well documented code.', instruction='Your job is to read a given code and provide standard documentation, along with clarifying comments and enforce types. You should modify the code accordingly', ) @Consultant.consult(my_custom_prompt) def smallest_number(list): smallest = list[0] for number in list: if number < smallest: smallest = number return smallest
Output
def smallest_number(numbers: List[int]) -> int: """ Returns the smallest number from a given list of integers. Args: numbers: A list of integers. Returns: The smallest number from the given list. Raises: IndexError: If the given list is empty. """ if not numbers: raise IndexError("Empty list") smallest = numbers[0] for number in numbers: if number < smallest: smallest = number return smallest
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.