Merge branch 'main' into preview

This commit is contained in:
Nate Sesti 2024-03-06 19:31:16 -08:00
commit a428d3eff6
32 changed files with 270 additions and 152 deletions

View file

@ -0,0 +1,3 @@
## 0.8.15 - 2024-03-05
### Added
* Tab-autocomplete in beta

View file

@ -1,4 +0,0 @@
project: extensions/vscode
kind: Added
body: Tab-autocomplete in beta
time: 2024-03-03T19:00:39.909292-05:00

View file

@ -24,3 +24,14 @@ export async function* onlyWhitespaceAfterEndOfLine(
}
yield pending;
}
export async function* noFirstCharNewline(stream: AsyncGenerator<string>) {
let first = true;
for await (let char of stream) {
if (first) {
first = false;
if (char === "\n") return;
}
yield char;
}
}

View file

@ -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,
};
}

View file

@ -9,7 +9,8 @@ export async function* avoidPathLine(
// Snippets are inserted as comments with a line at the start '// Path: <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;

View file

@ -14,4 +14,5 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = {
recentlyEditedSimilarityThreshold: 0.3,
useCache: true,
onlyMyCode: true,
useOtherFiles: true,
};

View file

@ -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<CompletionOptions>;
}
@ -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
? ""
: "<file_sep>" +
snippets
.map((snippet) => {
return snippet.contents;
// return `${getBasename(snippet.filepath)}\n${snippet.contents}`;
})
.join("<file_sep>") +
"<file_sep>";
let prompt = `${otherFiles}<fim_prefix>${prefix}<fim_suffix>${suffix}<fim_middle>`;
return prompt;
},
completionOptions: {
stop: [
"<fim_prefix>",
"<fim_suffix>",
"<fim_middle>",
"<|endoftext|>",
"<file_sep>",
],
},
};
const codeLlamaFimTemplate: AutocompleteTemplate = {
template: "<PRE> {{{prefix}}} <SUF>{{{suffix}}} <MID>",
completionOptions: { stop: ["<PRE>", "<SUF>", "<MID>", "<EOT>"] },
@ -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") ||

1
core/index.d.ts vendored
View file

@ -596,6 +596,7 @@ export interface TabAutocompleteOptions {
recentlyEditedSimilarityThreshold: number;
useCache: boolean;
onlyMyCode: boolean;
useOtherFiles: boolean;
}
export interface SerializedContinueConfig {

View file

@ -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,
}),

View file

@ -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,
};

View file

@ -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;
}
}

View file

@ -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" }
```

View file

@ -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`.

View file

@ -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

View file

@ -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)

View file

@ -8,8 +8,7 @@ The following shows the JSON Schema definition for `config.json`. You can also d
<JSONSchemaViewer
schema={Schema}
resolverOptions={{
jsonPointer:
"#/definitions/continuedev__core__config__serialized_config__SerializedContinueConfig",
jsonPointer: "#/definitions/SerializedContinueConfig",
}}
/>

View file

@ -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.

View file

@ -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"
}
]
}

View file

@ -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 <MODEL_NAME>`. 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 <MODEL_NAME>`. 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": []

View file

@ -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 <MODEL_NAME>`. 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 <MODEL_NAME>`. 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": []

View file

@ -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"
}
]
}
"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"
}
]
}

View file

@ -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 <MODEL_NAME>`. 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 <MODEL_NAME>`. 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": []

View file

@ -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 <MODEL_NAME>`. 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 <MODEL_NAME>`. 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": []

View file

@ -9,5 +9,4 @@ let d = repeat(5, "a");
console.log(d);
let e = factorial(3);
console.log(e);
console.log(e);

View file

@ -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",

View file

@ -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) {

View file

@ -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(

View file

@ -116,23 +116,18 @@ export class VsCodeExtension {
const config = vscode.workspace.getConfiguration("continue");
const enabled = config.get<boolean>("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(

View file

@ -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"

View file

@ -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);
},

View file

@ -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) {
>
<StyledMarkdownPreview
source={`${fence}${getMarkdownLanguageTagForFile(
props.item.description
props.item.description,
)}\n${props.item.content.trim()}\n${fence}`}
showCodeBorder={false}
/>

View file

@ -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 <MODEL_NAME>`. 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 <MODEL_NAME>`. 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: [