From fbce8c308064bb6da7e76bbb16ebcae603825d2f Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 13 Feb 2024 09:48:45 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20small=20bug=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/autocomplete/constructPrompt.ts | 15 ++++--- core/llm/llms/OpenAI.ts | 20 +++++++++- extensions/vscode/src/activation/activate.ts | 42 +------------------- 3 files changed, 29 insertions(+), 48 deletions(-) diff --git a/core/autocomplete/constructPrompt.ts b/core/autocomplete/constructPrompt.ts index 5808c675c..29e0a38a7 100644 --- a/core/autocomplete/constructPrompt.ts +++ b/core/autocomplete/constructPrompt.ts @@ -81,11 +81,16 @@ export async function constructAutocompletePrompt( // Find external snippets const snippets: AutocompleteSnippet[] = []; - const treePath = await getTreePathAtCursor( - filepath, - fullPrefix + fullSuffix, - fullPrefix.length - ); + let treePath; + try { + treePath = await getTreePathAtCursor( + filepath, + fullPrefix + fullSuffix, + fullPrefix.length + ); + } catch (e) { + console.error("Failed to parse AST", e); + } // Get function def when inside call expression if (treePath) { diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index ab7773c87..7804b0ca5 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -21,6 +21,21 @@ const NON_CHAT_MODELS = [ "ada", ]; +const CHAT_ONLY_MODELS = [ + "gpt-3.5-turbo", + "gpt-3.5-turbo-0613", + "gpt-3.5-turbo-16k", + "gpt-4", + "gpt-35-turbo-16k", + "gpt-35-turbo-0613", + "gpt-35-turbo", + "gpt-4-32k", + "gpt-4-turbo-preview", + "gpt-4-vision", + "gpt-4-0125-preview", + "gpt-4-1106-preview", +]; + class OpenAI extends BaseLLM { public useLegacyCompletionsEndpoint = false; @@ -142,8 +157,9 @@ class OpenAI extends BaseLLM { options: CompletionOptions ): AsyncGenerator { if ( - NON_CHAT_MODELS.includes(options.model) || - this.useLegacyCompletionsEndpoint + !CHAT_ONLY_MODELS.includes(options.model) && + (NON_CHAT_MODELS.includes(options.model) || + this.useLegacyCompletionsEndpoint) ) { for await (const content of this._legacystreamComplete( stripImages(messages[messages.length - 1]?.content || ""), diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts index 7b197e6b9..488cbed00 100644 --- a/extensions/vscode/src/activation/activate.ts +++ b/extensions/vscode/src/activation/activate.ts @@ -14,7 +14,7 @@ import { setupStatusBar, } from "../lang-server/completionProvider"; import { vsCodeIndexCodebase } from "../util/indexCodebase"; -import { getExtensionVersion, getPlatform } from "../util/util"; +import { getExtensionVersion } from "../util/util"; import { getExtensionUri } from "../util/vscode"; import { setupInlineTips } from "./inlineTips"; @@ -149,46 +149,6 @@ export async function activateExtension(context: vscode.ExtensionContext) { // }); // })(); - if (getPlatform() === "mac") { - // Icon is too large and distracting on other platforms - try { - // Add icon theme for .continueignore - const iconTheme = vscode.workspace - .getConfiguration("workbench") - .get("iconTheme"); - - let found = false; - for (let i = vscode.extensions.all.length - 1; i >= 0; i--) { - if (found) { - break; - } - const extension = vscode.extensions.all[i]; - if (extension.packageJSON?.contributes?.iconThemes?.length > 0) { - for (const theme of extension.packageJSON.contributes.iconThemes) { - if (theme.id === iconTheme) { - const themePath = path.join(extension.extensionPath, theme.path); - const themeJson = JSON.parse( - fs.readFileSync(themePath).toString() - ); - themeJson.iconDefinitions["_f_continue"] = { - fontCharacter: "⚙️", - fontColor: "#fff", - }; - themeJson.fileNames[".continueignore"] = "_f_continue"; - themeJson.fileNames[".continuerc.json"] = "_f_continue"; - themeJson.fileNames["config.json"] = "_f_continue"; - fs.writeFileSync(themePath, JSON.stringify(themeJson)); - found = true; - break; - } - } - } - } - } catch (e) { - console.log("Error adding .continueignore file icon: ", e); - } - } - // Load Continue configuration if (!context.globalState.get("hasBeenInstalled")) { context.globalState.update("hasBeenInstalled", true);