feat(agent): add experimental option: strip auto-closing chars in prompt suffix. (#651)
* feat(agent): add experimental option: strip auto-closing chars in prompt suffix. * fix: rename settings adding experimental prefix.release-notes-05
parent
b47bdd5d77
commit
238d81ad4f
|
|
@ -8,6 +8,7 @@ export type AgentConfig = {
|
||||||
};
|
};
|
||||||
completion: {
|
completion: {
|
||||||
prompt: {
|
prompt: {
|
||||||
|
experimentalStripAutoClosingCharacters: boolean;
|
||||||
maxPrefixLines: number;
|
maxPrefixLines: number;
|
||||||
maxSuffixLines: number;
|
maxSuffixLines: number;
|
||||||
};
|
};
|
||||||
|
|
@ -46,6 +47,7 @@ export const defaultAgentConfig: AgentConfig = {
|
||||||
},
|
},
|
||||||
completion: {
|
completion: {
|
||||||
prompt: {
|
prompt: {
|
||||||
|
experimentalStripAutoClosingCharacters: false,
|
||||||
maxPrefixLines: 20,
|
maxPrefixLines: 20,
|
||||||
maxSuffixLines: 20,
|
maxSuffixLines: 20,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -264,10 +264,14 @@ export class TabbyAgent extends EventEmitter implements Agent {
|
||||||
const maxPrefixLines = this.config.completion.prompt.maxPrefixLines;
|
const maxPrefixLines = this.config.completion.prompt.maxPrefixLines;
|
||||||
const maxSuffixLines = this.config.completion.prompt.maxSuffixLines;
|
const maxSuffixLines = this.config.completion.prompt.maxSuffixLines;
|
||||||
const { prefixLines, suffixLines } = context;
|
const { prefixLines, suffixLines } = context;
|
||||||
return {
|
const prefix = prefixLines.slice(Math.max(prefixLines.length - maxPrefixLines, 0)).join("");
|
||||||
prefix: prefixLines.slice(Math.max(prefixLines.length - maxPrefixLines, 0)).join(""),
|
let suffix;
|
||||||
suffix: suffixLines.slice(0, maxSuffixLines).join(""),
|
if (this.config.completion.prompt.experimentalStripAutoClosingCharacters && context.mode !== "fill-in-line") {
|
||||||
};
|
suffix = "\n" + suffixLines.slice(1, maxSuffixLines).join("");
|
||||||
|
} else {
|
||||||
|
suffix = suffixLines.slice(0, maxSuffixLines).join("");
|
||||||
|
}
|
||||||
|
return { prefix, suffix };
|
||||||
}
|
}
|
||||||
|
|
||||||
private calculateReplaceRange(response: CompletionResponse, context: CompletionContext): CompletionResponse {
|
private calculateReplaceRange(response: CompletionResponse, context: CompletionContext): CompletionResponse {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue