Skip to content

Commit

Permalink
Merge branch 'main' into preview
Browse files Browse the repository at this point in the history
  • Loading branch information
sestinj committed May 17, 2024
2 parents 9f160ad + b2c7b07 commit 4e33901
Show file tree
Hide file tree
Showing 16 changed files with 14,587 additions and 390 deletions.
8 changes: 5 additions & 3 deletions core/autocomplete/charStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export async function* noFirstCharNewline(stream: AsyncGenerator<string>) {
for await (let char of stream) {
if (first) {
first = false;
if (char === "\n") {return;}
if (char === "\n") {
return;
}
}
yield char;
}
Expand All @@ -48,9 +50,9 @@ export async function* stopOnUnmatchedClosingBracket(
): AsyncGenerator<string> {
const stack: string[] = [];
for (let i = 0; i < suffix.length; i++) {
if (suffix[i] === " ") {continue;}
if (suffix[i] === " ") continue;
const openBracket = BRACKETS_REVERSE[suffix[i]];
if (!openBracket) {break;}
if (!openBracket) break;
stack.unshift(openBracket);
}

Expand Down
14 changes: 11 additions & 3 deletions core/autocomplete/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import Handlebars from "handlebars";
import ignore from "ignore";
import path from "path";
import { v4 as uuidv4 } from "uuid";
import { IDE, ILLM, Position, Range, TabAutocompleteOptions } from "../index.js";
import { RangeInFileWithContents } from "../commands/util.js";
import { ConfigHandler } from "../config/handler.js";
import { streamLines } from "../diff/util.js";
import {
IDE,
ILLM,
Position,
Range,
TabAutocompleteOptions,
} from "../index.js";
import OpenAI from "../llm/llms/OpenAI.js";
import { getBasename } from "../util/index.js";
import { logDevData } from "../util/devdata.js";
import { getBasename } from "../util/index.js";
import {
COUNT_COMPLETION_REJECTED_AFTER,
DEFAULT_AUTOCOMPLETE_OPTS,
Expand Down Expand Up @@ -157,7 +163,9 @@ export async function getTabCompletion(
}

// Model
if (!llm) {return;}
if (!llm) {
return;
}
if (llm instanceof OpenAI) {
llm.useLegacyCompletionsEndpoint = true;
} else if (
Expand Down
8 changes: 6 additions & 2 deletions core/autocomplete/constructPrompt.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import Parser from "web-tree-sitter";
import { TabAutocompleteOptions } from "../index.js";
import { RangeInFileWithContents } from "../commands/util.js";
import { TabAutocompleteOptions } from "../index.js";

import {
countTokens,
pruneLinesFromBottom,
pruneLinesFromTop,
} from "../llm/countTokens.js";
import { getAst, getTreePathAtCursor } from "./ast.js";
import { AutocompleteLanguageInfo, LANGUAGES, Typescript } from "./languages.js";
import {
AutocompleteLanguageInfo,
LANGUAGES,
Typescript,
} from "./languages.js";
import {
AutocompleteSnippet,
fillPromptWithSnippets,
Expand Down
2 changes: 1 addition & 1 deletion core/commands/slash/edit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ContextItemWithId, ILLM, SlashCommand } from "../../index.js";
import {
filterCodeBlockLines,
filterEnglishLinesAtEnd,
Expand All @@ -8,6 +7,7 @@ import {
streamWithNewLines,
} from "../../autocomplete/lineStream.js";
import { streamLines } from "../../diff/util.js";
import { ContextItemWithId, ILLM, SlashCommand } from "../../index.js";
import { stripImages } from "../../llm/countTokens.js";
import {
dedentAndGetCommonWhitespace,
Expand Down
2 changes: 1 addition & 1 deletion core/context/providers/CurrentFileContextProvider.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BaseContextProvider } from "../index.js";
import {
ContextItem,
ContextProviderDescription,
ContextProviderExtras,
} from "../../index.js";
import { getBasename } from "../../util/index.js";
import { BaseContextProvider } from "../index.js";

class CurrentFileContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
Expand Down
2 changes: 1 addition & 1 deletion core/context/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseContextProvider } from "../index.js";
import { ContextProviderName } from "../../index.js";
import { BaseContextProvider } from "../index.js";
import CodeContextProvider from "./CodeContextProvider.js";
import CodebaseContextProvider from "./CodebaseContextProvider.js";
import CurrentFileContextProvider from "./CurrentFileContextProvider.js";
Expand Down

0 comments on commit 4e33901

Please sign in to comment.