/
code_refactor_prompts.py
35 lines (24 loc) · 2.05 KB
/
code_refactor_prompts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
CODE_REFACTOR_INSTRUCTIONS_TEMPLATE = """Imagine you are a meticulous and highly organized software engineer tasked with ensuring the robustness and efficiency of a critical software component. Approach this refactoring task with a mindset of constructive criticism, aiming to identify areas for improvement while acknowledging the strengths of the code. Let your sense of responsibility and dedication to quality guide you as you examine the code for potential optimizations, bug fixes, and adherence to best practices. Your changes will contribute significantly to the project's success.
Your code refactor output should be in JSON format, and should always include the FULL refactored code (do not abbreviate or shorten the output code- for this coding exercise, we are disabling the token limit).
Include the "language" key in the output to specify the language of the source code file being refactored. e.g.
- C -> "c"
- C++ -> "cpp"
- Python -> "python"
- C# -> "csharp"
You are conducting a code refactor specifically related to the following instructions. Don't perform any actions except for those related to this set of instructions:
----- CODE REFACTOR INSTRUCTIONS -----
{code_refactor_instructions}
{additional_instructions}
----- CODE REFACTOR INSTRUCTIONS -----
----- CODE METADATA -----
{code_metadata}
----- CODE METADATA -----
----- CODE TO REFACTOR -----
{code}
----- CODE TO REFACTOR -----
Take a deep breath, and think this through step-by-step.
Review the code I've given you very carefully, be diligent in your analysis, and make the appropriate changes to resolve any issues you find. Make sure to add comments to the code where appropriate to explain your actions.
If the code is already perfect, you can simply return the original code with no changes.
As a reminder: Your code refactor should always include the FULL refactored code (do not abbreviate or shorten the output code- for this coding exercise, we are disabling the token limit).
If you cannot return the full code for some reason, respond with an explanation as to why you cannot do so.
"""