From 86897c8d02f1927812c7a870ecaf9b82b2c9a3d4 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 28 Dec 2023 10:27:24 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=93=9D=20fix=20documentation=20build?= =?UTF-8?q?=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/config-file-migration.md | 2 +- docs/docs/model-setup/select-provider.md | 4 ++-- docs/docs/reference/Model Providers/lmstudio.md | 17 +++++++++++++++++ docs/sidebars.js | 1 - 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 docs/docs/reference/Model Providers/lmstudio.md diff --git a/docs/docs/config-file-migration.md b/docs/docs/config-file-migration.md index 5934c06bb..7e5a3e5fd 100644 --- a/docs/docs/config-file-migration.md +++ b/docs/docs/config-file-migration.md @@ -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: diff --git a/docs/docs/model-setup/select-provider.md b/docs/docs/model-setup/select-provider.md index 3235dfc31..1b720fbc8 100644 --- a/docs/docs/model-setup/select-provider.md +++ b/docs/docs/model-setup/select-provider.md @@ -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) diff --git a/docs/docs/reference/Model Providers/lmstudio.md b/docs/docs/reference/Model Providers/lmstudio.md new file mode 100644 index 000000000..a44a84427 --- /dev/null +++ b/docs/docs/reference/Model Providers/lmstudio.md @@ -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) diff --git a/docs/sidebars.js b/docs/sidebars.js index bfd360c27..a50d33185 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -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", ], From 6322984a89c659bb1fabf4522b403570269e1749 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 28 Dec 2023 10:35:40 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9D=20custom=20template=20messages?= =?UTF-8?q?=20in=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/model-setup/configuration.md | 60 +++++++++++++++----------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/docs/docs/model-setup/configuration.md b/docs/docs/model-setup/configuration.md index 960fc5425..68a073ff8 100644 --- a/docs/docs/model-setup/configuration.md +++ b/docs/docs/model-setup/configuration.md @@ -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" + 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" + for (let msg of msgs){ + prompt += `${msg.content}\n` + } prompt += "### Response:\n" 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"] = "" - return config +```typescript title="~/.continue/config.py" +function modifyConfig(config: Config): Config { + config.models[0].promptTemplates["edit"] = ""; + 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). From b162e8703a357c8d365cd6073bbc7fbb58ad527f Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 28 Dec 2023 13:09:08 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9D=20fix=20templateMessages=20exa?= =?UTF-8?q?mple=20in=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/model-setup/configuration.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/docs/model-setup/configuration.md b/docs/docs/model-setup/configuration.md index 68a073ff8..28307b80d 100644 --- a/docs/docs/model-setup/configuration.md +++ b/docs/docs/model-setup/configuration.md @@ -60,21 +60,21 @@ If you want to create an entirely new chat template, this can be done in [config ```typescript function templateAlpacaMessages(msgs: ChatMessage[]): string { - let prompt = "" + let prompt = ""; - if msgs[0].role === "system" { - prompt += `${msgs[0].content}\n` - msgs.pop(0) - } + if (msgs[0].role === "system") { + prompt += `${msgs[0].content}\n`; + msgs.pop(0); + } - prompt += "### Instruction:\n" - for (let msg of msgs){ - prompt += `${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; } ```