✨ useCache customization option

This commit is contained in:
Nate Sesti 2024-02-29 20:49:49 -05:00
parent b453b639c4
commit 97b2c04f80
9 changed files with 51 additions and 19 deletions

View file

@ -50,6 +50,19 @@ export async function* stopAtSimilarLine(
}
}
const LINES_TO_STOP_AT = [
"# End of file."
]
export async function* stopAtLines(stream: LineStream): LineStream {
for await (const line of stream) {
if (LINES_TO_STOP_AT.includes(line)) {
break;
}
yield line;
}
}
function shouldRemoveLineBeforeStart(line: string): boolean {
return (
line.trimStart().startsWith("```") ||

View file

@ -11,5 +11,6 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = {
slidingWindowPrefixPercentage: 0.75,
slidingWindowSize: 500,
maxSnippetPercentage: 0.6,
recentlyEditedSimilarityThreshold: 0.3
recentlyEditedSimilarityThreshold: 0.3,
useCache: true
};

1
core/index.d.ts vendored
View file

@ -590,6 +590,7 @@ export interface TabAutocompleteOptions {
slidingWindowSize: number;
maxSnippetPercentage: number;
recentlyEditedSimilarityThreshold: number;
useCache: boolean;
}
export interface SerializedContinueConfig {

View file

@ -1212,9 +1212,9 @@
},
"required": ["name", "type", "connection"]
}
}
},
"required": ["connections"]
},
"required": ["connections"]
}
},
{
"if": {
@ -1561,6 +1561,10 @@
"multilineCompletions": {
"enum": ["always", "never", "auto"],
"description": "If set to true, Continue will only complete a single line at a time."
},
"useCache": {
"type": "boolean",
"description": "Whether to cache completions"
}
},
"required": []

View file

@ -1212,9 +1212,9 @@
},
"required": ["name", "type", "connection"]
}
}
},
"required": ["connections"]
},
"required": ["connections"]
}
},
{
"if": {
@ -1561,6 +1561,10 @@
"multilineCompletions": {
"enum": ["always", "never", "auto"],
"description": "If set to true, Continue will only complete a single line at a time."
},
"useCache": {
"type": "boolean",
"description": "Whether to cache completions"
}
},
"required": []

View file

@ -1212,9 +1212,9 @@
},
"required": ["name", "type", "connection"]
}
}
},
"required": ["connections"]
},
"required": ["connections"]
}
},
{
"if": {
@ -1561,6 +1561,10 @@
"multilineCompletions": {
"enum": ["always", "never", "auto"],
"description": "If set to true, Continue will only complete a single line at a time."
},
"useCache": {
"type": "boolean",
"description": "Whether to cache completions"
}
},
"required": []

View file

@ -1362,11 +1362,11 @@
"connection"
]
}
}
},
"required": [
"connections"
]
},
"required": [
"connections"
]
}
},
{
"if": {
@ -1756,6 +1756,10 @@
"auto"
],
"description": "If set to true, Continue will only complete a single line at a time."
},
"useCache": {
"type": "boolean",
"description": "Whether to cache completions"
}
},
"required": []

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.9.73",
"version": "0.9.74",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.9.73",
"version": "0.9.74",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",

View file

@ -7,6 +7,7 @@ import {
} from "core/autocomplete/constructPrompt";
import {
avoidPathLine,
stopAtLines,
stopAtSimilarLine,
streamWithNewLines,
} from "core/autocomplete/lineStream";
@ -112,7 +113,7 @@ export async function getTabCompletion(
let completion = "";
const cache = await autocompleteCache;
const cachedCompletion = await cache.get(prompt);
const cachedCompletion = options.useCache ? await cache.get(prompt) : undefined;
let cacheHit = false;
if (cachedCompletion) {
// Cache
@ -159,7 +160,7 @@ export async function getTabCompletion(
generatorWithCancellation(),
lang.endOfLine
);
const lineGenerator = streamWithNewLines(avoidPathLine(streamLines(gen2), lang.comment));
const lineGenerator = streamWithNewLines(avoidPathLine(stopAtLines(streamLines(gen2)), lang.comment));
const finalGenerator = stopAtSimilarLine(lineGenerator, lineBelowCursor);
for await (const update of finalGenerator) {
completion += update;