Merge branch 'main' into preview
This commit is contained in:
commit
fdcf5ebce1
5 changed files with 59 additions and 33 deletions
|
|
@ -14,7 +14,7 @@ If you need any help migrating, please reach out to us on Discord.
|
|||
|
||||
## Configuration as Code
|
||||
|
||||
> Continue has moved to using Typescript configuration. To learn about this, please see [Configuration as Code](../customization/code-config.md).
|
||||
> Continue has moved to using Typescript configuration. To learn about this, please see [Configuration as Code](./customization/code-config.md).
|
||||
|
||||
For configuration that requires code, we now provide a simpler interface that works alongside config.json. In the same folder, `~/.continue`, create a file named `config.py` (the same name as before) and add a function called `modify_config`. This function should take a [`ContinueConfig`](https://github.com/continuedev/continue/blob/main/server/continuedev/core/config.py) object as its only argument, and return a `ContinueConfig` object. This object is essentially the same as the one that was previously defined in `config.py`. This allows you to modify the initial configuration object defined in your `config.json`. Here's an example that cuts the temperature in half:
|
||||
|
||||
|
|
|
|||
|
|
@ -54,33 +54,42 @@ However, if neither of these are the case, you will need to wire up a new LLM ob
|
|||
|
||||
## Customizing the Chat Template
|
||||
|
||||
Most open-source models expect a specific chat format, for example llama2 and codellama expect the input to look like `"[INST] How do I write bubble sort in Rust? [/INST]"`. Continue will automatically attempt to detect the correct prompt format based on the `model`value that you provide, but if you are receiving nonsense responses, you can use the`template`property to explicitly set the format that you expect. The options are:`["llama2", "alpaca", "zephyr", "phind", "anthropic", "chatml"]`.
|
||||
Most open-source models expect a specific chat format, for example llama2 and codellama expect the input to look like `"[INST] How do I write bubble sort in Rust? [/INST]"`. Continue will automatically attempt to detect the correct prompt format based on the `model`value that you provide, but if you are receiving nonsense responses, you can use the`template`property to explicitly set the format that you expect. The options are:`["llama2", "alpaca", "zephyr", "phind", "anthropic", "chatml", "openchat", "none"]`.
|
||||
|
||||
If you want to create an entirely new chat template, this can be done in [config.ts](../customization/code-config.md) by defining a function and adding it to the `templateMessages` property of your `LLM`. Here is an example of `templateMessages` for the Alpaca/Vicuna format:
|
||||
|
||||
```python
|
||||
def template_alpaca_messages(msgs: List[Dict[str, str]]) -> str:
|
||||
prompt = ""
|
||||
```typescript
|
||||
function templateAlpacaMessages(msgs: ChatMessage[]): string {
|
||||
let prompt = "";
|
||||
|
||||
if msgs[0]["role"] == "system":
|
||||
prompt += f"{msgs[0]['content']}\n"
|
||||
msgs.pop(0)
|
||||
if (msgs[0].role === "system") {
|
||||
prompt += `${msgs[0].content}\n`;
|
||||
msgs.pop(0);
|
||||
}
|
||||
|
||||
prompt += "### Instruction:\n"
|
||||
for msg in msgs:
|
||||
prompt += f"{msg['content']}\n"
|
||||
prompt += "### Instruction:\n";
|
||||
for (let msg of msgs) {
|
||||
prompt += `${msg.content}\n`;
|
||||
}
|
||||
|
||||
prompt += "### Response:\n"
|
||||
prompt += "### Response:\n";
|
||||
|
||||
return prompt
|
||||
return prompt;
|
||||
}
|
||||
```
|
||||
|
||||
It can then be used like this:
|
||||
|
||||
```python title="~/.continue/config.py"
|
||||
def modify_config(config: ContinueConfig) -> ContinueConfig:
|
||||
config.models.default.template_messages = template_alpaca_messages
|
||||
return config
|
||||
```typescript title="~/.continue/config.ts"
|
||||
function modifyConfig(config: Config): Config {
|
||||
const model = config.models.find(
|
||||
(model) => model.title === "My Alpaca Model"
|
||||
);
|
||||
if (model) {
|
||||
model.templateMessages = templateAlpacaMessages;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
```
|
||||
|
||||
This exact function and a few other default implementations are available in [`continuedev.libs.llm.prompts.chat`](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/prompts/chat.py).
|
||||
|
|
@ -89,28 +98,29 @@ This exact function and a few other default implementations are available in [`c
|
|||
|
||||
You also have access to customize the prompt used in the '/edit' slash command. We already have a well-engineered prompt for GPT-4 and sensible defaults for less powerful open-source models, but you might wish to play with the prompt and try to find a more reliable alternative if you are for example getting English as well as code in your output.
|
||||
|
||||
To customize the prompt, use the `prompt_templates` property of any `LLM`, which is a dictionary, and set the "edit" key to a template string with Mustache syntax. The 'file_prefix', 'file_suffix', 'code_to_edit', 'context_items', and 'user_input' variables are available in the template. Here is an example (the default for non-GPT-4 models):
|
||||
To customize the prompt, use the `promptTemplates` property of any `LLM`, which is a dictionary, and set the "edit" key to a template string with Mustache syntax. The 'filePrefix', 'fileSuffix', 'codeToEdit', 'contextItems', and 'userInput' variables are available in the template. Here is an example (the default for non-GPT-4 models):
|
||||
|
||||
````python
|
||||
"""
|
||||
```typescript
|
||||
`
|
||||
[INST] Consider the following code:
|
||||
```
|
||||
{{{code_to_edit}}}
|
||||
\`\`\`
|
||||
{{{codeToEdit}}}
|
||||
|
||||
```
|
||||
\`\`\`
|
||||
Edit the code to perfectly satisfy the following user request:
|
||||
{{{user_input}}}
|
||||
{{{userInput}}}
|
||||
Output nothing except for the code. No code block, no English explanation, no start/end tags.
|
||||
[/INST]
|
||||
"""
|
||||
````
|
||||
`;
|
||||
```
|
||||
|
||||
It can then be used like this in `config.py`:
|
||||
|
||||
```python title="~/.continue/config.py"
|
||||
def modify_config(config: ContinueConfig) -> ContinueConfig:
|
||||
config.models.edit.prompt_templates["edit"] = "<INSERT_TEMPLATE_HERE>"
|
||||
return config
|
||||
```typescript title="~/.continue/config.py"
|
||||
function modifyConfig(config: Config): Config {
|
||||
config.models[0].promptTemplates["edit"] = "<INSERT_TEMPLATE_HERE>";
|
||||
return config;
|
||||
}
|
||||
```
|
||||
|
||||
A few pre-made templates are available in [`continuedev.libs.llm.prompts.edit`](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/prompts/edit.py).
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Continue makes it easy to swap out different LLM providers. You can either click
|
|||
You can run a model on your local computer using:
|
||||
|
||||
- [Ollama](../reference/Model%20Providers/ollama.md)
|
||||
- [LM Studio](../reference/Model%20Providers/ggml.md)
|
||||
- [LM Studio](../reference/Model%20Providers/lmstudio.md)
|
||||
- [Llama.cpp](../reference/Model%20Providers/llamacpp.md)
|
||||
- [LocalAI](../reference/Model%20Providers/openai.md) (OpenAI compatible server)
|
||||
- [Text generation web UI](../reference/Model%20Providers/openai.md) (OpenAI compatible server)
|
||||
|
|
@ -54,4 +54,4 @@ You can use commercial LLMs via APIs using:
|
|||
- [Azure OpenAI Service](../reference/Model%20Providers/openai.md) (OpenAI compatible API)
|
||||
- [Anthrophic API](../reference/Model%20Providers/anthropicllm.md)
|
||||
- [Google PaLM API](../reference/Model%20Providers/googlepalmapi.md)
|
||||
- [OpenAI free trial](../reference/Model%20Providers/openaifreetrial.md)
|
||||
- [OpenAI free trial](../reference/Model%20Providers/freetrial.md)
|
||||
|
|
|
|||
17
docs/docs/reference/Model Providers/lmstudio.md
Normal file
17
docs/docs/reference/Model Providers/lmstudio.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# LM Studio
|
||||
|
||||
[LM Studio](https://lmstudio.ai) is an application for Mac, Windows, and Linux that makes it easy to locally run open-source models and comes with a great UI. To get started with LM Studio, download from the website, use the UI to download a model, and then start the local inference server. Continue can then be configured to use the `LMStudio` LLM class:
|
||||
|
||||
```json title="~/.continue/config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "LM Studio",
|
||||
"provider": "lmstudio",
|
||||
"model": "llama2-7b"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[View the source](https://github.com/continuedev/continue/blob/main/core/llm/llms/LMStudio.ts)
|
||||
|
|
@ -50,7 +50,6 @@ const sidebars = {
|
|||
"walkthroughs/codellama",
|
||||
"walkthroughs/manually-run-continue",
|
||||
"walkthroughs/running-continue-without-internet",
|
||||
"walkthroughs/headless-mode",
|
||||
"walkthroughs/codebase-embeddings",
|
||||
"walkthroughs/config-file-migration",
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue