From 08116e58085a489fe94fcd786275094e7fe3ba2f Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 14 Nov 2023 23:27:02 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20docs=20update=20and=20config=20m?= =?UTF-8?q?odifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/customization/context-providers.md | 81 ++++++------------ docs/docs/customization/models.md | 85 ++++++++++--------- docs/docs/customization/overview.md | 2 +- docs/docs/customization/slash-commands.md | 34 ++++---- docs/docs/languages/{c#.md => csharp.md} | 0 .../Context Providers/diffcontextprovider.md | 2 +- .../Context Providers/filecontextprovider.md | 2 +- .../filetreecontextprovider.md | 2 +- .../githubissuescontextprovider.md | 2 +- .../googlecontextprovider.md | 2 +- .../searchcontextprovider.md | 2 +- .../terminalcontextprovider.md | 2 +- .../Context Providers/urlcontextprovider.md | 2 +- docs/docs/reference/Models/anthropicllm.md | 18 ++-- docs/docs/reference/Models/ggml.md | 20 ++--- docs/docs/reference/Models/googlepalmapi.md | 16 +--- .../Models/huggingfaceinferenceapi.md | 22 ++--- docs/docs/reference/Models/huggingfacetgi.md | 19 ++--- docs/docs/reference/Models/llamacpp.md | 19 ++--- docs/docs/reference/Models/ollama.md | 19 ++--- docs/docs/reference/Models/openai.md | 19 ++--- docs/docs/reference/Models/openaifreetrial.md | 16 +--- docs/docs/reference/Models/queuedllm.md | 16 +--- docs/docs/reference/Models/replicatellm.md | 18 ++-- docs/docs/reference/Models/textgenwebui.md | 19 ++--- docs/docs/reference/Models/togetherllm.md | 19 ++--- docs/docs/reference/config.md | 20 ++--- docs/src/components/ClassPropertyRef.tsx | 9 +- server/config.json | 52 ++++++++++++ server/continuedev/core/config.py | 64 ++++++++------ .../continuedev/core/config_utils/context.py | 4 + .../continuedev/core/config_utils/shared.py | 2 - .../libs/constants/default_config.py | 81 ++---------------- .../continuedev/models/reference/generate.py | 5 +- 34 files changed, 279 insertions(+), 416 deletions(-) rename docs/docs/languages/{c#.md => csharp.md} (100%) create mode 100644 server/config.json diff --git a/docs/docs/customization/context-providers.md b/docs/docs/customization/context-providers.md index 776310064..e5fb63bab 100644 --- a/docs/docs/customization/context-providers.md +++ b/docs/docs/customization/context-providers.md @@ -16,88 +16,67 @@ When you enter your next input, Continue will see the full contents of each of t ## Built-in Context Providers -To use any of the built-in context providers, open `~/.continue/config.py` (can do this with the '/config' slash command). For each context provider, you will - -1. Import the context provider at the top of the file -2. Add it to the `context_providers` list in the `ContinueConfig` object - -Setup instructions are below for each (showing the import and config object). You can also see examples by opening `~/.continue/config.py`. +To use any of the built-in context providers, open `~/.continue/config.json` (can do this with the '/config' slash command) and add it to the `context_providers` list. ### GitHub Type '@issue' to reference the title and contents of a GitHub issue. -```python -from continuedev.plugins.context_providers.github import GitHubIssuesContextProvider -``` - -```python -GitHubIssuesContextProvider( - repo_name="continuedev/continue", # change to whichever repo you want to use - auth_token="", -) +```json +{ + "name": "github", + "params": { + // Change to whichever repo you want to use + "repo_name": "continuedev/continue", + "auth_token": "" + } +} ``` ### Codebase Search Type '@search' to reference the results of codebase search, just like the results you would get from VS Code search. -```python -from continuedev.plugins.context_providers.search import SearchContextProvider -``` - -```python -SearchContextProvider() # No arguments necessary +```json +{ "name": "search" } ``` ### URLs Type '@url' to reference the contents of a URL. You can either reference preset URLs, or reference one dynamically by typing '@url https://example.com'. The text contents of the page will be fetched and used as context. -```python -from continuedev.plugins.context_providers.url import URLContextProvider -``` - -```python -URLContextProvider(preset_urls=["https://continue.dev/docs/customization"]) +```json +{ + "name": "url", + "params": { "preset_urls": ["https://continue.dev/docs/customization"] } +} ``` ### Git Diff Type '@diff' to reference all of the changes you've made to your current branch. This is useful if you want to summarize what you've done or ask for a general review of your work before committing. -```python -from continuedev.plugins.context_providers.diff import DiffContextProvider -``` - -```python -DiffContextProvider() +```json +{ "name": "diff" } ``` ### File Tree Type '@tree' to reference the contents of your current workspace. The LLM will be able to see the nested directory structure of your project. -```python -from continuedev.plugins.context_providers.filetree import FileTreeContextProvider -``` - -```python -FileTreeContextProvider() +```json +{ "name": "tree" } ``` ### Google Type '@google' to reference the results of a Google search. For example, type "@google python tutorial" if you want to search and discuss ways of learning Python. -```python -from continuedev.plugins.context_providers.google import GoogleContextProvider -``` - -```python -GoogleContextProvider( - serper_api_key="" -) +```json +{ + "name": "google", + "params": { "serper_api_key": "" } +} ``` Note: You can get an API key for free at [serper.dev](https://serper.dev). @@ -106,12 +85,8 @@ Note: You can get an API key for free at [serper.dev](https://serper.dev). Type '@terminal' to reference the contents of your IDE's terminal. -```python -from continuedev.plugins.context_providers.terminal import TerminalContextProvider -``` - -```python -TerminalContextProvider() +```json +{ "name": "terminal" } ``` ### Requesting Context Providers diff --git a/docs/docs/customization/models.md b/docs/docs/customization/models.md index 1e352a6cf..e5574ce33 100644 --- a/docs/docs/customization/models.md +++ b/docs/docs/customization/models.md @@ -6,7 +6,7 @@ keywords: [openai, anthropic, PaLM, ollama, ggml] # Models -Continue makes it easy to swap out different LLM providers. You can either click the "+" button next to the model dropdown to configure in the UI or manually add them to your `config.py`. Once you've done this, you will be able to switch between them with the model selection dropdown. +Continue makes it easy to swap out different LLM providers. You can either click the "+" button next to the model dropdown to configure in the UI or manually add them to your `config.json`. Once you've done this, you will be able to switch between them with the model selection dropdown. Commercial Models @@ -30,23 +30,52 @@ Open-Source Models (not local) ## Change the default LLM -In `config.py`, you'll find the `models` property: +In `config.json`, you'll find the `models` property, a list of the models that you have saved to use with Continue: -```python -from continuedev.core.models import Models - -config = ContinueConfig( - ... - models=Models( - default=OpenAIFreeTrial(model="gpt-4"), - summarize=OpenAIFreeTrial(model="gpt-3.5-turbo") - ) -) +```json +"models": [ + { + "title": "Smart Model", + "provider": "openai-free-trial", + "model": "gpt-4" + }, + { + "title": "Fast Model", + "provider": "openai-free-trial", + "model": "gpt-3.5-turbo" + } +] ``` -The `default` and `summarize` properties are different _model roles_. This allows different models to be used for different tasks. The available roles are `default`, `summarize`, `edit`, and `chat`. `edit` is used when you use the '/edit' slash command, `chat` is used for all chat responses, and `summarize` is used for summarizing. If not set, all roles will fall back to `default`. The values of these fields must be of the [`LLM`](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/__init__.py) class, which implements methods for retrieving and streaming completions from an LLM. +Also in `config.json` is the `model_roles` property. This is optional, but allows you to specify different models to be used for different tasks. The available roles are `default`, `summarize`, `edit`, and `chat`. `edit` is used when you use the '/edit' slash command, `chat` is used for all chat responses, and `summarize` is used for summarizing. If not set, all roles will fall back to `default`. The values of each role must match the `title` property of one of the models in `models`. -Below, we describe the `LLM` classes available in the Continue core library, and how they can be used. +```json +"model_roles": { + "default": "Smart Model", + "summarize": "Fast Model" +} +``` + +Just by specifying the `model` and `provider` properties, we will automatically detect prompt templates and other important information, but if you're looking to do something beyond this basic setup, we'll explain a few other options below. + +## Azure OpenAI Service + +If you'd like to use OpenAI models but are concerned about privacy, you can use the Azure OpenAI service, which is GDPR and HIPAA compliant. After applying for access [here](https://azure.microsoft.com/en-us/products/ai-services/openai-service), you will typically hear back within only a few days. Once you have access, set up a model in `config.json` like so: + +```json +"models": [{ + "title": "Azure OpenAI", + "provider": "openai", + "model": "gpt-4", + "api_base": "https://my-azure-openai-instance.openai.azure.com/", + "engine": "my-azure-openai-deployment", + "api_version": "2023-07-01-preview", + "api_type": "azure", + "api_key": "" +}] +``` + +The easiest way to find this information is from the chat playground in the Azure OpenAI portal. Under the "Chat Session" section, click "View Code" to see each of these parameters. ## Self-hosting an open-source model @@ -54,35 +83,9 @@ If you want to self-host on Colab, RunPod, HuggingFace, Haven, or another hostin If by chance the provider has the exact same API interface as OpenAI, the `OpenAI` class will work for you out of the box, after changing only the `api_base` parameter. -## Azure OpenAI Service - -If you'd like to use OpenAI models but are concerned about privacy, you can use the Azure OpenAI service, which is GDPR and HIPAA compliant. After applying for access [here](https://azure.microsoft.com/en-us/products/ai-services/openai-service), you will typically hear back within only a few days. Once you have access, instantiate the model like so: - -```python -from continuedev.libs.llm.openai import OpenAI - -config = ContinueConfig( - ... - models=Models( - default=OpenAI( - api_key="my-api-key", - model="gpt-3.5-turbo", - api_base="https://my-azure-openai-instance.openai.azure.com/", - engine="my-azure-openai-deployment", - api_version="2023-07-01-preview", - api_type="azure" - ) - ) -) -``` - -The easiest way to find this information is from the chat playground in the Azure OpenAI portal. Under the "Chat Session" section, click "View Code" to see each of these parameters. Finally, find one of your Azure OpenAI keys and enter it in the VS Code settings under `continue.OPENAI_API_KEY`. - -Note that you can also use these parameters for uses other than Azure, such as self-hosting a model. - ## 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]". Other than for the OpenAI classes, the llama2 chat format is the default, but this is not correct for all models. If you are receiving nonsense responses, you can use the `template_messages` property to set the chat template to match the model you are using. This property is a function that takes a list of `ChatMessage`s and returns a string. +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"]`. Here is an example of `template_messages` for the Alpaca/Vicuna format: diff --git a/docs/docs/customization/overview.md b/docs/docs/customization/overview.md index 25486113d..fd514125f 100644 --- a/docs/docs/customization/overview.md +++ b/docs/docs/customization/overview.md @@ -6,7 +6,7 @@ keywords: [custom, slash commands, models, context providers] # Overview -Continue can be deeply customized by editing the `ContinueConfig` object in `~/.continue/config.py` (`%userprofile%\.continue\config.py` for Windows) on your machine. This file is created the first time you run Continue. +Continue can be deeply customized by editing `~/.continue/config.json` (`%userprofile%\.continue\config.json` for Windows) on your machine. This file is created the first time you run Continue. Currently, you can customize the following: diff --git a/docs/docs/customization/slash-commands.md b/docs/docs/customization/slash-commands.md index c78f961bc..6f256bc21 100644 --- a/docs/docs/customization/slash-commands.md +++ b/docs/docs/customization/slash-commands.md @@ -15,7 +15,7 @@ There are two ways to add custom slash commands: ## "Custom Commands" (Use Natural Language) -You can add custom slash commands by adding a `CustomCommand` object to the `custom_commands` property. Each `CustomCommand` has +You can add custom slash commands by adding to the `custom_commands` property in `config.json`. - `name`: the name of the command, which will be invoked with `/name` - `description`: a short description of the command, which will appear in the dropdown @@ -23,25 +23,21 @@ You can add custom slash commands by adding a `CustomCommand` object to the `cus Custom commands are great when you are frequently reusing a prompt. For example, if you've crafted a great prompt and frequently ask the LLM to check for mistakes in your code, you could add a command like this: -```python -config = ContinueConfig( - ... - custom_commands=[ - CustomCommand( - name="check", - description="Check for mistakes in my code", - prompt=dedent("""\ - Please read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant: - - Syntax errors - - Logic errors - - Security vulnerabilities - - Performance issues - - Anything else that looks wrong +```json +custom_commands=[{ + "name": "check", + "description": "Check for mistakes in my code", + "prompt": """\ + Please read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant: + - Syntax errors + - Logic errors + - Security vulnerabilities + - Performance issues + - Anything else that looks wrong - Once you find an error, please explain it as clearly as possible, but without using extra words. For example, instead of saying "I think there is a syntax error on line 5", you should say "Syntax error on line 5". Give your answer as one bullet point per mistake found.""") - ) - ] -) + Once you find an error, please explain it as clearly as possible, but without using extra words. For example, instead of saying "I think there is a syntax error on line 5", you should say "Syntax error on line 5". Give your answer as one bullet point per mistake found.""") + ) +}] ``` ## Custom Slash Commands diff --git a/docs/docs/languages/c#.md b/docs/docs/languages/csharp.md similarity index 100% rename from docs/docs/languages/c#.md rename to docs/docs/languages/csharp.md diff --git a/docs/docs/reference/Context Providers/diffcontextprovider.md b/docs/docs/reference/Context Providers/diffcontextprovider.md index fe40253c5..c2f4f4328 100644 --- a/docs/docs/reference/Context Providers/diffcontextprovider.md +++ b/docs/docs/reference/Context Providers/diffcontextprovider.md @@ -4,7 +4,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; Type '@diff' to reference all of the changes you've made to your current branch. This is useful if you want to summarize what you've done or ask for a general review of your work before committing. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/plugins/context_providers/diff.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/plugins/context_providers/diff.py) ## Properties diff --git a/docs/docs/reference/Context Providers/filecontextprovider.md b/docs/docs/reference/Context Providers/filecontextprovider.md index 79cfdfd01..f89fef58b 100644 --- a/docs/docs/reference/Context Providers/filecontextprovider.md +++ b/docs/docs/reference/Context Providers/filecontextprovider.md @@ -4,7 +4,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; The FileContextProvider is a ContextProvider that allows you to search files in the open workspace. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/plugins/context_providers/file.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/plugins/context_providers/file.py) ## Properties diff --git a/docs/docs/reference/Context Providers/filetreecontextprovider.md b/docs/docs/reference/Context Providers/filetreecontextprovider.md index 7c37385c4..97367dec1 100644 --- a/docs/docs/reference/Context Providers/filetreecontextprovider.md +++ b/docs/docs/reference/Context Providers/filetreecontextprovider.md @@ -4,7 +4,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; Type '@tree' to reference the contents of your current workspace. The LLM will be able to see the nested directory structure of your project. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/plugins/context_providers/filetree.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/plugins/context_providers/filetree.py) ## Properties diff --git a/docs/docs/reference/Context Providers/githubissuescontextprovider.md b/docs/docs/reference/Context Providers/githubissuescontextprovider.md index faf4611d4..c97f9f40a 100644 --- a/docs/docs/reference/Context Providers/githubissuescontextprovider.md +++ b/docs/docs/reference/Context Providers/githubissuescontextprovider.md @@ -4,7 +4,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; The GitHubIssuesContextProvider is a ContextProvider that allows you to search GitHub issues in a repo. Type '@issue' to reference the title and contents of an issue. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/plugins/context_providers/github.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/plugins/context_providers/github.py) ## Properties diff --git a/docs/docs/reference/Context Providers/googlecontextprovider.md b/docs/docs/reference/Context Providers/googlecontextprovider.md index 8dd33e567..4299608a5 100644 --- a/docs/docs/reference/Context Providers/googlecontextprovider.md +++ b/docs/docs/reference/Context Providers/googlecontextprovider.md @@ -4,7 +4,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; Type '@google' to reference the results of a Google search. For example, type "@google python tutorial" if you want to search and discuss ways of learning Python. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/plugins/context_providers/google.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/plugins/context_providers/google.py) ## Properties diff --git a/docs/docs/reference/Context Providers/searchcontextprovider.md b/docs/docs/reference/Context Providers/searchcontextprovider.md index ac735a007..3c2f00685 100644 --- a/docs/docs/reference/Context Providers/searchcontextprovider.md +++ b/docs/docs/reference/Context Providers/searchcontextprovider.md @@ -4,7 +4,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; Type '@search' to reference the results of codebase search, just like the results you would get from VS Code search. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/plugins/context_providers/search.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/plugins/context_providers/search.py) ## Properties diff --git a/docs/docs/reference/Context Providers/terminalcontextprovider.md b/docs/docs/reference/Context Providers/terminalcontextprovider.md index b7038c7b1..9909a0ad3 100644 --- a/docs/docs/reference/Context Providers/terminalcontextprovider.md +++ b/docs/docs/reference/Context Providers/terminalcontextprovider.md @@ -4,7 +4,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; Type '@terminal' to reference the contents of your IDE's terminal. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/plugins/context_providers/terminal.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/plugins/context_providers/terminal.py) ## Properties diff --git a/docs/docs/reference/Context Providers/urlcontextprovider.md b/docs/docs/reference/Context Providers/urlcontextprovider.md index e240e7ff6..d1af1e0e1 100644 --- a/docs/docs/reference/Context Providers/urlcontextprovider.md +++ b/docs/docs/reference/Context Providers/urlcontextprovider.md @@ -4,7 +4,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; Type '@url' to reference the contents of a URL. You can either reference preset URLs, or reference one dynamically by typing '@url https://example.com'. The text contents of the page will be fetched and used as context. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/plugins/context_providers/url.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/plugins/context_providers/url.py) ## Properties diff --git a/docs/docs/reference/Models/anthropicllm.md b/docs/docs/reference/Models/anthropicllm.md index 3dd6bdb07..e59caca83 100644 --- a/docs/docs/reference/Models/anthropicllm.md +++ b/docs/docs/reference/Models/anthropicllm.md @@ -17,7 +17,7 @@ config = ContinueConfig( Claude 2 is not yet publicly released. You can request early access [here](https://www.anthropic.com/earlyaccess). -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/anthropic.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/anthropic.py) ## Properties @@ -25,21 +25,13 @@ Claude 2 is not yet publicly released. You can request early access [here](https ### Inherited Properties - - - - - - - - - - - - + + + + diff --git a/docs/docs/reference/Models/ggml.md b/docs/docs/reference/Models/ggml.md index c3bbd665c..e01a828a6 100644 --- a/docs/docs/reference/Models/ggml.md +++ b/docs/docs/reference/Models/ggml.md @@ -19,12 +19,10 @@ config = ContinueConfig( ) ``` -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/ggml.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/ggml.py) ## Properties - - @@ -37,16 +35,8 @@ config = ContinueConfig( - - - - - - - - - - - - + + + + diff --git a/docs/docs/reference/Models/googlepalmapi.md b/docs/docs/reference/Models/googlepalmapi.md index 0c2acdbe8..acb5d8a95 100644 --- a/docs/docs/reference/Models/googlepalmapi.md +++ b/docs/docs/reference/Models/googlepalmapi.md @@ -18,7 +18,7 @@ config = ContinueConfig( ) ``` -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/google_palm_api.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/google_palm_api.py) ## Properties @@ -32,15 +32,7 @@ config = ContinueConfig( - - - - - - - - - - - + + + diff --git a/docs/docs/reference/Models/huggingfaceinferenceapi.md b/docs/docs/reference/Models/huggingfaceinferenceapi.md index e42199b7d..aa5893834 100644 --- a/docs/docs/reference/Models/huggingfaceinferenceapi.md +++ b/docs/docs/reference/Models/huggingfaceinferenceapi.md @@ -18,31 +18,21 @@ config = ContinueConfig( ) ``` -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/hf_inference_api.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/hf_inference_api.py) ## Properties - - ### Inherited Properties + - - - - - - - - - - - - - + + + + diff --git a/docs/docs/reference/Models/huggingfacetgi.md b/docs/docs/reference/Models/huggingfacetgi.md index 4e306d690..feb20ec79 100644 --- a/docs/docs/reference/Models/huggingfacetgi.md +++ b/docs/docs/reference/Models/huggingfacetgi.md @@ -4,11 +4,10 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/hf_tgi.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/hf_tgi.py) ## Properties - ### Inherited Properties @@ -18,16 +17,8 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; - - - - - - - - - - - - + + + + diff --git a/docs/docs/reference/Models/llamacpp.md b/docs/docs/reference/Models/llamacpp.md index ee991d3dc..225bf8208 100644 --- a/docs/docs/reference/Models/llamacpp.md +++ b/docs/docs/reference/Models/llamacpp.md @@ -23,11 +23,10 @@ config = ContinueConfig( ) ``` -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/llamacpp.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/llamacpp.py) ## Properties - @@ -38,16 +37,8 @@ config = ContinueConfig( - - - - - - - - - - - - + + + + diff --git a/docs/docs/reference/Models/ollama.md b/docs/docs/reference/Models/ollama.md index db0968c92..b5974bae4 100644 --- a/docs/docs/reference/Models/ollama.md +++ b/docs/docs/reference/Models/ollama.md @@ -15,11 +15,10 @@ config = ContinueConfig( ) ``` -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/ollama.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/ollama.py) ## Properties - ### Inherited Properties @@ -29,16 +28,8 @@ config = ContinueConfig( - - - - - - - - - - - - + + + + diff --git a/docs/docs/reference/Models/openai.md b/docs/docs/reference/Models/openai.md index c0151da0d..f5ad7eb6a 100644 --- a/docs/docs/reference/Models/openai.md +++ b/docs/docs/reference/Models/openai.md @@ -28,15 +28,14 @@ Options for serving models locally with an OpenAI-compatible server include: - [LocalAI](https://localai.io/basics/getting_started/) - [llama-cpp-python](https://github.com/abetlen/llama-cpp-python#web-server) -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/openai.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/openai.py) ## Properties - - + ### Inherited Properties @@ -47,15 +46,7 @@ Options for serving models locally with an OpenAI-compatible server include: - - - - - - - - - - - + + + diff --git a/docs/docs/reference/Models/openaifreetrial.md b/docs/docs/reference/Models/openaifreetrial.md index e7c51791f..540125261 100644 --- a/docs/docs/reference/Models/openaifreetrial.md +++ b/docs/docs/reference/Models/openaifreetrial.md @@ -25,7 +25,7 @@ The `OpenAIFreeTrial` class will automatically switch to using your API key inst These classes support any models available through the OpenAI API, assuming your API key has access, including "gpt-4", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", and "gpt-4-32k". -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/openai_free_trial.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/openai_free_trial.py) ## Properties @@ -39,16 +39,8 @@ These classes support any models available through the OpenAI API, assuming your - - - - - - - - - - - + + + diff --git a/docs/docs/reference/Models/queuedllm.md b/docs/docs/reference/Models/queuedllm.md index b981240b2..a835ab3d7 100644 --- a/docs/docs/reference/Models/queuedllm.md +++ b/docs/docs/reference/Models/queuedllm.md @@ -17,7 +17,7 @@ config = ContinueConfig( ) ``` -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/queued.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/queued.py) ## Properties @@ -31,16 +31,8 @@ config = ContinueConfig( - - - - - - - - - - - + + + diff --git a/docs/docs/reference/Models/replicatellm.md b/docs/docs/reference/Models/replicatellm.md index 4dc57cd31..f79beab59 100644 --- a/docs/docs/reference/Models/replicatellm.md +++ b/docs/docs/reference/Models/replicatellm.md @@ -20,7 +20,7 @@ config = ContinueConfig( If you don't specify the `model` parameter, it will default to `replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781`. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/replicate.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/replicate.py) ## Properties @@ -34,15 +34,7 @@ If you don't specify the `model` parameter, it will default to `replicate/llama- - - - - - - - - - - - - + + + + diff --git a/docs/docs/reference/Models/textgenwebui.md b/docs/docs/reference/Models/textgenwebui.md index f6cc5d33f..1f3725167 100644 --- a/docs/docs/reference/Models/textgenwebui.md +++ b/docs/docs/reference/Models/textgenwebui.md @@ -17,11 +17,10 @@ config = ContinueConfig( ) ``` -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/text_gen_webui.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/text_gen_webui.py) ## Properties - @@ -32,16 +31,8 @@ config = ContinueConfig( - - - - - - - - - - - - + + + + diff --git a/docs/docs/reference/Models/togetherllm.md b/docs/docs/reference/Models/togetherllm.md index 535cae6b2..3c69ae705 100644 --- a/docs/docs/reference/Models/togetherllm.md +++ b/docs/docs/reference/Models/togetherllm.md @@ -19,11 +19,10 @@ config = ContinueConfig( ) ``` -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/libs/llm/together.py) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/together.py) ## Properties - ### Inherited Properties @@ -34,15 +33,7 @@ config = ContinueConfig( - - - - - - - - - - - - + + + + diff --git a/docs/docs/reference/config.md b/docs/docs/reference/config.md index ad8efabc1..3ee31e83f 100644 --- a/docs/docs/reference/config.md +++ b/docs/docs/reference/config.md @@ -1,24 +1,22 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; -# ContinueConfig +# SerializedContinueConfig -Continue can be deeply customized by editing the `ContinueConfig` object in `~/.continue/config.py` (`%userprofile%\.continue\config.py` for Windows) on your machine. This class is instantiated from the config file for every new session. -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/core/config.py) + +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/core/config.py) ## Properties - - - - - - + + - - + + + + diff --git a/docs/src/components/ClassPropertyRef.tsx b/docs/src/components/ClassPropertyRef.tsx index 7246663bd..9f7060fb7 100644 --- a/docs/src/components/ClassPropertyRef.tsx +++ b/docs/src/components/ClassPropertyRef.tsx @@ -42,9 +42,12 @@ export default function ClassPropertyRef(props: ClassPropertyRefProps) { {props.default && ( {" "} - = {details.type === "string" && '"'} - {props.default} - {details.type === "string" && '"'} + ={" "} + + {details.type === "string" && '"'} + {props.default} + {details.type === "string" && '"'} + )} diff --git a/server/config.json b/server/config.json new file mode 100644 index 000000000..20e3674c2 --- /dev/null +++ b/server/config.json @@ -0,0 +1,52 @@ +{ + "models": [ + { + "title": "GPT-4", + "provider": "openai-free-trial", + "model": "gpt-4" + }, + { + "title": "GPT-3.5-Turbo", + "provider": "openai-free-trial", + "model": "gpt-3.5-turbo" + } + ], + "model_roles": { + "default": "GPT-4", + "summarize": "GPT-3.5-Turbo" + }, + "slash_commands": [ + { + "name": "edit", + "description": "Edit highlighted code", + "step": "EditHighlightedCodeStep" + }, + { + "name": "config", + "description": "Customize Continue", + "step": "OpenConfigStep" + }, + { + "name": "comment", + "description": "Write comments for the highlighted code", + "step": "CommentCodeStep" + }, + { + "name": "share", + "description": "Download and share this session", + "step": "ShareSessionStep" + }, + { + "name": "cmd", + "description": "Generate a shell command", + "step": "GenerateShellCommandStep" + } + ], + "custom_commands": [ + { + "name": "test", + "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": "Write unit tests for highlighted code" + } + ] +} diff --git a/server/continuedev/core/config.py b/server/continuedev/core/config.py index cd13f75bc..c189ee609 100644 --- a/server/continuedev/core/config.py +++ b/server/continuedev/core/config.py @@ -1,3 +1,4 @@ +import importlib.util import json import os from contextlib import contextmanager @@ -7,11 +8,8 @@ from pydantic import BaseModel, Field, validator from ..libs.llm.base import LLM from ..libs.llm.openai_free_trial import OpenAIFreeTrial -from ..libs.util.paths import ( - convertConfigImports, - getConfigFilePath, - getGlobalFolderPath, -) +from ..libs.util.logging import logger +from ..libs.util.paths import getConfigFilePath, getGlobalFolderPath from ..libs.util.telemetry import posthog_logger from ..models.llm import BaseCompletionOptions, RequestOptions from .config_utils.context import ( @@ -228,7 +226,7 @@ class SerializedContinueConfig(BaseModel): ) data_server_url: Optional[str] = Field( default="https://us-west1-autodebug.cloudfunctions.net", - description="The URL of the server where development data is sent. No data is sent unless a valid user token is provided.", + description="The URL of the server where development data is sent. No data is sent unless you have explicitly set the `user_token` property to a valid token that we have shared.", ) disable_summaries: Optional[bool] = Field( default=False, @@ -402,7 +400,7 @@ class ContinueConfig(BaseModel): ) data_server_url: Optional[str] = Field( default="https://us-west1-autodebug.cloudfunctions.net", - description="The URL of the server where development data is sent. No data is sent unless a valid user token is provided.", + description="The URL of the server where development data is sent. No data is sent unless you have explicitly set the `user_token` property to a valid token that we have shared.", ) disable_summaries: Optional[bool] = Field( default=False, @@ -440,29 +438,45 @@ class ContinueConfig(BaseModel): ) @staticmethod - def from_filepath(filepath: str, retry: bool = True) -> "ContinueConfig": - if filepath.endswith(".json"): - serialized_config = json.load(open(filepath)) - return ContinueConfig.from_serialized_config( - SerializedContinueConfig(**serialized_config) - ) - - # Use importlib to load the config file config.py at the given path + def modifier_from_filepath(filepath: str): try: - import importlib.util - spec = importlib.util.spec_from_file_location("config", filepath) config = importlib.util.module_from_spec(spec) spec.loader.exec_module(config) - return config.config - except ModuleNotFoundError as e: - # Check if the module was "continuedev.src" - if retry and e.name == "continuedev.src": - convertConfigImports(shorten=True) - return ContinueConfig.from_filepath(filepath, retry=False) - else: - raise e + if hasattr(config, "modify_config"): + return config.modify_config + + except Exception as e: + logger.warning(f"Failed to load config modifier from {filepath}: {e}") + return None + + return None + + @staticmethod + def from_filepath(filepath: str, retry: bool = True) -> "ContinueConfig": + if filepath.endswith(".json"): + serialized_config = json.load(open(filepath)) + initial_config = ContinueConfig.from_serialized_config( + SerializedContinueConfig(**serialized_config) + ) + if modifier := ContinueConfig.modifier_from_filepath( + filepath[: len(".json")] + ".py" + ): + try: + return modifier(initial_config) + except Exception as e: + logger.warning(f"Failed to modify config: {e}") + return initial_config + + return initial_config + + # Use importlib to load the config file config.py at the given path + spec = importlib.util.spec_from_file_location("config", filepath) + config = importlib.util.module_from_spec(spec) + spec.loader.exec_module(config) + + return config.config @staticmethod def load_default() -> "ContinueConfig": diff --git a/server/continuedev/core/config_utils/context.py b/server/continuedev/core/config_utils/context.py index 6e926911e..4305b69ed 100644 --- a/server/continuedev/core/config_utils/context.py +++ b/server/continuedev/core/config_utils/context.py @@ -1,6 +1,7 @@ from typing import Dict, Literal from ...plugins.context_providers.diff import DiffContextProvider +from ...plugins.context_providers.filetree import FileTreeContextProvider from ...plugins.context_providers.github import GitHubIssuesContextProvider from ...plugins.context_providers.google import GoogleContextProvider from ...plugins.context_providers.open_tabs import OpenTabsContextProvider @@ -16,6 +17,7 @@ ContextProviderName = Literal[ "google", "search", "url", + "tree", ] CONTEXT_PROVIDER_NAME_TO_CLASS = { @@ -26,6 +28,7 @@ CONTEXT_PROVIDER_NAME_TO_CLASS = { "google": GoogleContextProvider, "search": SearchContextProvider, "url": URLContextProvider, + "tree": FileTreeContextProvider, } CLASS_TO_CONTEXT_PROVIDER_NAME: Dict[str, ContextProviderName] = { @@ -36,4 +39,5 @@ CLASS_TO_CONTEXT_PROVIDER_NAME: Dict[str, ContextProviderName] = { "GoogleContextProvider": "google", "SearchContextProvider": "search", "URLContextProvider": "url", + "FileTreeContextProvider": "tree", } diff --git a/server/continuedev/core/config_utils/shared.py b/server/continuedev/core/config_utils/shared.py index a8de2b7c1..da645035f 100644 --- a/server/continuedev/core/config_utils/shared.py +++ b/server/continuedev/core/config_utils/shared.py @@ -28,8 +28,6 @@ StepName = Literal[ "GenerateShellCommandStep", ] -ContextProviderName = Literal["diff", "github"] - TemplateType = Literal["llama2", "alpaca", "zephyr", "phind", "anthropic", "chatml"] diff --git a/server/continuedev/libs/constants/default_config.py b/server/continuedev/libs/constants/default_config.py index 17cbfa286..1890b448d 100644 --- a/server/continuedev/libs/constants/default_config.py +++ b/server/continuedev/libs/constants/default_config.py @@ -1,82 +1,15 @@ default_config = """\ \"\"\" -This is the Continue configuration file. +config.py allows you to modify Continue programmatically instead of just using config.json. -See https://continue.dev/docs/customization to for documentation of the available options. +First, config.json is loaded. Then, if you have defined modify_config here, the function will be given the result of +loading config.json, and will return the final ContinueConfig to be used. \"\"\" -from continuedev.core.models import Models -from continuedev.core.config import CustomCommand, SlashCommand, ContinueConfig -from continuedev.libs.llm import OpenAIFreeTrial +from continuedev.core.config import ContinueConfig -from continuedev.plugins.context_providers import ( - DiffContextProvider, - TerminalContextProvider, - URLContextProvider, - GitHubIssuesContextProvider -) -from continuedev.plugins.steps import ( - CommentCodeStep, - EditHighlightedCodeStep, - GenerateShellCommandStep, - OpenConfigStep, -) -from continuedev.plugins.steps.share_session import ShareSessionStep +def modify_config(config: ContinueConfig) -> ContinueConfig: + config.completion_options.temperature = 0.5 + return config -config = ContinueConfig( - allow_anonymous_telemetry=True, - models=Models( - default=OpenAIFreeTrial(api_key="", model="gpt-4", title="GPT-4"), - summarize=OpenAIFreeTrial(api_key="", model="gpt-3.5-turbo") - ), - system_message=None, - temperature=0.5, - custom_commands=[ - CustomCommand( - name="test", - description="Write unit tests for highlighted code", - 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.", - ) - ], - slash_commands=[ - SlashCommand( - name="edit", - description="Edit highlighted code", - step=EditHighlightedCodeStep, - ), - SlashCommand( - name="config", - description="Customize Continue", - step=OpenConfigStep, - ), - SlashCommand( - name="comment", - description="Write comments for the highlighted code", - step=CommentCodeStep, - ), - SlashCommand( - name="share", - description="Download and share this session", - step=ShareSessionStep, - ), - SlashCommand( - name="cmd", - description="Generate a shell command", - step=GenerateShellCommandStep, - ) - ], - context_providers=[ - # GitHubIssuesContextProvider( - # repo_name="/", - # auth_token="" - # ), - DiffContextProvider(), - URLContextProvider( - preset_urls = [ - # Add any common urls you reference here so they appear in autocomplete - ] - ), - TerminalContextProvider(), - ], -) """ diff --git a/server/continuedev/models/reference/generate.py b/server/continuedev/models/reference/generate.py index 9afb5a708..a6647f1bd 100644 --- a/server/continuedev/models/reference/generate.py +++ b/server/continuedev/models/reference/generate.py @@ -79,7 +79,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; {dedent(schema.get("description", ""))} -[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/{filepath}) +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/{filepath}) ## Properties @@ -105,8 +105,9 @@ for module_name, module_title in LLM_MODULES: with open(f"docs/docs/reference/Models/{module_title.lower()}.md", "w") as f: f.write(markdown_docs) +# SerializedContinueConfig config_module = importlib.import_module("continuedev.core.config") -config_obj = getattr(config_module, "ContinueConfig") +config_obj = getattr(config_module, "SerializedContinueConfig") schema = config_obj.schema() markdown_docs = docs_from_schema(schema, "core/config.py") with open("docs/docs/reference/config.md", "w") as f: