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

Inline Fix: Improve response quality #376

Merged
merged 27 commits into from
Aug 1, 2023
Merged

Inline Fix: Improve response quality #376

merged 27 commits into from
Aug 1, 2023

Conversation

umpox
Copy link
Contributor

@umpox umpox commented Jul 25, 2023

Description

This PR improves the inline /fix workflow by:

  • Improving the prompt.
    • Through following examples from the Claude doc and reworking some possibly confusing instructions.
    • Declaring XML tags better
    • Moving preceding/following text to context messages - helps avoid Claude repeating/editing existing code that shouldn't be included in the selection.
  • Providing better context.
    • We included Markdown file context before, this was problematic because it included Markdown-style code blocks that would often lead to Cody producing Markdown.
    • Intelligently provide context through intent detection. E.g. narrow changes (like adding comments) work better when only providing context from the file. Specific cases like "fix this error" we can also include error messages from the editor.
  • Adding LLM-based intent detection.
    • Uses the fast model to detect intent from the user. Seems to work well from my experience but open to suggestions. I think eventually (once we have a better command UX) we'll want to use this primarily as a fallback and encourage users to use slash commands first.
  • Adding the ability for Cody to pluck errors/warnings/hints from the editors' selection.
    • It should be possible to also do the inverse of this, and add the ability for users to trigger Cody fixups from errors/warnings/hints
FixupQualityImprovements.mov

Test plan

Lots of manual testing on inline fixups.

@umpox umpox changed the title init Inline Fix: Improve response quality Jul 25, 2023
Comment on lines 90 to 93
- You will be provided with code that is below the users' selection, enclosed in <belowCode></belowCode> XML tags. You can use this code, if relevant, to help you plan your rewritten code.
- 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 rewritten code.
- You will be provided with instructions on how to modify this code, enclosed in <instructions></instructions> XML tags. You must follow these instructions carefully and to the letter.
- Enclose your response in <selection></selection> XML tags. Do not provide anything else.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of approach (being very specific by naming the XML tags) is taken from examples in the Anthropic docs. Seems to work well from my testing.

Only provide me with the replacement <selection> and nothing else.
If it doesn't make sense, you do not need to provide <selection>. Instead, tell me how I can help you to understand my request.
- You are an AI programming assistant who is an expert in rewriting code to meet given instructions.
- You should think step-by-step to plan your rewritten code before producing the final output.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work well with Claude, docs

@umpox umpox marked this pull request as ready for review July 31, 2023 14:03
@umpox umpox requested a review from abeatrix July 31, 2023 14:30
@umpox umpox requested review from a team July 31, 2023 14:30
Comment on lines +195 to +207
/**
* The test intent is unique in that we likely want to be much more specific in that context that we retrieve.
* TODO(umpox): How can infer the current testing dependencies, etc?
*/
case 'test':
// Currently the same as add|edit|fix
return getContextMessagesFromSelection(
selection.selectedText,
truncatedPrecedingText,
truncatedFollowingText,
selection,
context.codebaseContext
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abeatrix Am I correct in that you have been looking at improving the test flows? Interested to see if you've found any specific context gathering to be useful

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still wip and got pulled into replacing recipes with commands but I did! I'll share what I have first thing tomorrow since I'm afk atm

@@ -66,6 +68,26 @@ export function populateCurrentEditorSelectedContextTemplate(
)
}

const DIAGNOSTICS_CONTEXT_TEMPLATE = `Use the following {type} from the code snippet in the file \`{filePath}\`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@umpox umpox merged commit 1a0e0ca into main Aug 1, 2023
9 checks passed
@umpox umpox deleted the tr/improved-fixup branch August 1, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants