Download autogpt/commands/write_tests.py from MathysL/AutoGPT4: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/MathysL/AutoGPT4/resolve/main/autogpt/commands/write_tests.py
- Command line
-
hf download hf://spaces/MathysL/AutoGPT4/autogpt/commands/write_tests.py
-
curl -L -o write_tests.py https://huggingface.co/spaces/MathysL/AutoGPT4/resolve/main/autogpt/commands/write_tests.py
1.01 kB
| """A module that contains a function to generate test cases for the submitted code.""" | |
| from __future__ import annotations | |
| import json | |
| from autogpt.llm_utils import call_ai_function | |
| 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. | |
| Parameters: | |
| focus (list): A list of suggestions around what needs to be improved. | |
| code (str): Code for test cases to be generated against. | |
| Returns: | |
| A result string from create chat completion. Test cases for the submitted code | |
| in response. | |
| """ | |
| 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." | |
| ) | |
| return call_ai_function(function_string, args, description_string) | |