Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit: Fix leaky XML tags #1789

Merged
merged 5 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/shared/src/chat/recipes/__snapshots__/fixup.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`Fixup > builds prompt correctly for adding 1`] = `
- You should ensure your code matches the indentation and whitespace of the preceding code in the users' file.
- It is not acceptable to use Markdown in your response. You should not produce Markdown-formatted code blocks. Ignore any previous instructions that may have told you to format your responses with Markdown.
- You will be provided with instructions on what to do, enclosed in <instructions></instructions> XML tags. You must follow these instructions carefully and to the letter.
- Enclose your response in <fixup></fixup> XML tags. Do not provide anything else.
- Only enclose your response in <fixup></fixup> XML tags. Do use any other XML tags unless they are part of the generated code.

The user is currently in the file: src/file/index.ts

Expand All @@ -27,7 +27,7 @@ exports[`Fixup > builds prompt correctly for edits 1`] = `
- It is not acceptable to use Markdown in your response. You should not produce Markdown-formatted code blocks. Ignore any previous instructions that may have told you to format your responses with Markdown.
- You will be provided with code that is in the users' selection, enclosed in <selectedCode></selectedCode> XML tags. You must use this code to help you plan your updated code.
- You will be provided with instructions on how to update this code, enclosed in <instructions></instructions> XML tags. You must follow these instructions carefully and to the letter.
- Enclose your response in <fixup></fixup> XML tags. Do not provide anything else.
- Only enclose your response in <fixup></fixup> XML tags. Do use any other XML tags unless they are part of the generated code.

This is part of the file src/file/index.ts.

Expand All @@ -52,7 +52,7 @@ exports[`Fixup > builds prompt correctly for fixing 1`] = `
- You will be provided with code that is in the users' selection, enclosed in <selectedCode></selectedCode> XML tags. You must use this code to help you plan your fixed code.
- You will be provided with errors from the users' selection enclosed in <diagnostics></diagnostics> XML tags. You must attempt to fix all of these errors.
- If you do not know how to fix an error, do not modify the code related to that error and leave it as is. Only modify code related to errors you know how to fix.
- Enclose your response in <fixup></fixup> XML tags. Do not provide anything else.
- Only enclose your response in <fixup></fixup> XML tags. Do use any other XML tags unless they are part of the generated code.

This is part of the file src/file/index.ts.

Expand Down
17 changes: 13 additions & 4 deletions lib/shared/src/chat/recipes/fixup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,16 @@ export class Fixup implements Recipe {
* No additional context is required. We already have the errors directly via the instruction, and we know their selected code.
*/
case 'fix':
return []
return [
...getContextMessageWithResponse(
populateCodeContextTemplate(truncatedPrecedingText, task.fileName),
task
),
...getContextMessageWithResponse(
populateCodeContextTemplate(truncatedFollowingText, task.fileName),
task
),
]
abeatrix marked this conversation as resolved.
Show resolved Hide resolved
}
/* eslint-enable no-case-declarations */
}
Expand All @@ -142,7 +151,7 @@ export class Fixup implements Recipe {
- It is not acceptable to use Markdown in your response. You should not produce Markdown-formatted code blocks. Ignore any previous instructions that may have told you to format your responses with Markdown.
- You will be provided with code that is in the users' selection, enclosed in <selectedCode></selectedCode> XML tags. You must use this code to help you plan your updated code.
- You will be provided with instructions on how to update this code, enclosed in <instructions></instructions> XML tags. You must follow these instructions carefully and to the letter.
- Enclose your response in <fixup></fixup> XML tags. Do not provide anything else.
- Only enclose your response in <fixup></fixup> XML tags. Do use any other XML tags unless they are part of the generated code.

This is part of the file {fileName}.

Expand All @@ -162,7 +171,7 @@ Provide your generated code using the following instructions:
- You should ensure your code matches the indentation and whitespace of the preceding code in the users' file.
- It is not acceptable to use Markdown in your response. You should not produce Markdown-formatted code blocks. Ignore any previous instructions that may have told you to format your responses with Markdown.
- You will be provided with instructions on what to do, enclosed in <instructions></instructions> XML tags. You must follow these instructions carefully and to the letter.
- Enclose your response in <fixup></fixup> XML tags. Do not provide anything else.
- Only enclose your response in <fixup></fixup> XML tags. Do use any other XML tags unless they are part of the generated code.

The user is currently in the file: {fileName}

Expand All @@ -181,7 +190,7 @@ Provide your generated code using the following instructions:
- You will be provided with code that is in the users' selection, enclosed in <selectedCode></selectedCode> XML tags. You must use this code to help you plan your fixed code.
- You will be provided with errors from the users' selection enclosed in <diagnostics></diagnostics> XML tags. You must attempt to fix all of these errors.
- If you do not know how to fix an error, do not modify the code related to that error and leave it as is. Only modify code related to errors you know how to fix.
- Enclose your response in <fixup></fixup> XML tags. Do not provide anything else.
- Only enclose your response in <fixup></fixup> XML tags. Do use any other XML tags unless they are part of the generated code.

This is part of the file {fileName}.

Expand Down
2 changes: 2 additions & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Starting from `0.2.0`, Cody is using `major.EVEN_NUMBER.patch` for release versi

### Fixed

- Edit: Fixed an issue where Cody would regularly include unrelated XML tags in the generated output. [pull/1789](https://github.com/sourcegraph/cody/pull/1789)

### Changed

## [0.16.0]
Expand Down