updated prompt formatting
This commit is contained in:
parent
e83fe9b479
commit
6743ea6ece
1 changed files with 14 additions and 11 deletions
|
@ -5,11 +5,11 @@ import { Ollama } from 'ollama/browser';
|
||||||
|
|
||||||
const MODEL = 'deepseek-coder:6.7b';
|
const MODEL = 'deepseek-coder:6.7b';
|
||||||
|
|
||||||
const PREFIX_START = '<fileStart>';
|
const PREFIX_START = '<prefixStart>';
|
||||||
const PREFIX_END = '</fileStart>';
|
const PREFIX_END = '<prefixEnd>';
|
||||||
|
|
||||||
const SUFFIX_START = '<fileEnd>';
|
const SUFFIX_START = '<suffixStart>';
|
||||||
const SUFFIX_END = '</fileEnd>';
|
const SUFFIX_END = '<suffixEnd>';
|
||||||
|
|
||||||
const MAX_TOKENS = 50;
|
const MAX_TOKENS = 50;
|
||||||
const GENERATION_TIMEOUT = 200;
|
const GENERATION_TIMEOUT = 200;
|
||||||
|
@ -35,12 +35,15 @@ const getModelSupportsSuffix = async (model: string) => {
|
||||||
const getPrompt = (document: vscode.TextDocument, position: vscode.Position) => {
|
const getPrompt = (document: vscode.TextDocument, position: vscode.Position) => {
|
||||||
const prefix = document.getText(new vscode.Range(0, 0, position.line, position.character));
|
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 messageHeader = `In an english code base with the file.\nfile:\nproject {PROJECT_NAME}\nfile {FILE_NAME}\nlanguage {LANG}`
|
||||||
|
|
||||||
const prompt = messageHeader
|
|
||||||
.replace("{PROJECT_NAME}", vscode.workspace.name || "Untitled")
|
.replace("{PROJECT_NAME}", vscode.workspace.name || "Untitled")
|
||||||
.replace("{FILE_NAME}", document.fileName)
|
.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;
|
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 messageSuffix = `End of the file:\n${SUFFIX_START}\n${suffix}\n${SUFFIX_END}\n`;
|
||||||
const messagePrefix = `Start of the file:\n${PREFIX_START}`;
|
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("{PROJECT_NAME}", vscode.workspace.name || "Untitled")
|
||||||
.replace("{FILE_NAME}", document.fileName)
|
.replace("{FILE_NAME}", document.fileName)
|
||||||
.replace("{LANG}", document.languageId);
|
.replace("{LANG}", document.languageId);
|
||||||
|
@ -97,9 +100,9 @@ export const activate = (context: vscode.ExtensionContext) => {
|
||||||
console.log('"ai-code" extensions loaded');
|
console.log('"ai-code" extensions loaded');
|
||||||
|
|
||||||
const provider: vscode.InlineCompletionItemProvider = {
|
const provider: vscode.InlineCompletionItemProvider = {
|
||||||
async provideInlineCompletionItems(document, position, context, _token) {
|
async provideInlineCompletionItems(document, position, context, token) {
|
||||||
try {
|
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 resultBuffer: string[] = await new Promise(async (resolve, reject) => {
|
||||||
const buffer: string[] = [];
|
const buffer: string[] = [];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue