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

Imporve code completion variable naming #14467

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions packages/ai-code-completion/src/common/code-completion-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
}

// Get text until the given position
const textUntilCurrentPosition = model.getValueInRange({
const prefix = model.getValueInRange({
startLineNumber: 1,
startColumn: 1,
endLineNumber: position.lineNumber,
endColumn: position.column,
});

// Get text after the given position
const textAfterCurrentPosition = model.getValueInRange({
const suffix = model.getValueInRange({
startLineNumber: position.lineNumber,
startColumn: position.column,
endLineNumber: model.getLineCount(),
Expand All @@ -71,7 +71,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
return undefined;
}
const prompt = await this.promptService
.getPrompt('code-completion-prompt', { textUntilCurrentPosition, textAfterCurrentPosition, file, language })
.getPrompt('code-completion-prompt', { prefix, suffix, file, language })
.then(p => p?.text);
if (!prompt) {
this.logger.error('No prompt found for code-completion-agent');
Expand Down Expand Up @@ -138,7 +138,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
The language of the file is {{language}}. Return your result as plain text without markdown formatting.
Finish the following code snippet.

{{textUntilCurrentPosition}}[[MARKER]]{{textAfterCurrentPosition}}
{{prefix}}[[MARKER]]{{suffix}}

Only return the exact replacement for [[MARKER]] to complete the snippet.`,
},
Expand All @@ -154,8 +154,8 @@ Only return the exact replacement for [[MARKER]] to complete the snippet.`,
readonly agentSpecificVariables: AgentSpecificVariables[] = [
{ name: 'file', usedInPrompt: true, description: 'The uri of the file being edited.' },
{ name: 'language', usedInPrompt: true, description: 'The languageId of the file being edited.' },
{ name: 'textUntilCurrentPosition', usedInPrompt: true, description: 'The code before the current position of the cursor.' },
{ name: 'textAfterCurrentPosition', usedInPrompt: true, description: 'The code after the current position of the cursor.' }
{ name: 'prefix', usedInPrompt: true, description: 'The code before the current position of the cursor.' },
{ name: 'suffix', usedInPrompt: true, description: 'The code after the current position of the cursor.' }
];
readonly tags?: string[] | undefined;
}
Loading