diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index 28f31d4b0..24815f501 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -1,17 +1,19 @@ import { ConfigHandler } from "../config/ConfigHandler.js"; +import { TRIAL_FIM_MODEL } from "../config/onboarding.js"; import { IDE, ILLM } from "../index.js"; +import OpenAI from "../llm/llms/OpenAI.js"; import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js"; + +import { shouldCompleteMultiline } from "./classification/shouldCompleteMultiline.js"; import { AutocompleteLanguageInfo } from "./constants/AutocompleteLanguageInfo.js"; import { constructAutocompletePrompt } from "./constructPrompt.js"; -import { AutocompleteSnippet } from "./context/ranking/index.js"; -import { postprocessCompletion } from "./postprocessing/index.js"; // @prettier-ignore -import { TRIAL_FIM_MODEL } from "../config/onboarding.js"; -import OpenAI from "../llm/llms/OpenAI.js"; -import { shouldCompleteMultiline } from "./classification/shouldCompleteMultiline.js"; + import { ContextRetrievalService } from "./context/ContextRetrievalService.js"; +import { AutocompleteSnippet } from "./context/ranking/index.js"; import { BracketMatchingService } from "./filtering/BracketMatchingService.js"; import { CompletionStreamer } from "./generation/CompletionStreamer.js"; +import { postprocessCompletion } from "./postprocessing/index.js"; import { shouldPrefilter } from "./prefiltering/index.js"; import { renderPrompt } from "./templating/index.js"; import { AutocompleteDebouncer } from "./util/AutocompleteDebouncer.js"; diff --git a/core/autocomplete/constants/AutocompleteLanguageInfo.ts b/core/autocomplete/constants/AutocompleteLanguageInfo.ts index 18bbf2ff9..ccd5a9717 100644 --- a/core/autocomplete/constants/AutocompleteLanguageInfo.ts +++ b/core/autocomplete/constants/AutocompleteLanguageInfo.ts @@ -28,7 +28,7 @@ export const Python = { name: "Python", // """"#" is for .ipynb files, where we add '"""' surrounding markdown blocks. // This stops the model from trying to complete the start of a new markdown block - topLevelKeywords: ["def", "class", '"""#'], + topLevelKeywords: ["def", "class", "\"\"\"#"], singleLineComment: "#", endOfLine: [], }; diff --git a/core/autocomplete/constructPrompt.ts b/core/autocomplete/constructPrompt.ts index 2c5d43f42..f15b1c4e1 100644 --- a/core/autocomplete/constructPrompt.ts +++ b/core/autocomplete/constructPrompt.ts @@ -1,4 +1,5 @@ import { Position, Range } from "../index.js"; + import { ContextRetrievalService } from "./context/ContextRetrievalService.js"; import { fillPromptWithSnippets, diff --git a/core/autocomplete/context/ContextRetrievalService.ts b/core/autocomplete/context/ContextRetrievalService.ts index a12d1962e..24f6e9182 100644 --- a/core/autocomplete/context/ContextRetrievalService.ts +++ b/core/autocomplete/context/ContextRetrievalService.ts @@ -1,6 +1,7 @@ import { IDE } from "../.."; import { HelperVars } from "../util/HelperVars"; import { RecentlyEditedRange } from "../util/types"; + import { ImportDefinitionsService } from "./ImportDefinitionsService"; import { AutocompleteSnippet, getSymbolsForSnippet } from "./ranking"; import { RootPathContextService } from "./root-path-context/RootPathContextService"; diff --git a/core/autocomplete/context/NearbyDefinitionsService.ts b/core/autocomplete/context/NearbyDefinitionsService.ts index 6e4cece83..8b526b261 100644 --- a/core/autocomplete/context/NearbyDefinitionsService.ts +++ b/core/autocomplete/context/NearbyDefinitionsService.ts @@ -1,5 +1,6 @@ import { IDE, Location } from "../.."; import { LANGUAGES } from "../constants/AutocompleteLanguageInfo"; + import { getSymbolsForSnippet } from "./ranking"; interface FileInfo { diff --git a/core/autocomplete/context/ranking/slidingWindow.ts b/core/autocomplete/context/ranking/slidingWindow.ts index 54ec763f2..7b650eb44 100644 --- a/core/autocomplete/context/ranking/slidingWindow.ts +++ b/core/autocomplete/context/ranking/slidingWindow.ts @@ -1,4 +1,5 @@ import { RangeInFileWithContents } from "../../../commands/util.js"; + import { AutocompleteSnippet, jaccardSimilarity } from "./index.js"; function* slidingWindow( diff --git a/core/autocomplete/context/root-path-context/RootPathContextService.test.ts b/core/autocomplete/context/root-path-context/RootPathContextService.test.ts index fad65fcfb..e72a65cab 100644 --- a/core/autocomplete/context/root-path-context/RootPathContextService.test.ts +++ b/core/autocomplete/context/root-path-context/RootPathContextService.test.ts @@ -1,9 +1,11 @@ import fs from "fs"; import path from "path"; + import { Range } from "../../.."; import { testIde } from "../../../test/util/fixtures"; import { getAst, getTreePathAtCursor } from "../../util/ast"; import { ImportDefinitionsService } from "../ImportDefinitionsService"; + import { RootPathContextService } from "./RootPathContextService"; function splitTextAtRange(fileContent: string, range: Range): [string, string] { diff --git a/core/autocomplete/context/root-path-context/RootPathContextService.ts b/core/autocomplete/context/root-path-context/RootPathContextService.ts index ba99b2e83..5584ff807 100644 --- a/core/autocomplete/context/root-path-context/RootPathContextService.ts +++ b/core/autocomplete/context/root-path-context/RootPathContextService.ts @@ -1,6 +1,8 @@ import { createHash } from "crypto"; + import { LRUCache } from "lru-cache"; import Parser from "web-tree-sitter"; + import { IDE } from "../../.."; import { getQueryForFile, TSQueryType } from "../../../util/treeSitter"; import { AstPath } from "../../util/ast"; diff --git a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts index 8d7f3e23f..5576ee26b 100644 --- a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts +++ b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts @@ -1,6 +1,7 @@ import { streamLines } from "../../../diff/util"; import { DEFAULT_AUTOCOMPLETE_OPTS } from "../../../util/parameters"; import { HelperVars } from "../../util/HelperVars"; + import { stopAtStopTokens } from "./charStream"; import { avoidEmptyComments, diff --git a/core/autocomplete/filtering/streamTransforms/lineStream.test.ts b/core/autocomplete/filtering/streamTransforms/lineStream.test.ts index 2ef41bda0..0a99a5a91 100644 --- a/core/autocomplete/filtering/streamTransforms/lineStream.test.ts +++ b/core/autocomplete/filtering/streamTransforms/lineStream.test.ts @@ -1,4 +1,5 @@ import { jest } from "@jest/globals"; + import * as lineStream from "./lineStream"; describe("lineStream", () => { diff --git a/core/autocomplete/filtering/streamTransforms/lineStream.ts b/core/autocomplete/filtering/streamTransforms/lineStream.ts index 308da41dd..8c7936e2d 100644 --- a/core/autocomplete/filtering/streamTransforms/lineStream.ts +++ b/core/autocomplete/filtering/streamTransforms/lineStream.ts @@ -1,4 +1,5 @@ import { distance } from "fastest-levenshtein"; + import { DiffLine } from "../../.."; import { LineStream } from "../../../diff/util"; diff --git a/core/autocomplete/filtering/test/filter.test.ts b/core/autocomplete/filtering/test/filter.test.ts index 62ef65512..b2e025a4b 100644 --- a/core/autocomplete/filtering/test/filter.test.ts +++ b/core/autocomplete/filtering/test/filter.test.ts @@ -1,9 +1,10 @@ +import { setUpTestDir, tearDownTestDir } from "../../../test/util/testDir"; + +import { TEST_CASES_WITH_DIFF, TEST_CASES_WITHOUT_DIFF } from "./testCases"; import { AutocompleteFileringTestInput, testAutocompleteFiltering, } from "./util"; -import { TEST_CASES_WITH_DIFF, TEST_CASES_WITHOUT_DIFF } from "./testCases"; -import { setUpTestDir, tearDownTestDir } from "../../../test/util/testDir"; const filterTestCases = (tests: AutocompleteFileringTestInput[]) => { if (tests.some((test) => test.options?.only)) { diff --git a/core/autocomplete/filtering/test/testCases.ts b/core/autocomplete/filtering/test/testCases.ts index 9715db4c6..406faf66f 100644 --- a/core/autocomplete/filtering/test/testCases.ts +++ b/core/autocomplete/filtering/test/testCases.ts @@ -1,4 +1,5 @@ import { dedent } from "../../../util"; + import { AutocompleteFileringTestInput } from "./util"; export const TEST_CASES_WITH_DIFF: AutocompleteFileringTestInput[] = [ @@ -62,7 +63,7 @@ function sayHello() { `, llmOutput: `world!"); `, - expectedCompletion: `world!");`, + expectedCompletion: "world!\");", }, { description: "Should autocomplete Java when inside a block", @@ -375,8 +376,8 @@ button { border: 2px solid #000; border-radius<|fim|> }`, - llmOutput: `: 5px;`, - expectedCompletion: `: 5px;`, + llmOutput: ": 5px;", + expectedCompletion: ": 5px;", }, { @@ -391,8 +392,8 @@ button { border-bottom-right-radius: 8px; } `, - llmOutput: `8`, - expectedCompletion: `8`, + llmOutput: "8", + expectedCompletion: "8", }, { @@ -404,8 +405,8 @@ input:focus { border: 2px solid <|fim|>; } `, - llmOutput: `#4CAF50;`, - expectedCompletion: `#4CAF50;`, + llmOutput: "#4CAF50;", + expectedCompletion: "#4CAF50;", }, { @@ -422,8 +423,8 @@ input:focus { padding: var(--padding); } `, - llmOutput: `--primary-color`, - expectedCompletion: `--primary-color`, + llmOutput: "--primary-color", + expectedCompletion: "--primary-color", }, { description: "Should complete CSS grid template columns", @@ -435,8 +436,8 @@ input:focus { grid-gap: 10px; } `, - llmOutput: `3, 1fr`, - expectedCompletion: `3, 1fr`, + llmOutput: "3, 1fr", + expectedCompletion: "3, 1fr", }, { @@ -476,8 +477,8 @@ function calculateArea($length, $width) { } echo calculateArea(5, 3);`, - llmOutput: `return $length * $width;`, - expectedCompletion: `return $length * $width;`, + llmOutput: "return $length * $width;", + expectedCompletion: "return $length * $width;", filename: "areaCalculator.php", }, @@ -488,8 +489,8 @@ echo calculateArea(5, 3);`, $colors = array("Red", "Green", <|fim|>); echo "First color is: " . $colors[0];`, - llmOutput: `"Blue"`, - expectedCompletion: `"Blue"`, + llmOutput: "\"Blue\"", + expectedCompletion: "\"Blue\"", filename: "colors.php", }, { @@ -529,8 +530,8 @@ export const Counter = () => { ); };`, - llmOutput: `0`, - expectedCompletion: `0`, + llmOutput: "0", + expectedCompletion: "0", filename: "Counter.tsx", }, @@ -557,8 +558,8 @@ export const Timer = () => { ); };`, - llmOutput: `return () => clearInterval(interval);`, - expectedCompletion: `return () => clearInterval(interval);`, + llmOutput: "return () => clearInterval(interval);", + expectedCompletion: "return () => clearInterval(interval);", filename: "Timer.tsx", }, @@ -593,8 +594,8 @@ class Form extends React.Component { ); } }`, - llmOutput: `this.setState({ name: event.target.value });`, - expectedCompletion: `this.setState({ name: event.target.value });`, + llmOutput: "this.setState({ name: event.target.value });", + expectedCompletion: "this.setState({ name: event.target.value });", filename: "Form.tsx", }, { @@ -646,8 +647,8 @@ print(even_squares) odd_squares = [<|fim|> print(odd_squares) `, - llmOutput: `x for x in squares if x % 2 != 0`, - expectedCompletion: `x for x in squares if x % 2 != 0`, + llmOutput: "x for x in squares if x % 2 != 0", + expectedCompletion: "x for x in squares if x % 2 != 0", }, { description: "Should autocomplete a simple Go function declaration", @@ -731,8 +732,8 @@ func main() { WHERE release_year > 2000 AND director = 'Christopher Nolan' GROUP BY name HAVING avg_rating > <|fim|>`, - llmOutput: `8.5)`, - expectedCompletion: `8.5)`, + llmOutput: "8.5)", + expectedCompletion: "8.5)", }, { description: @@ -774,8 +775,8 @@ func main() { FROM users u WHERE u.active = 1 <|fim|>`, - llmOutput: ` AND EXISTS (SELECT 1 FROM transactions t WHERE t.user_id = u.id AND t.amount > 100)`, - expectedCompletion: ` AND EXISTS (SELECT 1 FROM transactions t WHERE t.user_id = u.id AND t.amount > 100)`, + llmOutput: " AND EXISTS (SELECT 1 FROM transactions t WHERE t.user_id = u.id AND t.amount > 100)", + expectedCompletion: " AND EXISTS (SELECT 1 FROM transactions t WHERE t.user_id = u.id AND t.amount > 100)", }, { description: @@ -790,8 +791,8 @@ func main() { ELSE 'Unknown' END as order_status FROM orders`, - llmOutput: `WHEN status = 'cancelled' THEN 'Cancelled'`, - expectedCompletion: `WHEN status = 'cancelled' THEN 'Cancelled'`, + llmOutput: "WHEN status = 'cancelled' THEN 'Cancelled'", + expectedCompletion: "WHEN status = 'cancelled' THEN 'Cancelled'", }, { description: "Should autocomplete HTML paragraph content", @@ -803,8 +804,8 @@ func main() {
<|fim|>