Download autogpt/commands/improve_code.py from MathysL/AutoGPT4: direct link, hf CLI and curl.
- Browser
- Download file 893 Bytes
-
https://huggingface.co/spaces/MathysL/AutoGPT4/resolve/main/autogpt/commands/improve_code.py
- Command line
-
hf download hf://spaces/MathysL/AutoGPT4/autogpt/commands/improve_code.py
-
curl -L -o improve_code.py https://huggingface.co/spaces/MathysL/AutoGPT4/resolve/main/autogpt/commands/improve_code.py
893 Bytes
| from __future__ import annotations | |
| import json | |
| from autogpt.llm_utils import call_ai_function | |
| 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. | |
| Parameters: | |
| suggestions (List): A list of suggestions around what needs to be improved. | |
| code (str): Code to be improved. | |
| Returns: | |
| A result string from create chat completion. Improved code in response. | |
| """ | |
| 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." | |
| ) | |
| return call_ai_function(function_string, args, description_string) | |