feat: support accepts and reject logging
This commit is contained in:
parent
7b23b10950
commit
75a6ff2ccc
2 changed files with 27 additions and 17 deletions
|
|
@ -541,6 +541,12 @@ export class Core {
|
|||
);
|
||||
return outcome ? [outcome.completion, outcome.originalEditableRange] : [];
|
||||
});
|
||||
on("nextEdit/accept", async (msg) => {
|
||||
this.nextEditProvider.accept(msg.data.completionId);
|
||||
});
|
||||
on("nextEdit/reject", async (msg) => {
|
||||
this.nextEditProvider.reject(msg.data.completionId);
|
||||
});
|
||||
|
||||
on("streamDiffLines", async (msg) => {
|
||||
const { config } = await this.configHandler.loadConfig();
|
||||
|
|
|
|||
|
|
@ -158,19 +158,19 @@ export class NextEditProvider {
|
|||
this.loggingService.cancel();
|
||||
}
|
||||
|
||||
// public accept(completionId: string) {
|
||||
// const outcome = this.loggingService.accept(completionId);
|
||||
// if (!outcome) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
public accept(completionId: string) {
|
||||
const outcome = this.loggingService.accept(completionId);
|
||||
if (!outcome) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// public reject(completionId: string) {
|
||||
// const outcome = this.loggingService.reject(completionId);
|
||||
// if (!outcome) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
public reject(completionId: string) {
|
||||
const outcome = this.loggingService.reject(completionId);
|
||||
if (!outcome) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public markDisplayed(completionId: string, outcome: NextEditOutcome) {
|
||||
this.loggingService.markDisplayed(completionId, outcome);
|
||||
|
|
@ -237,7 +237,6 @@ export class NextEditProvider {
|
|||
|
||||
// TODO: Toggle between the default endpoint and the finetuned endpoint.
|
||||
const prompts: Prompt[] = [];
|
||||
|
||||
if (this.endpointType === "default") {
|
||||
prompts.push(renderDefaultSystemPrompt());
|
||||
prompts.push(renderDefaultUserPrompt(snippetPayload, helper));
|
||||
|
|
@ -278,11 +277,16 @@ export class NextEditProvider {
|
|||
}
|
||||
} else {
|
||||
const msg: ChatMessage = await llm.chat(prompts, token);
|
||||
|
||||
if (typeof msg.content === "string") {
|
||||
// TODO: There are cases where msg.conetnt.split("<|start|>")[1] is undefined
|
||||
const nextCompletion = replaceEscapedCharacters(
|
||||
msg.content.split("<|editable_region_start|>\n")[1],
|
||||
).replace(/\n$/, "");
|
||||
// NOTE: There are cases where msg.conetnt.split("<|start|>")[1] is undefined
|
||||
const nextCompletion = msg.content.split(
|
||||
"<|editable_region_start|>\n",
|
||||
)[1]
|
||||
? replaceEscapedCharacters(
|
||||
msg.content.split("<|editable_region_start|>\n")[1],
|
||||
).replace(/\n$/, "")
|
||||
: "";
|
||||
|
||||
const currCursorPos = helper.pos;
|
||||
const editableRegionStartLine = Math.max(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue