You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: sonnet lazy apply prompt should not change comments (#8665)
* feat: sonnet lazy apply prompt should not change comments
* change for ApplyManager.getApplyPrompt
* change for ApplyToFileHandler.buildApplyPrompt
* remove unused edit prompts in edit templates
* add do not change comments to edit templates
* tweak prompt to remove explicitly
Copy file name to clipboardExpand all lines: core/edit/lazy/prompts.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -14,14 +14,15 @@ const RULES = [
14
14
`Whenever any part of the code is the same as before, you may simply indicate this with a comment that says "${UNCHANGED_CODE}" instead of rewriting.`,
15
15
"You must keep at least one line above and below from the original code, so that we can identify what the previous code was.",
16
16
`Do not place miscellaneous "${UNCHANGED_CODE}" comments at the top or bottom of the file when there is nothing to replace them.`,
17
+
"Leave existing comments in place unless changes require modifying them.",
17
18
// `You should write "${UNCHANGED_CODE}" at least for each function that is unchanged, rather than grouping them into a single comment.`,
18
19
// `You should lean toward using a smaller number of these comments rather than rewriting it for every function if all of them are unchanged.`,
19
20
// `You may do this for imports as well if needed.`,
20
21
// `Do not explain your changes either before or after the code block.`,
21
22
"The code should always be syntactically valid, even with the comments.",
22
23
];
23
24
24
-
functionclaude35SonnetLazyApplyPrompt(
25
+
functionclaudeSonnetLazyApplyPrompt(
25
26
...args: Parameters<LazyApplyPrompt>
26
27
): ReturnType<LazyApplyPrompt>{
27
28
constuserContent=dedent`
@@ -55,7 +56,7 @@ export function lazyApplyPromptForModel(
Output nothing except for the code. No code block, no English explanation, no start/end tags. Leave existing comments in place unless changes require modifying them.`;
Please rewrite the entire code block above in order to satisfy the following request: "${otherData.userInput}". You should rewrite the entire code block without leaving placeholders, even if the code is the same as before.${suffixExplanation}`,
46
+
Please rewrite the entire code block above in order to satisfy the following request: "${otherData.userInput}". You should rewrite the entire code block without leaving placeholders, even if the code is the same as before. Leave existing comments in place unless changes require modifying them.${suffixExplanation}`,
59
47
},
60
48
{
61
49
role: "assistant",
@@ -75,7 +63,7 @@ ${otherData.codeToEdit}
75
63
${suffixTag}
76
64
\`\`\`
77
65
78
-
Please rewrite the entire code block above, editing the portion below "${START_TAG}" in order to satisfy the following request: "${otherData.userInput}". You should rewrite the entire code block without leaving placeholders, even if the code is the same as before.${suffixExplanation}
66
+
Please rewrite the entire code block above, editing the portion below "${START_TAG}" in order to satisfy the following request: "${otherData.userInput}". You should rewrite the entire code block without leaving placeholders, even if the code is the same as before. Leave existing comments in place unless changes require modifying them.${suffixExplanation}
79
67
`,
80
68
},
81
69
{
@@ -93,12 +81,12 @@ const mistralEditPrompt = `[INST] You are a helpful code assistant. Your task is
93
81
{{{codeToEdit}}}
94
82
\`\`\`
95
83
96
-
Just rewrite the code without explanations: [/INST]
84
+
Leave existing comments in place unless changes require modifying them. Just rewrite the code without explanations: [/INST]
97
85
\`\`\`{{{language}}}`;
98
86
99
87
constalpacaEditPrompt=`Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
100
88
101
-
### Instruction: Rewrite the code to satisfy this request: "{{{userInput}}}"
89
+
### Instruction: Leave existing comments in place unless changes require modifying them. Rewrite the code to satisfy this request: "{{{userInput}}}"
102
90
103
91
### Input:
104
92
@@ -116,7 +104,7 @@ const phindEditPrompt = `### System Prompt
116
104
You are an expert programmer and write code on the first attempt without any errors or fillers.
117
105
118
106
### User Message:
119
-
Rewrite the code to satisfy this request: "{{{userInput}}}"
107
+
Leave existing comments in place unless changes require modifying them. Rewrite the code to satisfy this request: "{{{userInput}}}"
120
108
121
109
\`\`\`{{{language}}}
122
110
{{{codeToEdit}}}
@@ -131,7 +119,7 @@ Sure! Here's the code you requested:
131
119
constdeepseekEditPrompt=`### System Prompt
132
120
You are an AI programming assistant, utilizing the DeepSeek Coder model, developed by DeepSeek Company, and your role is to assist with questions related to computer science. For politically sensitive questions, security and privacy issues, and other non-computer science questions, you will not answer.
133
121
### Instruction:
134
-
Rewrite the code to satisfy this request: "{{{userInput}}}"
122
+
Leave existing comments in place unless changes require modifying them. Rewrite the code to satisfy this request: "{{{userInput}}}"
135
123
136
124
\`\`\`{{{language}}}
137
125
{{{codeToEdit}}}
@@ -145,7 +133,7 @@ Sure! Here's the code you requested:
145
133
constzephyrEditPrompt=`<|system|>
146
134
You are an expert programmer and write code on the first attempt without any errors or fillers.</s>
147
135
<|user|>
148
-
Rewrite the code to satisfy this request: "{{{userInput}}}"
136
+
Leave existing comments in place unless changes require modifying them. Rewrite the code to satisfy this request: "{{{userInput}}}"
149
137
150
138
\`\`\`{{{language}}}
151
139
{{{codeToEdit}}}
@@ -160,12 +148,12 @@ const openchatEditPrompt = `GPT4 Correct User: You are an expert programmer and
160
148
\`\`\`{{{language}}}
161
149
{{{codeToEdit}}}
162
150
\`\`\`
163
-
Please only respond with code and put it inside of a markdown code block. Do not give any explanation, but your code should perfectly satisfy the user request.<|end_of_turn|>GPT4 Correct Assistant: Sure thing! Here is the rewritten code that you requested:
151
+
Please only respond with code and put it inside of a markdown code block. Do not give any explanation, but your code should perfectly satisfy the user request. Leave existing comments in place unless changes require modifying them.<|end_of_turn|>GPT4 Correct Assistant: Sure thing! Here is the rewritten code that you requested:
164
152
\`\`\`{{{language}}}
165
153
`;
166
154
167
155
constxWinCoderEditPrompt=`<system>: You are an AI coding agent that helps people with programming. Write a response that appropriately completes the user's request.
168
-
<user>: Please rewrite the following code with these instructions: "{{{userInput}}}"
156
+
<user>: Please rewrite the following code (without changing existing code comments) with these instructions: "{{{userInput}}}"
169
157
\`\`\`{{{language}}}
170
158
{{{codeToEdit}}}
171
159
\`\`\`
@@ -177,7 +165,7 @@ Just rewrite the code without explanations:
177
165
constneuralChatEditPrompt=`### System:
178
166
You are an expert programmer and write code on the first attempt without any errors or fillers.
179
167
### User:
180
-
Rewrite the code to satisfy this request: "{{{userInput}}}"
168
+
Rewrite the code (without changing existing code comments) to satisfy this request: "{{{userInput}}}"
181
169
182
170
\`\`\`{{{language}}}
183
171
{{{codeToEdit}}}
@@ -188,7 +176,7 @@ Sure! Here's the code you requested:
188
176
\`\`\`{{{language}}}
189
177
`;
190
178
191
-
constcodeLlama70bEditPrompt=`<s>Source: system\n\n You are an expert programmer and write code on the first attempt without any errors or fillers. <step> Source: user\n\n Rewrite the code to satisfy this request: "{{{userInput}}}"
179
+
constcodeLlama70bEditPrompt=`<s>Source: system\n\n You are an expert programmer and write code on the first attempt without any errors or fillers. <step> Source: user\n\n Rewrite the code (without changing existing code comments) to satisfy this request: "{{{userInput}}}"
192
180
193
181
\`\`\`{{{language}}}
194
182
{{{codeToEdit}}}
@@ -209,7 +197,7 @@ You are an expert programmer. You will rewrite the above code to do the followin
209
197
210
198
${otherData.userInput}
211
199
212
-
Output only a code block with the rewritten code:
200
+
Leave existing comments in place unless changes require modifying them. Output only a code block with the rewritten code:
Rewrite the above code to satisfy this request: "{{{userInput}}}"<|eot_id|><|start_header_id|>assistant<|end_header_id|>
215
+
Rewrite the above code to satisfy this request (without changing existing code comments): "{{{userInput}}}"<|eot_id|><|start_header_id|>assistant<|end_header_id|>
228
216
Sure! Here's the code you requested:
229
217
\`\`\`{{{language}}}`;
230
218
231
219
constgemmaEditPrompt=`<start_of_turn>user
232
-
You are an expert programmer and write code on the first attempt without any errors or fillers. Rewrite the code to satisfy this request: "{{{userInput}}}"
220
+
You are an expert programmer and write code on the first attempt without any errors or fillers. Rewrite the code to satisfy this request (without changing existing code comments): "{{{userInput}}}"
return`${otherData.original_code}\n\nThe following code was suggested as an edit:\n\`\`\`\n${otherData.new_code}\n\`\`\`\nPlease apply it to the previous code. Do not change comments unless explicitly requested.`;
79
+
return`${otherData.original_code}\n\nThe following code was suggested as an edit:\n\`\`\`\n${otherData.new_code}\n\`\`\`\nPlease apply it to the previous code. Leave existing comments in place unless changes require modifying them.`;
Copy file name to clipboardExpand all lines: extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/ApplyToFileHandler.kt
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,7 @@ class ApplyToFileHandler(
141
141
}
142
142
143
143
privatefunbuildApplyPrompt(): String {
144
-
return"The following code was suggested as an edit:\n```\n${params.text}\n```\nPlease apply it to the previous code."
144
+
return"The following code was suggested as an edit:\n```\n${params.text}\n```\nPlease apply it to the previous code. Leave existing comments in place unless changes require modifying them."
Copy file name to clipboardExpand all lines: extensions/vscode/src/apply/ApplyManager.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -171,7 +171,7 @@ export class ApplyManager {
171
171
* Creates a prompt for applying code edits
172
172
*/
173
173
privategetApplyPrompt(text: string): string{
174
-
return`The following code was suggested as an edit:\n\`\`\`\n${text}\n\`\`\`\nPlease apply it to the previous code.`;
174
+
return`The following code was suggested as an edit:\n\`\`\`\n${text}\n\`\`\`\nPlease apply it to the previous code. Leave existing comments in place unless changes require modifying them.`;
0 commit comments