From 86897c8d02f1927812c7a870ecaf9b82b2c9a3d4 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 28 Dec 2023 10:27:24 -0500 Subject: [PATCH 1/7] =?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/7] =?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/7] =?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; } ``` From 03bc88e1b3e4868a2d6188816dad5b0b09f243bc Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 29 Dec 2023 02:11:54 +0000 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=92=9A=20Update=20package.json=20vers?= =?UTF-8?q?ion=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 ++-- extensions/vscode/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 2d540f041..e4e517eb1 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.61", + "version": "0.7.62", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.61", + "version": "0.7.62", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index d8e0a4455..f46d5dc88 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.61", + "version": "0.7.62", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 271dbce25f0283835c465091cbd520016fa879a6 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 28 Dec 2023 22:19:05 -0500 Subject: [PATCH 5/7] =?UTF-8?q?=F0=9F=94=A5=20remove=20modelRoles=20from?= =?UTF-8?q?=20config=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config/default.ts | 4 ---- core/config/types.ts | 1 - core/index.d.ts | 1 - extensions/vscode/config_schema.json | 15 --------------- 4 files changed, 21 deletions(-) diff --git a/core/config/default.ts b/core/config/default.ts index 9b32bd474..ad23477c6 100644 --- a/core/config/default.ts +++ b/core/config/default.ts @@ -13,10 +13,6 @@ const defaultConfig: SerializedContinueConfig = { model: "gpt-3.5-turbo", }, ], - modelRoles: { - default: "GPT-4", - summarize: "GPT-3.5-Turbo", - }, slashCommands: [ { name: "edit", diff --git a/core/config/types.ts b/core/config/types.ts index 1b4bff556..5256b7e97 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -441,7 +441,6 @@ declare global { disallowedSteps?: string[]; allowAnonymousTelemetry?: boolean; models: ModelDescription[]; - modelRoles: ModelRoles; systemMessage?: string; completionOptions?: BaseCompletionOptions; slashCommands?: SlashCommandDescription[]; diff --git a/core/index.d.ts b/core/index.d.ts index 9aca642c1..9368f4823 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -442,7 +442,6 @@ export interface SerializedContinueConfig { disallowedSteps?: string[]; allowAnonymousTelemetry?: boolean; models: ModelDescription[]; - modelRoles: ModelRoles; systemMessage?: string; completionOptions?: BaseCompletionOptions; slashCommands?: SlashCommandDescription[]; diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index cad4101de..19134f885 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -844,21 +844,6 @@ "$ref": "#/definitions/ModelDescription" } }, - "modelRoles": { - "title": "Model Roles", - "description": "Roles for models. Each entry should be the title of a model in the models array.", - "default": { - "default": "GPT-4 (trial)", - "chat": null, - "edit": null, - "summarize": null - }, - "allOf": [ - { - "$ref": "#/definitions/ModelRoles" - } - ] - }, "systemMessage": { "title": "System Message", "description": "A system message that will always be followed by the LLM", From d827576936ef915514a0dcb8c41bd9cbf0cc929d Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 29 Dec 2023 10:57:50 -0500 Subject: [PATCH 6/7] =?UTF-8?q?=E2=9C=A8=20diff=20context=20provider=20in?= =?UTF-8?q?=20jetbrains?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constants/ServerConstants.kt | 19 ++++++++ .../continue/IdeProtocolClient.kt | 46 +++++++++++++++---- gui/src/components/mainInput/TipTapEditor.tsx | 2 +- gui/src/hooks/useSetup.ts | 2 + 4 files changed, 58 insertions(+), 11 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt index 38c16ae24..daaa26245 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/ServerConstants.kt @@ -1,5 +1,6 @@ package com.github.continuedev.continueintellijextension.constants +import java.io.File import java.nio.file.Files import java.nio.file.Paths @@ -132,4 +133,22 @@ fun getDevDataFilepath(filename: String): String { Files.createFile(path) } return path.toString() +} + +fun getMigrationsFolderPath(): String { + val path = Paths.get(getContinueGlobalPath(), ".migrations") + if (Files.notExists(path)) { + Files.createDirectories(path) + } + return path.toString() +} + +fun migrate(id: String, callback: () -> Unit) { + val migrationsPath = getMigrationsFolderPath() + val migrationPath = Paths.get(migrationsPath, id).toString() + val migrationFile = File(migrationPath) + if (!migrationFile.exists()) { + migrationFile.writeText("") + callback() + } } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index caf573649..60b73a198 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -1,16 +1,18 @@ package com.github.continuedev.continueintellijextension.`continue` import com.github.continuedev.continueintellijextension.* -import com.github.continuedev.continueintellijextension.constants.getConfigJsPath -import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath -import com.github.continuedev.continueintellijextension.constants.getContinueGlobalPath -import com.github.continuedev.continueintellijextension.constants.getDevDataFilepath +import com.github.continuedev.continueintellijextension.constants.* import com.github.continuedev.continueintellijextension.services.ContinuePluginService import com.google.gson.Gson import com.google.gson.GsonBuilder import com.google.gson.JsonObject import com.google.gson.reflect.TypeToken +import com.intellij.execution.ExecutionManager +import com.intellij.execution.process.ProcessAdapter +import com.intellij.execution.process.ProcessEvent +import com.intellij.execution.ui.RunContentDescriptor import com.intellij.openapi.Disposable +import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.application.ApplicationInfo import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.ServiceManager @@ -32,15 +34,13 @@ import com.intellij.ui.awt.RelativePoint import kotlinx.coroutines.* import net.minidev.json.JSONObject import org.jetbrains.annotations.NotNull -import java.io.File -import java.io.FileInputStream -import java.io.FileReader -import java.io.FileWriter +import java.io.* import java.net.NetworkInterface import java.nio.charset.Charset import java.nio.file.Files import java.nio.file.Paths import java.util.* +import kotlin.coroutines.ContinuationInterceptor fun uuid(): String { @@ -278,11 +278,37 @@ class IdeProtocolClient ( // NEW // "getDiff" -> { - respond(null); + val builder = ProcessBuilder("git", "diff") + builder.directory(File(workspacePath ?: ".")) + val process = builder.start() + + val reader = BufferedReader(InputStreamReader(process.inputStream)) + val output = StringBuilder() + var line: String? = reader.readLine() + while (line != null) { + output.append(line) + output.append("\n") + line = reader.readLine() + } + + process.waitFor() + + respond(output.toString()); } "getSerializedConfig" -> { val configPath = getConfigJsonPath() - val config = File(configPath).readText() + var config = File(configPath).readText() + + migrate("camelCaseConfig") { + if (config.contains("_")) { + config = config + .replace(Regex("(_\\w)")) { it.value[1].uppercase() } + .replace("openai-aiohttp", "openai") + // Rewrite to config.json + File(configPath).writeText(config) + } + } + val mapType = object : TypeToken>() {}.type val parsed: Map = Gson().fromJson(config, mapType) respond(parsed) diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index ac9ed65d6..eeb377f82 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -276,7 +276,7 @@ function TipTapEditor(props: TipTapEditorProps) { return; } if (editor && document.hasFocus()) { - editor.commands.focus() + editor.commands.focus(); } const handler = async (event: any) => { if (!editor) return; diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index f6dbb3190..ba0b02e51 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -18,7 +18,9 @@ function useSetup(dispatch: Dispatch) { try { const ide = new ExtensionIde(); let serialized = await ide.getSerializedConfig(); + console.log("serialized: ", serialized); let intermediate = serializedToIntermediateConfig(serialized); + console.log("i1", intermediate); const configJsUrl = await ide.getConfigJsUrl(); if (configJsUrl) { From a761d8bc8e55a1bb6b2f60f6d81236247f508ea2 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 29 Dec 2023 10:58:30 -0500 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=93=9D=20update=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changes/unreleased/Added-20231229-105815.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changes/unreleased/Added-20231229-105815.yaml diff --git a/.changes/unreleased/Added-20231229-105815.yaml b/.changes/unreleased/Added-20231229-105815.yaml new file mode 100644 index 000000000..16a87052c --- /dev/null +++ b/.changes/unreleased/Added-20231229-105815.yaml @@ -0,0 +1,4 @@ +project: extensions/intellij +kind: Added +body: diff context provider +time: 2023-12-29T10:58:15.432508-05:00