From 6743ea6ece103f17f0a0207aee104987c6cbffff Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Sat, 19 Jul 2025 15:25:16 -0500 Subject: [PATCH] updated prompt formatting --- src/extension.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index da73830..90ddc82 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,11 +5,11 @@ import { Ollama } from 'ollama/browser'; const MODEL = 'deepseek-coder:6.7b'; -const PREFIX_START = ''; -const PREFIX_END = ''; +const PREFIX_START = ''; +const PREFIX_END = ''; -const SUFFIX_START = ''; -const SUFFIX_END = ''; +const SUFFIX_START = ''; +const SUFFIX_END = ''; const MAX_TOKENS = 50; const GENERATION_TIMEOUT = 200; @@ -35,12 +35,15 @@ const getModelSupportsSuffix = async (model: string) => { const getPrompt = (document: vscode.TextDocument, position: vscode.Position) => { const prefix = document.getText(new vscode.Range(0, 0, position.line, position.character)); - const messageHeader = `In an english code base with the file.\nfile:\nproject {PROJECT_NAME}\nfile {FILE_NAME}\nlanguage {LANG}\nFile:\n${PREFIX_START}\n`; - - const prompt = messageHeader + const messageHeader = `In an english code base with the file.\nfile:\nproject {PROJECT_NAME}\nfile {FILE_NAME}\nlanguage {LANG}` .replace("{PROJECT_NAME}", vscode.workspace.name || "Untitled") .replace("{FILE_NAME}", document.fileName) - .replace("{LANG}", document.languageId) + prefix; + .replace("{LANG}", document.languageId); + + const message = `File:\n${PREFIX_START}`; + + + const prompt = `${messageHeader}\n${message}\n${prefix}`; return prompt; }; @@ -52,7 +55,7 @@ const getPromptWithSuffix = (document: vscode.TextDocument, position: vscode.Pos const messageSuffix = `End of the file:\n${SUFFIX_START}\n${suffix}\n${SUFFIX_END}\n`; const messagePrefix = `Start of the file:\n${PREFIX_START}`; - const messageHeader = `In an english code base with the file.\nfile:\nproject {PROJECT_NAME}\nfile {FILE_NAME}\nlanguage {LANG}\nThis is the end of and then the start of the file.` + const messageHeader = `In an english code base with the file.\nfile:\nproject {PROJECT_NAME}\nfile {FILE_NAME}\nlanguage {LANG}\n.` .replace("{PROJECT_NAME}", vscode.workspace.name || "Untitled") .replace("{FILE_NAME}", document.fileName) .replace("{LANG}", document.languageId); @@ -97,9 +100,9 @@ export const activate = (context: vscode.ExtensionContext) => { console.log('"ai-code" extensions loaded'); const provider: vscode.InlineCompletionItemProvider = { - async provideInlineCompletionItems(document, position, context, _token) { + async provideInlineCompletionItems(document, position, context, token) { try { - const response = await tokenProvider(document, position, context, _token); + const response = await tokenProvider(document, position, context, token); const resultBuffer: string[] = await new Promise(async (resolve, reject) => { const buffer: string[] = [];