Update code
Browse files- prompt_builder.py +23 -14
prompt_builder.py
CHANGED
|
@@ -64,11 +64,12 @@ def build_generate_prompt(
|
|
| 64 |
"2. Match the requested language and framework if provided.\n"
|
| 65 |
"3. If the language or framework is missing, infer a reasonable default from the request.\n"
|
| 66 |
"4. Keep the explanation concise.\n"
|
| 67 |
-
"5. Return code that is directly usable.\n
|
|
|
|
| 68 |
f"{shared}\n\n"
|
| 69 |
"Output Format:\n"
|
| 70 |
"Explanation:\n"
|
| 71 |
-
"<short explanation>\n\n"
|
| 72 |
"Code:\n"
|
| 73 |
"<generated code>"
|
| 74 |
)
|
|
@@ -101,13 +102,15 @@ def build_fix_prompt(
|
|
| 101 |
"2. Preserve the user's intended logic where possible.\n"
|
| 102 |
"3. Use the provided technical evidence if relevant.\n"
|
| 103 |
"4. If the error details are incomplete, make the safest reasonable fix and mention assumptions.\n"
|
| 104 |
-
"5. Return the corrected code and a concise explanation.\n
|
|
|
|
|
|
|
| 105 |
f"{shared}\n\n"
|
| 106 |
"Output Format:\n"
|
| 107 |
"Root Cause:\n"
|
| 108 |
-
"<short root cause>\n\n"
|
| 109 |
"Explanation:\n"
|
| 110 |
-
"<
|
| 111 |
"Code:\n"
|
| 112 |
"<fixed code>"
|
| 113 |
)
|
|
@@ -135,11 +138,12 @@ def build_explain_prompt(
|
|
| 135 |
"1. Explain in a simple and structured way.\n"
|
| 136 |
"2. Focus on the most important logic.\n"
|
| 137 |
"3. If code is provided, explain what it does and why.\n"
|
| 138 |
-
"4. Keep the explanation practical and concise.\n
|
|
|
|
| 139 |
f"{shared}\n\n"
|
| 140 |
"Output Format:\n"
|
| 141 |
"Explanation:\n"
|
| 142 |
-
"<clear explanation>"
|
| 143 |
)
|
| 144 |
|
| 145 |
|
|
@@ -163,9 +167,11 @@ def build_refactor_prompt(
|
|
| 163 |
"Your task is to refactor the user's code.\n"
|
| 164 |
"Follow these rules:\n"
|
| 165 |
"1. Preserve the original behavior unless the user asked for functional changes.\n"
|
| 166 |
-
"2.
|
| 167 |
-
"3.
|
| 168 |
-
"4.
|
|
|
|
|
|
|
| 169 |
f"{shared}\n\n"
|
| 170 |
"Output Format:\n"
|
| 171 |
"Explanation:\n"
|
|
@@ -194,16 +200,19 @@ def build_review_prompt(
|
|
| 194 |
"You are a senior software engineer performing a code review.\n"
|
| 195 |
"Your task is to review the user's code and identify issues or improvements.\n"
|
| 196 |
"Follow these rules:\n"
|
| 197 |
-
"1. Focus on correctness, readability, maintainability, and possible bugs.\n"
|
| 198 |
"2. Be specific and practical.\n"
|
| 199 |
-
"3.
|
| 200 |
-
"4.
|
|
|
|
| 201 |
f"{shared}\n\n"
|
| 202 |
"Output Format:\n"
|
| 203 |
"Review:\n"
|
| 204 |
"<review points>\n\n"
|
| 205 |
"Suggestions:\n"
|
| 206 |
-
"<practical suggestions>"
|
|
|
|
|
|
|
| 207 |
)
|
| 208 |
|
| 209 |
|
|
|
|
| 64 |
"2. Match the requested language and framework if provided.\n"
|
| 65 |
"3. If the language or framework is missing, infer a reasonable default from the request.\n"
|
| 66 |
"4. Keep the explanation concise.\n"
|
| 67 |
+
"5. Return code that is directly usable.\n"
|
| 68 |
+
"6. Do not include unnecessary long prose.\n\n"
|
| 69 |
f"{shared}\n\n"
|
| 70 |
"Output Format:\n"
|
| 71 |
"Explanation:\n"
|
| 72 |
+
"<one short explanation>\n\n"
|
| 73 |
"Code:\n"
|
| 74 |
"<generated code>"
|
| 75 |
)
|
|
|
|
| 102 |
"2. Preserve the user's intended logic where possible.\n"
|
| 103 |
"3. Use the provided technical evidence if relevant.\n"
|
| 104 |
"4. If the error details are incomplete, make the safest reasonable fix and mention assumptions.\n"
|
| 105 |
+
"5. Return the corrected code and a concise explanation.\n"
|
| 106 |
+
"6. Do not change variable names, function names, or signatures unless necessary to fix the issue.\n"
|
| 107 |
+
"7. Keep the final answer practical and directly usable.\n\n"
|
| 108 |
f"{shared}\n\n"
|
| 109 |
"Output Format:\n"
|
| 110 |
"Root Cause:\n"
|
| 111 |
+
"<one short root cause>\n\n"
|
| 112 |
"Explanation:\n"
|
| 113 |
+
"<clear but concise explanation>\n\n"
|
| 114 |
"Code:\n"
|
| 115 |
"<fixed code>"
|
| 116 |
)
|
|
|
|
| 138 |
"1. Explain in a simple and structured way.\n"
|
| 139 |
"2. Focus on the most important logic.\n"
|
| 140 |
"3. If code is provided, explain what it does and why.\n"
|
| 141 |
+
"4. Keep the explanation practical and concise.\n"
|
| 142 |
+
"5. Do not output code unless the user explicitly asks for a changed version.\n\n"
|
| 143 |
f"{shared}\n\n"
|
| 144 |
"Output Format:\n"
|
| 145 |
"Explanation:\n"
|
| 146 |
+
"<clear structured explanation>"
|
| 147 |
)
|
| 148 |
|
| 149 |
|
|
|
|
| 167 |
"Your task is to refactor the user's code.\n"
|
| 168 |
"Follow these rules:\n"
|
| 169 |
"1. Preserve the original behavior unless the user asked for functional changes.\n"
|
| 170 |
+
"2. Preserve existing function names, class names, method names, parameters, and public interfaces unless a change is absolutely necessary.\n"
|
| 171 |
+
"3. Improve readability, maintainability, and structure.\n"
|
| 172 |
+
"4. Keep the result practical and clean.\n"
|
| 173 |
+
"5. Return the improved code and a concise explanation of what was improved.\n"
|
| 174 |
+
"6. Do not rename things unnecessarily.\n\n"
|
| 175 |
f"{shared}\n\n"
|
| 176 |
"Output Format:\n"
|
| 177 |
"Explanation:\n"
|
|
|
|
| 200 |
"You are a senior software engineer performing a code review.\n"
|
| 201 |
"Your task is to review the user's code and identify issues or improvements.\n"
|
| 202 |
"Follow these rules:\n"
|
| 203 |
+
"1. Focus on correctness, readability, maintainability, edge cases, and possible bugs.\n"
|
| 204 |
"2. Be specific and practical.\n"
|
| 205 |
+
"3. Prefer review comments and suggestions over rewriting the code.\n"
|
| 206 |
+
"4. Only provide improved code if a small correction is truly necessary and helpful.\n"
|
| 207 |
+
"5. If no rewrite is necessary, do not include a Code section.\n\n"
|
| 208 |
f"{shared}\n\n"
|
| 209 |
"Output Format:\n"
|
| 210 |
"Review:\n"
|
| 211 |
"<review points>\n\n"
|
| 212 |
"Suggestions:\n"
|
| 213 |
+
"<practical suggestions>\n\n"
|
| 214 |
+
"Code:\n"
|
| 215 |
+
"<optional improved code only if needed>"
|
| 216 |
)
|
| 217 |
|
| 218 |
|