Instruct the prompt to not repeat existing comments
What does this MR do and why?
When using the LLM for generation instruction extraction, the LLM more frequently wants to comment and explain the code. These additional instructions ensure it does not repeat existing comments
Resolves #431267 (closed)
Screenshots or screen recordings
POST /api/v4/code_suggestions/completions
{
"current_file": {
"file_name": "test.js",
"content_above_cursor": "function validateAustrianPostalCode(postalCode) { \n// validate austrian postal code",
"content_below_cursor": "\n}"
},
"repositories": []
}
Result
{
"id": "id",
"model": {
"engine": "anthropic",
"name": "claude-2",
"lang": "js"
},
...
"choices": [
{
"text": "\nconst postalCodeRegex = /^[1-9][0-9]{3}$/;\n\nif (!postalCodeRegex.test(postalCode)) {\n return false; \n}\n\nreturn true;\n",
"index": 0,
"finish_reason": "length"
}
]
}
How to set up and validate locally
- Enable code completion for your local instance according to instructions
- Enable the
code_generation_anthropic
andskip_code_generation_instruction_extraction
feature flags - Send a code completion request with a comment just before the cursor
- The response should not have that comment in it's choices text
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Allen Cook