Merge branch 'continuedev:main' into main
This commit is contained in:
commit
caada6789a
4 changed files with 25 additions and 6 deletions
|
|
@ -83,6 +83,7 @@ export const LINES_TO_REMOVE_BEFORE_START = [
|
|||
"<COMPLETION>",
|
||||
"[CODE]",
|
||||
"<START EDITING HERE>",
|
||||
"{{FILL_HERE}}"
|
||||
];
|
||||
|
||||
export const ENGLISH_START_PHRASES = [
|
||||
|
|
|
|||
|
|
@ -83,6 +83,24 @@ export function postprocessCompletion({
|
|||
}
|
||||
}
|
||||
|
||||
if (llm.model.includes("granite")) {
|
||||
// Granite tends to repeat the start of the line in the completion output
|
||||
let prefixEnd = prefix.split("\n").pop();
|
||||
if (prefixEnd) {
|
||||
if (completion.startsWith(prefixEnd)) {
|
||||
completion = completion.slice(prefixEnd.length);
|
||||
} else {
|
||||
const trimmedPrefix = prefixEnd.trim();
|
||||
const lastWord = trimmedPrefix.split(/\s+/).pop();
|
||||
if (lastWord && completion.startsWith(lastWord)) {
|
||||
completion = completion.slice(lastWord.length);
|
||||
} else if (completion.startsWith(trimmedPrefix)) {
|
||||
completion = completion.slice(trimmedPrefix.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // If completion starts with multiple whitespaces, but the cursor is at the end of the line
|
||||
// // then it should probably be on a new line
|
||||
// if (
|
||||
|
|
@ -99,7 +117,6 @@ export function postprocessCompletion({
|
|||
prefix.endsWith(" ") &&
|
||||
completion.startsWith(" ")
|
||||
) {
|
||||
const test = prefix.split("\n").pop()?.trim() !== "";
|
||||
completion = completion.slice(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -376,7 +376,8 @@ export function getTemplateForModel(model: string): AutocompleteTemplate {
|
|||
if (
|
||||
lowerCaseModel.includes("gpt") ||
|
||||
lowerCaseModel.includes("davinci-002") ||
|
||||
lowerCaseModel.includes("claude")
|
||||
lowerCaseModel.includes("claude") ||
|
||||
lowerCaseModel.includes("granite3")
|
||||
) {
|
||||
return holeFillerTemplate;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
);
|
||||
|
||||
if (log && this.writeLog) {
|
||||
await this.writeLog(`Completion:\n\n${completion}\n\n`);
|
||||
await this.writeLog(`Completion:\n${completion}\n\n`);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -521,7 +521,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
this._logTokensGenerated(completionOptions.model, prompt, completion);
|
||||
|
||||
if (log && this.writeLog) {
|
||||
await this.writeLog(`Completion:\n\n${completion}\n\n`);
|
||||
await this.writeLog(`Completion:\n${completion}\n\n`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -562,7 +562,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
this._logTokensGenerated(completionOptions.model, prompt, completion);
|
||||
|
||||
if (log && this.writeLog) {
|
||||
await this.writeLog(`Completion:\n\n${completion}\n\n`);
|
||||
await this.writeLog(`Completion:\n${completion}\n\n`);
|
||||
}
|
||||
|
||||
return completion;
|
||||
|
|
@ -628,7 +628,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
this._logTokensGenerated(completionOptions.model, prompt, completion);
|
||||
|
||||
if (log && this.writeLog) {
|
||||
await this.writeLog(`Completion:\n\n${completion}\n\n`);
|
||||
await this.writeLog(`Completion:\n${completion}\n\n`);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue