Merge pull request #2203 from continuedev/nate/docs-refactor

Nate - docs refactor
This commit is contained in:
Patrick Erichsen 2024-09-06 13:48:41 -07:00 • committed by GitHub
commit 7dbd56627a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 276 additions and 18 deletions

View file

@ -1,7 +1,55 @@
---
title: Advanced configuration
description: \-advanced configuration
description: Actions \-advanced configuration
keywords: [configuration, advanced]
---
# Advanced configuration
## Built-in slash commands
Continue has a large library of built-in slash commands, but when you first install we only display the most commonly used ones, like “/edit”, “/comment”, and “/share”. To add more actions, you can open [config.json](https://docs.continue.dev/reference/config-json.md) and add them to the `slashCommands` array.
## Custom slash commands
There are two ways to add custom slash commands:
1. With `.prompt` files - this is recommended in most cases. See the full reference [here](../reference/prompt-files.md).
2. With `config.ts` - this gives you full programmatic access to the LLM, IDE, and other important entities by writing a JavaScript/TypeScript function
### Custom Slash Commands with `config.ts`
:::tip[config.ts]
Before adding a custom slash command, we recommend reading the [introduction to `config.ts`](../reference/config-ts.md).
:::
If you want to go a step further than writing custom commands with natural language, you can write a custom function that returns the response. This requires using `config.ts` instead of `config.json`.
To do this, push a new `SlashCommand` object to the `slashCommands` list. This object contains "name", the name that you will type to invoke the slash command, "description", the description seen in the dropdown menu, and "run". The `run` function is any async generator that should yield strings as you want them to be streamed to the UI. As an argument to the function, you have access to a `ContinueSDK` object with utilities such as access to certain information/actions within the IDE, the current language model, and a few other utilities. For example, here is a slash command that generates a commit message:
```typescript title="~/.continue/config.ts"
export function modifyConfig(config: Config): Config {
config.slashCommands?.push({
name: "commit",
description: "Write a commit message",
run: async function* (sdk) {
const diff = await sdk.ide.getDiff();
for await (const message of sdk.llm.streamComplete(
`${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`,
{
maxTokens: 20,
},
)) {
yield message;
}
},
});
return config;
}
```
For full `config.ts` reference, see [here](../reference/config-ts.md).
## Other custom actions
Currently the other action triggers are not open for configuration, but we plan to allow this via .prompt files in the future.

View file

@ -1,7 +1,37 @@
---
title: Context selection
description: \-context selection
keywords: [context]
description: Actions \-context selection
keywords: [context, slash, debug, quick fix, right click]
---
# Context selection
## Slash commands
Slash commands can be combined with additional instructions, including [context providers](../chat/context-selection.md) or [highlighted code](../chat/context-selection.md).
For example, with the “/edit” slash command you should describe the edit that you want the LLM to perform.
Some slash commands will not acknowledge your input; for example, the “/share” slash command just creates a markdown copy of the current conversation, regardless of what else you may request it to do.
## Quick actions
Quick actions are always displayed above a class or function and will edit that class or function, but nothing outside of it.
## Right click actions
The highlighted code you’ve selected will be included in your prompt alongside a pre-written set of instructions depending on the selected action. This is the only section of code that the model will attempt to edit.
## Debug action
The debug action selects the most recently run terminal command and its output and then injects the following prompt into the chat window. There is no additional, non-visible information sent to the language model.
```
I got the following error, can you please help explain how to fix it?
[ERROR_MESSAGE]
```
## Quick fixes
Similarly to the debug action, quick actions transparently inject a prompt into the chat window. When you select “Ask Continue”, the 3 lines above and below the error are sent to the chat followed by the question “How do I fix the following problem in the above code?: [ERROR_MESSAGE]”.

View file

@ -1,7 +1,13 @@
---
title: How it works
description: \-how it works
keywords: [how]
description: Actions \-how it works
keywords: [how, slash, commands, prompt, right click, quick fix, debug, action]
---
# How it works
While many actions are based on templated prompts and can be customized with .prompt files, there are a number that execute more complex code under the hood.
Actions that generate inline diffs, like “/edit”, “/comment”, or right click actions, use the same prompt and response processing logic as [Edit](../edit/how-it-works.md).
To learn how other slash commands work, see the full reference [here](../reference/slash-commands).

View file

@ -1,7 +1,81 @@
---
title: How to use it
description: How to use it
keywords: [how]
description: Actions \- how to use it
keywords: [how, slash, commands, prompt, right click, quick fix, debug, action]
---
# How to use it
# How to use it
Actions are shortcuts for common use cases. For example, you might want to review code, write tests, or add a docstring.
## Slash commands
The most common way to invoke an action is with a slash command. These are shortcuts that can be activated by typing '/' and selecting from the dropdown. For example, the built-in '/edit' slash command lets you stream edits directly into your editor.
![slash-commands](/img/slash-commands.png)
A few of the most useful slash commands are available by default, like “/edit”, “/comment”, and “/share”, but Continue has a large built-in library of other options. To enable these, learn more [here](TODO).
## Prompt files
It is also possible to write your own slash command by defining a “.prompt file.” Prompt files can be as simple as a text file, but also include templating so that you can refer to files, URLs, highlighted code, and more.
The full .prompt file reference can be found [here](TODO).
:::tip[Prompt library]
To assist you in getting started, [we've curated a small library of `.prompt` files](https://github.com/continuedev/prompt-file-examples). We encourage community contributions to this repository, so please consider opening up a pull request with your own prompts!
:::
Below is a quick example of setting up a prompt file to write unit tests using Jest.
1. Create a folder called `.prompts/` at the top level of your workspace.
2. Add a file called `test.prompt` to this folder. The name of this file will be the name of the slash command you will use to generate your prompt.
3. Write the following contents to `test.prompt` and save.
```
{{{ input }}}
Write unit tests for the above selected code, following each of these instructions:
- Use `jest`
- Properly set up and tear down
- Include important edge cases
- The tests should be complete and sophisticated
- Give the tests just as chat output, don't edit any file
- Don't explain how to set up `jest`
```
Now to use this prompt, you can highlight code and use `cmd/ctrl+L` to select it in the Continue sidebar.
Then, type "/" to see the list of slash commands and choose the one called "test". Press enter and the LLM will respond given the instructions from your prompt file.
## Other triggers for actions (VS Code)
:::info
Currently all of these are only available in VS Code
:::
To make common use cases even more accessible, we provide a handful of other ways to invoke actions.
### Quick actions
Quick Actions are displayed as buttons above top-level classes and functions in your source code, letting you invoke actions with one click. They can also be customized with .prompt files to perform custom actions.
![quick-actions](/img/quick-actions.png)
By default, quick actions are disabled, but can be enabled with the “Continue: Enable Quick Actions” in VS Code settings.
### Right click actions
Right click actions let you highlight a desired region of code, right click, and then select an action from the dropdown menu.
![context-menu](/img/context-menu.png)
### Debug action
The debug action is a special built-in keyboard shortcut in the VS Code extension. Use `cmd/ctrl+shift+R` to instantly copy the contents of the current terminal into the chat sidebar and get debugging advice.
### Quick fixes
Whenever you see red/yellow underlines in your code indicating errors, you can place your cursor nearby and VS Code will display a lightbulb icon. Either clicking the lightbulb or using the keyboard shortcut `cmd/ctrl+.` will show a dropdown menu of quick fixes. One of these will be the “Ask Continue” action. Either click or use `cmd/ctrl+.` again and Continue will attempt to help solve the problem.
![ask-continue](/img/ask-continue.png)

View file

@ -1,7 +1,11 @@
---
title: Model setup
description: \-model setup
description: Actions \-model setup
keywords: [model]
---
# Model setup
By default, actions uses the same model as Chat since we recommend a similar, 400B+ parameter model for the complex instructions that will be carried out.
<!-- For any actions defined in a .prompt file, you can [configure a specific model](TODO). -->

View file

@ -1,7 +1,23 @@
---
title: Advanced configuration
description: \-advanced configuration
description: Autocomplete \- advanced configuration
keywords: [configuration, advanced]
---
# Advanced configuration
Experiment with these settings to find the perfect balance between suggestion quality and system performance for your specific needs and hardware capabilities:
```config.json
"tabAutocompleteOptions": {
"useCopyBuffer": false,
"maxPromptTokens": 400,
"prefixPercentage": 0.5
"multilineCompletions": "always"
}
```
- `useCopyBuffer`: Determines if the clipboard content should be considered in prompt construction.
- `maxPromptTokens`: Sets the maximum number of tokens for the prompt, balancing context and speed.
- `prefixPercentage`: Defines the proportion of the prompt dedicated to the code before the cursor.
- `multilineCompletions`: Controls whether suggestions can span multiple lines ("always", "never", or "auto").
For a comprehensive guide on all configuration options and their impacts, refer to our (detailed configuration documentation).

View file

@ -1,7 +1,17 @@
---
title: Context selection
description: \-context selection
description: Autocomplete \-context selection
keywords: [context]
---
# Context selection
Autocomplete will automatically determine context based on the current cursor position. We use the following techniques to determine what to include in the prompt:
### File prefix/suffix
We will always include the code from your file prior to and after the cursor position.
### Type definitions from the LSP
### Recent files
We automatically consider recently opened or edited files and include snippets that are relevant to the current completion.

View file

@ -1,7 +1,17 @@
---
title: How it works
description: \-how it works
keywords: [how]
description: Autocomplete \-how it works
keywords: [how, autocomplete, context]
---
# How it works
Continue’s autocomplete is a [compound AI system]() that uses a combination of retrieval methods and response processing techniques. The system can be understood in roughly three parts.
## Timing
## Context
## Filtering
Continue's autocomplete analyzes your code context, including the current file, cursor position, and recent edits. It crafts a smart prompt using this information and relevant snippets from other files. The system then uses a language model to generate code suggestions, which can include multi-line completions or edits to existing code. These suggestions are refined for relevance and correctness, with successful completions cached for future use. Finally, the system displays the suggestions as ghost text for new additions or diff popups for modifications, allowing you to easily understand and incorporate the proposed changes.

View file

@ -1,7 +1,23 @@
---
title: How to use it
description: How to use it
description: Autocomplete \- how to use it
keywords: [how]
---
# How to use it
Tab autocomplete provides inline code suggestions as you type. To enable it, simply click the "Continue" button in the status bar at the bottom right of your IDE or ensure the "Enable Tab Autocomplete" option is checked in your IDE settings.
## See when ghost text appears
Autocomplete will suggest code based on your recent changes for every keystroke or cursor movement. You'll see suggestions appear as ghost text when adding new code or when modifying existing code. Suggestions may not always appear if no changes are predicted.
## Accept the suggestions
Accept a full suggestion by pressing Tab, or reject it with Esc. Use Ctrl/CMD + → to accept part of a suggestion word-by-word, allowing for more granular control. To reject a suggestion, simply continue typing or press Escape.
:::tip
Getting only ever single-line suggestions? To ensure multi-line completions, set "multilineCompletions": "always" in tabAutocompleteOptions. If you're still seeing only single-line completions, try temporarily moving text below your cursor out of your active file or switching to a larger model.
:::

View file

@ -1,7 +1,51 @@
---
title: Model setup
description: \-model setup
keywords: [model]
description: Autocomplete \-model setup
keywords: [model, autocomplete]
---
# Model setup
## Best autocomplete experience (Codestral)
For the best autocomplete experience, we recommend using Codestral through the [Mistral API](https://console.mistral.ai/). This model offers high-quality completions with an excellent understanding of code context:
```config.json
{
"tabAutocompleteModel": {
"title": "Codestral",
"provider": "mistral",
"model": "codestral-latest",
"apiKey": "YOUR_API_KEY"
}
}
```
## Self Hosted / Local
For those preferring local execution or self-hosting, StarCoder2-3b offers a good balance of performance and quality for most users:
```config.json
{
"tabAutocompleteModel": {
"title": "StarCoder2-3b",
"model": "starcoder2:3b",
"provider": "ollama",
}
}
```
### Alternatives
- Need to be faster? Try deepseek-coder:1.3b-base for quicker completions on less powerful hardware.
- Have more compute? Use deepseek-coder:6.7b-base for potentially higher-quality suggestions.
:::note
For LM Studio users, navigate to the "My Models" section, find your desired model, and copy the path (e.g., second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf). Use this path in your configuration.
:::
## More
There are many more models and providers you can use with Autocomplete. Check them out [here](../reference/Model%20Providers/).

BIN
docs/static/img/ask-continue.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

BIN
docs/static/img/context-menu.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

BIN
docs/static/img/quick-actions.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB