Skip to content

Commit

Permalink
chore(agent): clean up experimental post-processing features. (#1973)
Browse files Browse the repository at this point in the history
* chore(agent): clean up experimental syntax features.

* fix: lint
  • Loading branch information
icycodes authored Apr 26, 2024
1 parent 7f3d56a commit edb23ff
Show file tree
Hide file tree
Showing 24 changed files with 55 additions and 1,136 deletions.
29 changes: 4 additions & 25 deletions clients/tabby-agent/src/AgentConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export type AgentConfig = {
};
completion: {
prompt: {
experimentalStripAutoClosingCharacters: boolean;
maxPrefixLines: number;
maxSuffixLines: number;
fillDeclarations: {
Expand Down Expand Up @@ -52,20 +51,8 @@ export type AgentConfig = {
};
};
postprocess: {
limitScope: {
// Prefer to use syntax parser than indentation
experimentalSyntax: boolean;
indentation: {
// When completion is continuing the current line, limit the scope to:
// false(default): the line scope, meaning use the next indent level as the limit.
// true: the block scope, meaning use the current indent level as the limit.
experimentalKeepBlockScopeWhenCompletingLine: boolean;
};
};
calculateReplaceRange: {
// Prefer to use syntax parser than bracket stack
experimentalSyntax: boolean;
};
limitScope: any;
calculateReplaceRange: any;
};
logs: {
level: "debug" | "error" | "silent";
Expand Down Expand Up @@ -98,7 +85,6 @@ export const defaultAgentConfig: AgentConfig = {
},
completion: {
prompt: {
experimentalStripAutoClosingCharacters: false,
maxPrefixLines: 20,
maxSuffixLines: 20,
fillDeclarations: {
Expand Down Expand Up @@ -130,15 +116,8 @@ export const defaultAgentConfig: AgentConfig = {
},
},
postprocess: {
limitScope: {
experimentalSyntax: false,
indentation: {
experimentalKeepBlockScopeWhenCompletingLine: false,
},
},
calculateReplaceRange: {
experimentalSyntax: false,
},
limitScope: {},
calculateReplaceRange: {},
},
logs: {
level: "silent",
Expand Down
7 changes: 1 addition & 6 deletions clients/tabby-agent/src/TabbyAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,7 @@ export class TabbyAgent extends EventEmitter implements Agent {
const maxSuffixLines = this.config.completion.prompt.maxSuffixLines;
const { prefixLines, suffixLines } = context;
const prefix = prefixLines.slice(Math.max(prefixLines.length - maxPrefixLines, 0)).join("");
let suffix;
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("");
}
const suffix = suffixLines.slice(0, maxSuffixLines).join("");
if (isBlank(prefix)) {
return null;
}
Expand Down
4 changes: 0 additions & 4 deletions clients/tabby-agent/src/configFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const typeCheckSchema: Record<string, string> = {
"server.requestTimeout": "number",
completion: "object",
"completion.prompt": "object",
"completion.prompt.experimentalStripAutoClosingCharacters": "boolean",
"completion.prompt.maxPrefixLines": "number",
"completion.prompt.maxSuffixLines": "number",
"completion.prompt.fillDeclarations": "object",
Expand All @@ -74,9 +73,6 @@ const typeCheckSchema: Record<string, string> = {
"completion.debounce": "object",
"completion.debounce.mode": "string",
"completion.debounce.interval": "number",
postprocess: "object",
"postprocess.limitScopeByIndentation": "object",
"postprocess.limitScopeByIndentation.experimentalKeepBlockScopeWhenCompletingLine": "boolean",
logs: "object",
"logs.level": "string",
tls: "object",
Expand Down
17 changes: 2 additions & 15 deletions clients/tabby-agent/src/postprocess/calculateReplaceRange.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import { AgentConfig } from "../AgentConfig";
import { isBrowser } from "../env";
import { PostprocessChoiceFilter, logger } from "./base";
import { PostprocessChoiceFilter } from "./base";
import { calculateReplaceRangeByBracketStack } from "./calculateReplaceRangeByBracketStack";
import { calculateReplaceRangeBySyntax } from "./calculateReplaceRangeBySyntax";

export function calculateReplaceRange(
config: AgentConfig["postprocess"]["calculateReplaceRange"],
_config: AgentConfig["postprocess"]["calculateReplaceRange"],
): PostprocessChoiceFilter {
return async (choice, context) => {
const preferSyntaxParser =
!isBrowser && // syntax parser is not supported in browser yet
config.experimentalSyntax;

if (preferSyntaxParser) {
try {
return await calculateReplaceRangeBySyntax(choice, context);
} catch (error) {
logger.debug({ error }, "Failed to calculate replace range by syntax parser");
}
}
return calculateReplaceRangeByBracketStack(choice, context);
};
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit edb23ff

Please sign in to comment.