diff --git a/.changes/extensions/vscode/0.8.15.md b/.changes/extensions/vscode/0.8.15.md new file mode 100644 index 000000000..0bee662f3 --- /dev/null +++ b/.changes/extensions/vscode/0.8.15.md @@ -0,0 +1,3 @@ +## 0.8.15 - 2024-03-05 +### Added +* Tab-autocomplete in beta diff --git a/.changes/unreleased/Added-20240303-190039.yaml b/.changes/unreleased/Added-20240303-190039.yaml deleted file mode 100644 index 1c9937e1e..000000000 --- a/.changes/unreleased/Added-20240303-190039.yaml +++ /dev/null @@ -1,4 +0,0 @@ -project: extensions/vscode -kind: Added -body: Tab-autocomplete in beta -time: 2024-03-03T19:00:39.909292-05:00 diff --git a/core/autocomplete/charStream.ts b/core/autocomplete/charStream.ts index eb912cb57..58f88bb88 100644 --- a/core/autocomplete/charStream.ts +++ b/core/autocomplete/charStream.ts @@ -24,3 +24,14 @@ export async function* onlyWhitespaceAfterEndOfLine( } yield pending; } + +export async function* noFirstCharNewline(stream: AsyncGenerator) { + let first = true; + for await (let char of stream) { + if (first) { + first = false; + if (char === "\n") return; + } + yield char; + } +} diff --git a/core/autocomplete/constructPrompt.ts b/core/autocomplete/constructPrompt.ts index 85bd3c54a..3e3f00b01 100644 --- a/core/autocomplete/constructPrompt.ts +++ b/core/autocomplete/constructPrompt.ts @@ -1,13 +1,12 @@ import Parser from "web-tree-sitter"; import { TabAutocompleteOptions } from ".."; import { RangeInFileWithContents } from "../commands/util"; + import { countTokens, pruneLinesFromBottom, pruneLinesFromTop, } from "../llm/countTokens"; -import { getBasename } from "../util"; - import { getAst, getTreePathAtCursor } from "./ast"; import { AutocompleteLanguageInfo, LANGUAGES, Typescript } from "./languages"; import { @@ -24,23 +23,6 @@ export function languageForFilepath( return LANGUAGES[filepath.split(".").slice(-1)[0]] || Typescript; } -function formatExternalSnippet( - filepath: string, - snippet: string, - language: AutocompleteLanguageInfo, -) { - const comment = language.comment; - const lines = [ - comment + " Path: " + getBasename(filepath), - ...snippet - .trim() - .split("\n") - .map((line) => comment + " " + line), - comment, - ]; - return lines.join("\n"); -} - const BLOCK_TYPES = ["body", "statement_block"]; function shouldCompleteMultilineAst( @@ -113,43 +95,8 @@ export async function constructAutocompletePrompt( suffix: string; useFim: boolean; completeMultiline: boolean; + snippets: AutocompleteSnippet[]; }> { - // Find external snippets - let snippets: RangeInFileWithContents[] = extraSnippets; - - const windowAroundCursor = - fullPrefix.slice( - -options.slidingWindowSize * options.slidingWindowPrefixPercentage, - ) + - fullSuffix.slice( - options.slidingWindowSize * (1 - options.slidingWindowPrefixPercentage), - ); - - const slidingWindowMatches = await slidingWindowMatcher( - recentlyEditedDocuments, - windowAroundCursor, - 3, - options.slidingWindowSize, - ); - snippets.push(...slidingWindowMatches); - - const recentlyEdited = ( - await Promise.all( - recentlyEditedRanges.map(async (r) => { - return r; - // return await getScopeAroundRange(r); - }), - ) - ).filter((s) => !!s); - snippets.push(...(recentlyEdited as any)); - - // Rank / order the snippets - const scoredSnippets = rankSnippets(snippets, windowAroundCursor); - - // Fill maxSnippetTokens with snippets - const maxSnippetTokens = - options.maxPromptTokens * options.maxSnippetPercentage; - // Construct basic prefix const maxPrefixTokens = options.maxPromptTokens * options.prefixPercentage; let prefix = pruneLinesFromTop(fullPrefix, maxPrefixTokens, modelName); @@ -161,44 +108,82 @@ export async function constructAutocompletePrompt( ); let suffix = pruneLinesFromBottom(fullSuffix, maxSuffixTokens, modelName); - // Remove prefix range from snippets - const prefixLines = prefix.split("\n").length; - const suffixLines = suffix.split("\n").length; - const buffer = 8; - const prefixSuffixRangeWithBuffer = { - start: { - line: cursorLine - prefixLines - buffer, - character: 0, - }, - end: { - line: cursorLine + suffixLines + buffer, - character: 0, - }, - }; - let finalSnippets = removeRangeFromSnippets( - scoredSnippets, - filepath.split("://").slice(-1)[0], - prefixSuffixRangeWithBuffer, - ); + // Find external snippets + let snippets: AutocompleteSnippet[] = []; - // Filter snippets for those with best scores (must be above threshold) - finalSnippets = finalSnippets.filter( - (snippet) => snippet.score >= options.recentlyEditedSimilarityThreshold, - ); - finalSnippets = fillPromptWithSnippets( - scoredSnippets, - maxSnippetTokens, - modelName, - ); + if (options.useOtherFiles) { + snippets.push(...extraSnippets); - // Format snippets as comments and prepend to prefix - const formattedSnippets = finalSnippets - .map((snippet) => - formatExternalSnippet(snippet.filepath, snippet.contents, language), - ) - .join("\n"); - if (formattedSnippets.length > 0) { - prefix = formattedSnippets + "\n\n" + prefix; + const windowAroundCursor = + fullPrefix.slice( + -options.slidingWindowSize * options.slidingWindowPrefixPercentage, + ) + + fullSuffix.slice( + options.slidingWindowSize * (1 - options.slidingWindowPrefixPercentage), + ); + + const slidingWindowMatches = await slidingWindowMatcher( + recentlyEditedDocuments, + windowAroundCursor, + 3, + options.slidingWindowSize, + ); + snippets.push(...slidingWindowMatches); + + const recentlyEdited = ( + await Promise.all( + recentlyEditedRanges.map(async (r) => { + return r; + // return await getScopeAroundRange(r); + }), + ) + ).filter((s) => !!s); + snippets.push(...(recentlyEdited as any)); + // Filter out empty snippets + snippets = snippets.filter( + (s) => + s.contents.trim() !== "" && + !(prefix + suffix).includes(s.contents.trim()), + ); + + // Rank / order the snippets + const scoredSnippets = rankSnippets(snippets, windowAroundCursor); + + // Fill maxSnippetTokens with snippets + const maxSnippetTokens = + options.maxPromptTokens * options.maxSnippetPercentage; + + // Remove prefix range from snippets + const prefixLines = prefix.split("\n").length; + const suffixLines = suffix.split("\n").length; + const buffer = 8; + const prefixSuffixRangeWithBuffer = { + start: { + line: cursorLine - prefixLines - buffer, + character: 0, + }, + end: { + line: cursorLine + suffixLines + buffer, + character: 0, + }, + }; + let finalSnippets = removeRangeFromSnippets( + scoredSnippets, + filepath.split("://").slice(-1)[0], + prefixSuffixRangeWithBuffer, + ); + + // Filter snippets for those with best scores (must be above threshold) + finalSnippets = finalSnippets.filter( + (snippet) => snippet.score >= options.recentlyEditedSimilarityThreshold, + ); + finalSnippets = fillPromptWithSnippets( + scoredSnippets, + maxSnippetTokens, + modelName, + ); + + snippets = finalSnippets; } return { @@ -210,5 +195,6 @@ export async function constructAutocompletePrompt( fullPrefix, fullSuffix, ), + snippets, }; } diff --git a/core/autocomplete/lineStream.ts b/core/autocomplete/lineStream.ts index c7ecc2f7c..98f39b326 100644 --- a/core/autocomplete/lineStream.ts +++ b/core/autocomplete/lineStream.ts @@ -9,7 +9,8 @@ export async function* avoidPathLine( // Snippets are inserted as comments with a line at the start '// Path: '. // Sometimes the model with copy this pattern, which is unwanted for await (const line of stream) { - if (line.startsWith(comment + " Path: ")) { + // Also filter lines that are empty comments + if (line.startsWith(comment + " Path: ") || line.trim() === comment) { continue; } yield line; diff --git a/core/autocomplete/parameters.ts b/core/autocomplete/parameters.ts index fdc72932e..2bde04cf5 100644 --- a/core/autocomplete/parameters.ts +++ b/core/autocomplete/parameters.ts @@ -14,4 +14,5 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = { recentlyEditedSimilarityThreshold: 0.3, useCache: true, onlyMyCode: true, + useOtherFiles: true, }; diff --git a/core/autocomplete/templates.ts b/core/autocomplete/templates.ts index 4f8c8771c..51d28c5dc 100644 --- a/core/autocomplete/templates.ts +++ b/core/autocomplete/templates.ts @@ -1,9 +1,18 @@ // Fill in the middle prompts import { CompletionOptions } from ".."; +import { AutocompleteSnippet } from "./ranking"; interface AutocompleteTemplate { - template: string | ((prefix: string, suffix: string) => string); + template: + | string + | (( + prefix: string, + suffix: string, + filename: string, + reponame: string, + snippets: AutocompleteSnippet[], + ) => string); completionOptions?: Partial; } @@ -15,6 +24,41 @@ const stableCodeFimTemplate: AutocompleteTemplate = { }, }; +// https://arxiv.org/pdf/2402.19173.pdf section 5.1 +const starcoder2FimTemplate: AutocompleteTemplate = { + template: ( + prefix: string, + suffix: string, + filename: string, + reponame: string, + snippets: AutocompleteSnippet[], + ): string => { + const otherFiles = + snippets.length === 0 + ? "" + : "" + + snippets + .map((snippet) => { + return snippet.contents; + // return `${getBasename(snippet.filepath)}\n${snippet.contents}`; + }) + .join("") + + ""; + + let prompt = `${otherFiles}${prefix}${suffix}`; + return prompt; + }, + completionOptions: { + stop: [ + "", + "", + "", + "<|endoftext|>", + "", + ], + }, +}; + const codeLlamaFimTemplate: AutocompleteTemplate = { template: "
 {{{prefix}}} {{{suffix}}} ",
   completionOptions: { stop: ["
", "", "", ""] },
@@ -46,6 +90,11 @@ The last line is incomplete, and you should provide the rest of that line. If th
 
 export function getTemplateForModel(model: string): AutocompleteTemplate {
   const lowerCaseModel = model.toLowerCase();
+
+  if (lowerCaseModel.includes("starcoder2")) {
+    return starcoder2FimTemplate;
+  }
+
   if (
     lowerCaseModel.includes("starcoder") ||
     lowerCaseModel.includes("star-coder") ||
diff --git a/core/index.d.ts b/core/index.d.ts
index ba0a9e4f6..7c8f76098 100644
--- a/core/index.d.ts
+++ b/core/index.d.ts
@@ -596,6 +596,7 @@ export interface TabAutocompleteOptions {
   recentlyEditedSimilarityThreshold: number;
   useCache: boolean;
   onlyMyCode: boolean;
+  useOtherFiles: boolean;
 }
 
 export interface SerializedContinueConfig {
diff --git a/core/llm/llms/Anthropic.ts b/core/llm/llms/Anthropic.ts
index c5d6b0ee3..cbf675a45 100644
--- a/core/llm/llms/Anthropic.ts
+++ b/core/llm/llms/Anthropic.ts
@@ -50,7 +50,7 @@ class Anthropic extends BaseLLM {
       },
       body: JSON.stringify({
         ...this._convertArgs(options),
-        messages,
+        messages: messages.filter((m) => m.role !== "system"),
         system: this.systemMessage,
         stream: true,
       }),
diff --git a/core/llm/llms/FreeTrial.ts b/core/llm/llms/FreeTrial.ts
index 463f41cc0..709fe2f2f 100644
--- a/core/llm/llms/FreeTrial.ts
+++ b/core/llm/llms/FreeTrial.ts
@@ -3,7 +3,7 @@ import { ChatMessage, CompletionOptions, ModelProvider } from "../..";
 import { streamResponse } from "../stream";
 
 // const SERVER_URL = "http://localhost:3000";
-const SERVER_URL = "https://node-proxy-server-green-l6vsfbzhba-uw.a.run.app";
+const SERVER_URL = "https://node-proxy-server-blue-l6vsfbzhba-uw.a.run.app";
 
 class FreeTrial extends BaseLLM {
   static providerName: ModelProvider = "free-trial";
@@ -21,7 +21,7 @@ class FreeTrial extends BaseLLM {
       frequency_penalty: options.frequencyPenalty,
       presence_penalty: options.presencePenalty,
       max_tokens: options.maxTokens,
-      stop: options.stop?.slice(0, 4),
+      stop: options.stop?.slice(0, 2),
       temperature: options.temperature,
       top_p: options.topP,
     };
diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts
index 56271632a..86961ea85 100644
--- a/core/llm/llms/OpenAI.ts
+++ b/core/llm/llms/OpenAI.ts
@@ -148,7 +148,7 @@ class OpenAI extends BaseLLM {
     });
 
     for await (const value of streamSse(response)) {
-      if (value.choices?.[0]?.text) {
+      if (value.choices?.[0]?.text && value.finish_reason !== "eos") {
         yield value.choices[0].text;
       }
     }
diff --git a/docs/docs/customization/context-providers.md b/docs/docs/customization/context-providers.md
index dc673c890..4c4c66b7e 100644
--- a/docs/docs/customization/context-providers.md
+++ b/docs/docs/customization/context-providers.md
@@ -36,6 +36,8 @@ Type '@terminal' to reference the contents of your IDE's terminal.
 
 Type `@docs` to index and retrieve snippets from any documentation site. You can add any site by selecting "Add Docs" in the dropdown, then entering the root URL of the documentation site and a title to remember it by. After the site has been indexed, you can type `@docs`, select your documentation from the dropdown, and Continue will use similarity search to automatically find important sections when answering your question.
 
+> The crawler currently works only on static sites that don't require Javascript to load. An example of a page that won't be correctly indexed is [the OpenAI documentation](https://platform.openai.com/docs/overview)
+
 ```json
 { "name": "docs" }
 ```
diff --git a/docs/docs/customization/overview.md b/docs/docs/customization/overview.md
index 7e33a5cb4..8581225b8 100644
--- a/docs/docs/customization/overview.md
+++ b/docs/docs/customization/overview.md
@@ -14,3 +14,5 @@ Currently, you can customize the following:
 - [Context Providers](./context-providers.md) - Type '@' to easily add attachments to your prompt. Define which sources you want to reference, including GitHub Issues, terminal output, or automatically retrieved snippets from your codebase.
 - [Slash Commands](./slash-commands.md) - Call custom prompts or programs written with our SDK by typing `/`.
 - [Other Configuration](../reference/config.mdx) - Configure other settings like the system message and temperature.
+
+If you'd like to share Continue configuration with others, you can add a `.continuerc.json` to the root of your project. It has the same JSON Schema definition as `config.json`, and will automatically be applied on top of the local `config.json`.
diff --git a/docs/docs/intro.md b/docs/docs/intro.md
index 9cbca1e72..3a6a627c5 100644
--- a/docs/docs/intro.md
+++ b/docs/docs/intro.md
@@ -14,7 +14,8 @@ Many developers have begun to use ChatGPT while coding; however, the experience
 
 Some examples of what you can achieve are:
 
-- Use cmd/ctrl + shift + L to generate boilerplate code from natural language
+- Use cmd/ctrl + I to generate boilerplate code from natural language
+- Use our local tab-autocomplete to get inline suggestions and write boilerplate code quickly
 - Highlight code, describe how to refactor it, and have changes streamed into your editor
 - Ask high-level questions about your codebase, with Continue automatically finding relevant files
 - Quickly generate unit tests for any function or class
diff --git a/docs/docs/model-setup/select-provider.md b/docs/docs/model-setup/select-provider.md
index 1f0cc1e08..46002cf0d 100644
--- a/docs/docs/model-setup/select-provider.md
+++ b/docs/docs/model-setup/select-provider.md
@@ -17,6 +17,7 @@ You can run a model on your local computer using:
 - [Ollama](../reference/Model%20Providers/ollama.md)
 - [LM Studio](../reference/Model%20Providers/lmstudio.md)
 - [Llama.cpp](../reference/Model%20Providers/llamacpp.md)
+- [llamafile](../reference/Model%20Providers/llamafile) ((OpenAI compatible server)
 - [LocalAI](../reference/Model%20Providers/openai.md) (OpenAI compatible server)
 - [Text generation web UI](../reference/Model%20Providers/openai.md) (OpenAI compatible server)
 - [FastChat](../reference/Model%20Providers/openai.md) (OpenAI compatible server)
diff --git a/docs/docs/reference/config.mdx b/docs/docs/reference/config.mdx
index 608072369..53f02b2be 100644
--- a/docs/docs/reference/config.mdx
+++ b/docs/docs/reference/config.mdx
@@ -8,8 +8,7 @@ The following shows the JSON Schema definition for `config.json`. You can also d
 
 
diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md
index a733ec327..bc3196aaa 100644
--- a/docs/docs/troubleshooting.md
+++ b/docs/docs/troubleshooting.md
@@ -39,6 +39,14 @@ If you're seeing a `fetch failed` error and your network requires custom certifi
 
 You may also set `requestOptions.caBundlePath` to an array of paths to multiple certificates.
 
+## Upgrade VS Code Version
+
+Continue is built against Node.js version 19.0.0 and may not be compatible with older versions of Node. If the extension completely fails to load (e.g. pressing ctrl/cmd+L causes a warning that the command does not exist, and the sidebar does not load), you may want to try upgrading VS Code to the latest version.
+
+## Android Studio - JCEF Not Supported
+
+Certain versions of Android Studio, unlike other JetBrains IDEs, do not by default support the Java Chromium Embedded Framework, which is required for Continue's web-based sidebar. If you see an error saying that JCEF failed to initialize, you may be able to solve the problem by [changing your boot runtime](https://github.com/continuedev/continue/issues/596#issuecomment-1789327178).
+
 ## Download a Newer Version
 
 If you are using an older version of the Continue extension, particularly one which depends on the separate Python server, we would recommend downloading the latest version of the extension, as we are constantly making bug fixes and are likely to have solved any major issues.
diff --git a/docs/docs/walkthroughs/codellama.md b/docs/docs/walkthroughs/codellama.md
index 961788cc6..b5d245abb 100644
--- a/docs/docs/walkthroughs/codellama.md
+++ b/docs/docs/walkthroughs/codellama.md
@@ -41,7 +41,7 @@ If you haven't already installed Continue, you can do that [here](https://market
     {
       "title": "Code Llama",
       "provider": "ollama",
-      "model": "codellama-7b"
+      "model": "codellama:7b"
     }
   ]
 }
diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json
index 6bdcb3e82..3cd02ca58 100644
--- a/docs/static/schemas/config.json
+++ b/docs/static/schemas/config.json
@@ -141,7 +141,7 @@
             "### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI using our API key. If you are ready to use your own API key or have used all 250 free uses, you can enter your API key in config.py where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/freetrial)",
             "### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/anthropicllm)",
             "### Together\nTogether is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/togetherllm)",
-            "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama pull `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/ollama)",
+            "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/ollama)",
             "### Huggingface TGI\n\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/huggingfacetgi)",
             "### Huggingface Inference API\n\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/huggingfaceinferenceapi)",
             "### Llama.cpp\nllama.cpp comes with a [built-in server](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#llamacppexampleserver) that can be run from source. To do this:\n\n1. Clone the repository with `git clone https://github.com/ggerganov/llama.cpp`.\n2. `cd llama.cpp`\n3. Run `make` to build the server.\n4. Download the model you'd like to use and place it in the `llama.cpp/models` directory (the best place to find models is [The Bloke on HuggingFace](https://huggingface.co/TheBloke))\n5. Run the llama.cpp server with the command below (replacing with the model you downloaded):\n\n```shell\n.\\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models/codellama-7b-instruct.Q8_0.gguf\n```\n\nAfter it's up and running, you can start using Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/llamacpp)",
@@ -1579,6 +1579,10 @@
             "onlyMyCode": {
               "type": "boolean",
               "description": "If set to true, Continue will not include any snippets from go to definition unless they are within your repository"
+            },
+            "useOtherFiles": {
+              "type": "boolean",
+              "description": "Defaults to true. If set to false, Continue will not attempt to include snippets from other files."
             }
           },
           "required": []
diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json
index 6bdcb3e82..3cd02ca58 100644
--- a/extensions/intellij/src/main/resources/config_schema.json
+++ b/extensions/intellij/src/main/resources/config_schema.json
@@ -141,7 +141,7 @@
             "### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI using our API key. If you are ready to use your own API key or have used all 250 free uses, you can enter your API key in config.py where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/freetrial)",
             "### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/anthropicllm)",
             "### Together\nTogether is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/togetherllm)",
-            "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama pull `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/ollama)",
+            "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/ollama)",
             "### Huggingface TGI\n\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/huggingfacetgi)",
             "### Huggingface Inference API\n\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/huggingfaceinferenceapi)",
             "### Llama.cpp\nllama.cpp comes with a [built-in server](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#llamacppexampleserver) that can be run from source. To do this:\n\n1. Clone the repository with `git clone https://github.com/ggerganov/llama.cpp`.\n2. `cd llama.cpp`\n3. Run `make` to build the server.\n4. Download the model you'd like to use and place it in the `llama.cpp/models` directory (the best place to find models is [The Bloke on HuggingFace](https://huggingface.co/TheBloke))\n5. Run the llama.cpp server with the command below (replacing with the model you downloaded):\n\n```shell\n.\\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models/codellama-7b-instruct.Q8_0.gguf\n```\n\nAfter it's up and running, you can start using Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/llamacpp)",
@@ -1579,6 +1579,10 @@
             "onlyMyCode": {
               "type": "boolean",
               "description": "If set to true, Continue will not include any snippets from go to definition unless they are within your repository"
+            },
+            "useOtherFiles": {
+              "type": "boolean",
+              "description": "Defaults to true. If set to false, Continue will not attempt to include snippets from other files."
             }
           },
           "required": []
diff --git a/extensions/vscode/.continuerc.json b/extensions/vscode/.continuerc.json
index 12a1699e5..7fbb047a6 100644
--- a/extensions/vscode/.continuerc.json
+++ b/extensions/vscode/.continuerc.json
@@ -1,9 +1,9 @@
 {
-    "customCommands": [
-        {
-            "name": "hello",
-            "prompt": "Write a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
-            "description": "This is an example custom command. Use /config to edit it and create more"
-        }
-    ]
-}
\ No newline at end of file
+  "customCommands": [
+    {
+      "name": "hello",
+      "prompt": "Write a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
+      "description": "This is an example custom command. Use /config to edit it and create more"
+    }
+  ]
+}
diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json
index 1ead9e9af..ee14a7ed2 100644
--- a/extensions/vscode/config_schema.json
+++ b/extensions/vscode/config_schema.json
@@ -146,7 +146,7 @@
             "### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI using our API key. If you are ready to use your own API key or have used all 250 free uses, you can enter your API key in config.py where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/freetrial)",
             "### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/anthropicllm)",
             "### Together\nTogether is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/togetherllm)",
-            "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama pull `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/ollama)",
+            "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/ollama)",
             "### Huggingface TGI\n\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/huggingfacetgi)",
             "### Huggingface Inference API\n\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/huggingfaceinferenceapi)",
             "### Llama.cpp\nllama.cpp comes with a [built-in server](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#llamacppexampleserver) that can be run from source. To do this:\n\n1. Clone the repository with `git clone https://github.com/ggerganov/llama.cpp`.\n2. `cd llama.cpp`\n3. Run `make` to build the server.\n4. Download the model you'd like to use and place it in the `llama.cpp/models` directory (the best place to find models is [The Bloke on HuggingFace](https://huggingface.co/TheBloke))\n5. Run the llama.cpp server with the command below (replacing with the model you downloaded):\n\n```shell\n.\\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models/codellama-7b-instruct.Q8_0.gguf\n```\n\nAfter it's up and running, you can start using Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/llamacpp)",
@@ -1584,6 +1584,10 @@
             "onlyMyCode": {
               "type": "boolean",
               "description": "If set to true, Continue will not include any snippets from go to definition unless they are within your repository"
+            },
+            "useOtherFiles": {
+              "type": "boolean",
+              "description": "Defaults to true. If set to false, Continue will not attempt to include snippets from other files."
             }
           },
           "required": []
diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json
index 2687899f9..e047c46ee 100644
--- a/extensions/vscode/continue_rc_schema.json
+++ b/extensions/vscode/continue_rc_schema.json
@@ -141,7 +141,7 @@
             "### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI using our API key. If you are ready to use your own API key or have used all 250 free uses, you can enter your API key in config.py where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/freetrial)",
             "### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/anthropicllm)",
             "### Together\nTogether is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/togetherllm)",
-            "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama pull `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/ollama)",
+            "### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/ollama)",
             "### Huggingface TGI\n\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/huggingfacetgi)",
             "### Huggingface Inference API\n\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/huggingfaceinferenceapi)",
             "### Llama.cpp\nllama.cpp comes with a [built-in server](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#llamacppexampleserver) that can be run from source. To do this:\n\n1. Clone the repository with `git clone https://github.com/ggerganov/llama.cpp`.\n2. `cd llama.cpp`\n3. Run `make` to build the server.\n4. Download the model you'd like to use and place it in the `llama.cpp/models` directory (the best place to find models is [The Bloke on HuggingFace](https://huggingface.co/TheBloke))\n5. Run the llama.cpp server with the command below (replacing with the model you downloaded):\n\n```shell\n.\\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models/codellama-7b-instruct.Q8_0.gguf\n```\n\nAfter it's up and running, you can start using Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/llamacpp)",
@@ -1771,6 +1771,10 @@
             "onlyMyCode": {
               "type": "boolean",
               "description": "If set to true, Continue will not include any snippets from go to definition unless they are within your repository"
+            },
+            "useOtherFiles": {
+              "type": "boolean",
+              "description": "Defaults to true. If set to false, Continue will not attempt to include snippets from other files."
             }
           },
           "required": []
diff --git a/extensions/vscode/manual-testing-sandbox/example.ts b/extensions/vscode/manual-testing-sandbox/example.ts
index 5622d7172..07bec826c 100644
--- a/extensions/vscode/manual-testing-sandbox/example.ts
+++ b/extensions/vscode/manual-testing-sandbox/example.ts
@@ -9,5 +9,4 @@ let d = repeat(5, "a");
 console.log(d);
 
 let e = factorial(3);
-console.log(e);
-
+console.log(e);
\ No newline at end of file
diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json
index 3d8aba38b..27b09e160 100644
--- a/extensions/vscode/package-lock.json
+++ b/extensions/vscode/package-lock.json
@@ -8,9 +8,6 @@
       "name": "continue",
       "version": "0.9.81",
       "license": "Apache-2.0",
-      "dependencies": {
-        "@electron/rebuild": "^3.2.10",
-        "@reduxjs/toolkit": "^1.9.3",
         "@types/jest": "^29.5.11",
         "@types/node-fetch": "^2.6.11",
         "@vscode/ripgrep": "^1.15.9",
diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts
index b0ba35647..698f2ad8f 100644
--- a/extensions/vscode/src/autocomplete/completionProvider.ts
+++ b/extensions/vscode/src/autocomplete/completionProvider.ts
@@ -58,8 +58,8 @@ export class ContinueCompletionProvider
 
     const config = await this.configHandler.loadConfig();
     const options = {
-      ...config.tabAutocompleteOptions,
       ...DEFAULT_AUTOCOMPLETE_OPTS,
+      ...config.tabAutocompleteOptions,
     };
 
     if (ContinueCompletionProvider.debouncing) {
diff --git a/extensions/vscode/src/autocomplete/getTabCompletion.ts b/extensions/vscode/src/autocomplete/getTabCompletion.ts
index ef2876499..b3bae02f8 100644
--- a/extensions/vscode/src/autocomplete/getTabCompletion.ts
+++ b/extensions/vscode/src/autocomplete/getTabCompletion.ts
@@ -1,10 +1,14 @@
 import { IDE, TabAutocompleteOptions } from "core";
 import { AutocompleteLruCache } from "core/autocomplete/cache";
-import { onlyWhitespaceAfterEndOfLine } from "core/autocomplete/charStream";
+import {
+  noFirstCharNewline,
+  onlyWhitespaceAfterEndOfLine,
+} from "core/autocomplete/charStream";
 import {
   constructAutocompletePrompt,
   languageForFilepath,
 } from "core/autocomplete/constructPrompt";
+import { AutocompleteLanguageInfo } from "core/autocomplete/languages";
 import {
   avoidPathLine,
   stopAtLines,
@@ -17,6 +21,7 @@ import { getTemplateForModel } from "core/autocomplete/templates";
 import { GeneratorReuseManager } from "core/autocomplete/util";
 import { streamLines } from "core/diff/util";
 import OpenAI from "core/llm/llms/OpenAI";
+import { getBasename } from "core/util";
 import Handlebars from "handlebars";
 import * as vscode from "vscode";
 import { TabAutocompleteModel } from "../util/loadAutocompleteModel";
@@ -38,6 +43,23 @@ export interface AutocompleteOutcome {
 const autocompleteCache = AutocompleteLruCache.get();
 const recentlyEditedTracker = new RecentlyEditedTracker();
 
+function formatExternalSnippet(
+  filepath: string,
+  snippet: string,
+  language: AutocompleteLanguageInfo,
+) {
+  const comment = language.comment;
+  const lines = [
+    comment + " Path: " + getBasename(filepath),
+    ...snippet
+      .trim()
+      .split("\n")
+      .map((line) => comment + " " + line),
+    comment,
+  ];
+  return lines.join("\n");
+}
+
 export async function getTabCompletion(
   document: vscode.TextDocument,
   pos: vscode.Position,
@@ -99,7 +121,7 @@ export async function getTabCompletion(
     });
   }
 
-  const { prefix, suffix, completeMultiline } =
+  let { prefix, suffix, completeMultiline, snippets } =
     await constructAutocompletePrompt(
       document.uri.toString(),
       pos.line,
@@ -114,12 +136,37 @@ export async function getTabCompletion(
       extrasSnippets,
     );
 
+  // Template prompt
   const { template, completionOptions } = options.template
     ? { template: options.template, completionOptions: {} }
     : getTemplateForModel(llm.model);
 
-  const compiledTemplate = Handlebars.compile(template);
-  const prompt = compiledTemplate({ prefix, suffix });
+  let prompt: string;
+  const filename = getBasename(document.uri.fsPath);
+  const reponame = getBasename(workspaceDirs[0] ?? "myproject");
+  if (typeof template === "string") {
+    const compiledTemplate = Handlebars.compile(template);
+
+    // Format snippets as comments and prepend to prefix
+    const formattedSnippets = snippets
+      .map((snippet) =>
+        formatExternalSnippet(snippet.filepath, snippet.contents, lang),
+      )
+      .join("\n");
+    if (formattedSnippets.length > 0) {
+      prefix = formattedSnippets + "\n\n" + prefix;
+    }
+
+    prompt = compiledTemplate({
+      prefix,
+      suffix,
+      filename,
+      reponame,
+    });
+  } else {
+    // Let the template function format snippets
+    prompt = template(prefix, suffix, filename, reponame, snippets);
+  }
 
   // Completion
   let completion = "";
@@ -172,8 +219,9 @@ export async function getTabCompletion(
         yield update;
       }
     };
+    let chars = generatorWithCancellation();
     const gen2 = onlyWhitespaceAfterEndOfLine(
-      generatorWithCancellation(),
+      noFirstCharNewline(chars),
       lang.endOfLine,
     );
     const lineGenerator = streamWithNewLines(
diff --git a/extensions/vscode/src/extension/vscodeExtension.ts b/extensions/vscode/src/extension/vscodeExtension.ts
index 00521d338..73d2809d5 100644
--- a/extensions/vscode/src/extension/vscodeExtension.ts
+++ b/extensions/vscode/src/extension/vscodeExtension.ts
@@ -116,23 +116,18 @@ export class VsCodeExtension {
     const config = vscode.workspace.getConfiguration("continue");
     const enabled = config.get("enableTabAutocomplete");
 
-    // Register inline completion provider (odd versions are pre-release)
-    if (
-      parseInt(context.extension.packageJSON.version.split(".")[1]) % 2 !==
-      0
-    ) {
-      setupStatusBar(enabled);
-      context.subscriptions.push(
-        vscode.languages.registerInlineCompletionItemProvider(
-          [{ pattern: "**" }],
-          new ContinueCompletionProvider(
-            this.configHandler,
-            this.ide,
-            this.tabAutocompleteModel,
-          ),
+    // Register inline completion provider
+    setupStatusBar(enabled);
+    context.subscriptions.push(
+      vscode.languages.registerInlineCompletionItemProvider(
+        [{ pattern: "**" }],
+        new ContinueCompletionProvider(
+          this.configHandler,
+          this.ide,
+          this.tabAutocompleteModel,
         ),
-      );
-    }
+      ),
+    );
 
     // Commands
     registerAllCommands(
diff --git a/extensions/vscode/yarn.lock b/extensions/vscode/yarn.lock
index 530ca3472..21f1b3e6c 100644
--- a/extensions/vscode/yarn.lock
+++ b/extensions/vscode/yarn.lock
@@ -697,9 +697,9 @@
   integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==
 
 "@lancedb/vectordb-darwin-arm64@*":
-  version "0.4.11"
-  resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.11.tgz"
-  integrity sha512-JDOKmFnuJPFkA7ZmrzBJolROwSjWr7yMvAbi40uLBc25YbbVezodd30u2EFtIwWwtk1GqNYRZ49FZOElKYeC/Q==
+  version "0.4.12"
+  resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.12.tgz"
+  integrity sha512-38/rkJRlWXkPWXuj9onzvbrhnIWcIUQjgEp5G9v5ixPosBowm7A4j8e2Q8CJMsVSNcVX2JLqwWVldiWegZFuYw==
 
 "@lancedb/vectordb-darwin-arm64@0.4.10":
   version "0.4.10"
diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx
index fa6591e93..5bf6ae70f 100644
--- a/gui/src/components/mainInput/TipTapEditor.tsx
+++ b/gui/src/components/mainInput/TipTapEditor.tsx
@@ -420,6 +420,7 @@ function TipTapEditor(props: TipTapEditorProps) {
         saveSession();
       }
       setTimeout(() => {
+        editor?.commands.blur();
         editor?.commands.focus("end");
       }, 20);
     },
@@ -493,8 +494,9 @@ function TipTapEditor(props: TipTapEditorProps) {
           })
           .run();
         setTimeout(() => {
+          editor.commands.blur();
           editor.commands.focus("end");
-        }, 200);
+        }, 20);
       }
       setIgnoreHighlightedCode(false);
     },
diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx
index 4df6f8896..d5c80e08c 100644
--- a/gui/src/components/markdown/CodeSnippetPreview.tsx
+++ b/gui/src/components/markdown/CodeSnippetPreview.tsx
@@ -93,7 +93,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
             new WebviewIde().showLines(
               props.item.description,
               parseInt(lines[0]) - 1,
-              parseInt(lines[1]) - 1
+              parseInt(lines[1]) - 1,
             );
           } else {
             postToIde("showVirtualFile", {
@@ -144,7 +144,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
           height: collapsed
             ? `${Math.min(
                 MAX_PREVIEW_HEIGHT,
-                codeBlockRef.current?.scrollHeight
+                codeBlockRef.current?.scrollHeight,
               )}px`
             : undefined,
           overflow: collapsed ? "hidden" : "auto",
@@ -152,7 +152,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) {
       >
         
diff --git a/gui/src/util/modelData.ts b/gui/src/util/modelData.ts
index 40a823634..52a316840 100644
--- a/gui/src/util/modelData.ts
+++ b/gui/src/util/modelData.ts
@@ -687,7 +687,7 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = {
     description:
       "One of the fastest ways to get started with local models on Mac, Linux, or Windows",
     longDescription:
-      'To get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama pull `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model="codellama:7b-instruct"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.',
+      'To get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run `. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.py (e.g. `model="codellama:7b-instruct"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.',
     icon: "ollama.png",
     tags: [ModelProviderTag["Local"], ModelProviderTag["Open-Source"]],
     packages: [