From ef42d7604d0f556ff03c61dda39508b16467389b Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 15 Nov 2023 00:42:09 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20updating=20reference=20for=20mod?= =?UTF-8?q?els?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/reference/Models/anthropicllm.md | 20 ++-- docs/docs/reference/Models/ggml.md | 22 ++-- docs/docs/reference/Models/googlepalmapi.md | 23 ++-- .../Models/huggingfaceinferenceapi.md | 24 ++-- docs/docs/reference/Models/llamacpp.md | 22 ++-- docs/docs/reference/Models/ollama.md | 17 ++- docs/docs/reference/Models/openai.md | 25 ++--- docs/docs/reference/Models/openaifreetrial.md | 36 +++--- docs/docs/reference/Models/replicatellm.md | 23 ++-- docs/docs/reference/Models/textgenwebui.md | 19 ++-- docs/docs/reference/Models/togetherllm.md | 24 ++-- docs/docs/reference/config.md | 6 +- docs/docs/telemetry.md | 13 +-- docs/docs/walkthroughs/codebase-embeddings.md | 19 ++-- docs/docs/walkthroughs/codellama.md | 104 ++++++++---------- .../running-continue-without-internet.md | 7 +- server/continuedev/libs/llm/anthropic.py | 23 ++-- server/continuedev/libs/llm/ggml.py | 32 +++--- .../continuedev/libs/llm/google_palm_api.py | 23 ++-- .../continuedev/libs/llm/hf_inference_api.py | 28 ++--- server/continuedev/libs/llm/hf_tgi.py | 7 +- server/continuedev/libs/llm/hugging_face.py | 19 ---- server/continuedev/libs/llm/llamacpp.py | 26 ++--- server/continuedev/libs/llm/ollama.py | 19 ++-- server/continuedev/libs/llm/openai.py | 25 ++--- .../continuedev/libs/llm/openai_free_trial.py | 38 ++++--- server/continuedev/libs/llm/replicate.py | 24 ++-- server/continuedev/libs/llm/text_gen_webui.py | 19 ++-- server/continuedev/libs/llm/together.py | 24 ++-- .../continuedev/models/reference/generate.py | 3 +- server/continuedev/server/window_manager.py | 8 +- 31 files changed, 327 insertions(+), 395 deletions(-) delete mode 100644 server/continuedev/libs/llm/hugging_face.py diff --git a/docs/docs/reference/Models/anthropicllm.md b/docs/docs/reference/Models/anthropicllm.md index e59caca83..61e419b0b 100644 --- a/docs/docs/reference/Models/anthropicllm.md +++ b/docs/docs/reference/Models/anthropicllm.md @@ -2,17 +2,17 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; # AnthropicLLM -Import the `AnthropicLLM` class and set it as the default model: +To setup Anthropic, add the following to your `config.json` file: -```python title="~/.continue/config.py" -from continuedev.libs.llm.anthropic import AnthropicLLM - -config = ContinueConfig( - ... - models=Models( - default=AnthropicLLM(api_key="", model="claude-2") - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "Anthropic", + "provider": "anthropic", + "model": "claude-2", + "api_key": "YOUR_API_KEY" + }] +} ``` Claude 2 is not yet publicly released. You can request early access [here](https://www.anthropic.com/earlyaccess). diff --git a/docs/docs/reference/Models/ggml.md b/docs/docs/reference/Models/ggml.md index e01a828a6..7bfddcf9c 100644 --- a/docs/docs/reference/Models/ggml.md +++ b/docs/docs/reference/Models/ggml.md @@ -4,19 +4,17 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; See our [5 minute quickstart](https://github.com/continuedev/ggml-server-example) to run any model locally with ggml. While these models don't yet perform as well, they are free, entirely private, and run offline. -Once the model is running on localhost:8000, change `~/.continue/config.py` to look like this: +Once the model is running on localhost:8000, change `~/.continue/config.json` to look like this: -```python title="~/.continue/config.py" -from continuedev.libs.llm.ggml import GGML - -config = ContinueConfig( - ... - models=Models( - default=GGML( - max_context_length=2048, - server_url="http://localhost:8000") - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "GGML", + "provider": "openai-aiohttp", + "model": "MODEL_NAME", + "api_base": "http://localhost:8000" + }] +} ``` [View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/ggml.py) diff --git a/docs/docs/reference/Models/googlepalmapi.md b/docs/docs/reference/Models/googlepalmapi.md index acb5d8a95..eacb40958 100644 --- a/docs/docs/reference/Models/googlepalmapi.md +++ b/docs/docs/reference/Models/googlepalmapi.md @@ -2,20 +2,17 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; # GooglePaLMAPI -The Google PaLM API is currently in public preview, so production applications are not supported yet. However, you can [create an API key in Google MakerSuite](https://makersuite.google.com/u/2/app/apikey) and begin trying out the `chat-bison-001` model. Change `~/.continue/config.py` to look like this: +The Google PaLM API is currently in public preview, so production applications are not supported yet. However, you can [create an API key in Google MakerSuite](https://makersuite.google.com/u/2/app/apikey) and begin trying out the `chat-bison-001` model. Change `~/.continue/config.json` to look like this: -```python title="~/.continue/config.py" -from continuedev.core.models import Models -from continuedev.libs.llm.hf_inference_api import GooglePaLMAPI - -config = ContinueConfig( - ... - models=Models( - default=GooglePaLMAPI( - model="chat-bison-001" - api_key="", - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "Chat Bison", + "provider": "google-palm", + "model": "chat-bison-001", + "api_key": "YOUR_API_KEY" + }] +} ``` [View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/google_palm_api.py) diff --git a/docs/docs/reference/Models/huggingfaceinferenceapi.md b/docs/docs/reference/Models/huggingfaceinferenceapi.md index aa5893834..2b2d65ee6 100644 --- a/docs/docs/reference/Models/huggingfaceinferenceapi.md +++ b/docs/docs/reference/Models/huggingfaceinferenceapi.md @@ -2,20 +2,18 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; # HuggingFaceInferenceAPI -Hugging Face Inference API is a great option for newly released language models. Sign up for an account and add billing [here](https://huggingface.co/settings/billing), access the Inference Endpoints [here](https://ui.endpoints.huggingface.co), click on “New endpoint”, and fill out the form (e.g. select a model like [WizardCoder-Python-34B-V1.0](https://huggingface.co/WizardLM/WizardCoder-Python-34B-V1.0)), and then deploy your model by clicking “Create Endpoint”. Change `~/.continue/config.py` to look like this: +Hugging Face Inference API is a great option for newly released language models. Sign up for an account and add billing [here](https://huggingface.co/settings/billing), access the Inference Endpoints [here](https://ui.endpoints.huggingface.co), click on “New endpoint”, and fill out the form (e.g. select a model like [WizardCoder-Python-34B-V1.0](https://huggingface.co/WizardLM/WizardCoder-Python-34B-V1.0)), and then deploy your model by clicking “Create Endpoint”. Change `~/.continue/config.json` to look like this: -```python title="~/.continue/config.py" -from continuedev.core.models import Models -from continuedev.libs.llm.hf_inference_api import HuggingFaceInferenceAPI - -config = ContinueConfig( - ... - models=Models( - default=HuggingFaceInferenceAPI( - endpoint_url="", - hf_token="", - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "Hugging Face Inference API", + "provider": "huggingface-inference-api", + "model": "MODEL_NAME", + "api_key": "YOUR_HF_TOKEN", + "api_base": "INFERENCE_API_ENDPOINT_URL" + }] +} ``` [View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/hf_inference_api.py) diff --git a/docs/docs/reference/Models/llamacpp.md b/docs/docs/reference/Models/llamacpp.md index 225bf8208..6d5cdc0c3 100644 --- a/docs/docs/reference/Models/llamacpp.md +++ b/docs/docs/reference/Models/llamacpp.md @@ -8,19 +8,17 @@ Run the llama.cpp server binary to start the API server. If running on a remote .\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models\meta\llama\codellama-7b-instruct.Q8_0.gguf ``` -After it's up and running, change `~/.continue/config.py` to look like this: +After it's up and running, change `~/.continue/config.json` to look like this: -```python title="~/.continue/config.py" -from continuedev.libs.llm.llamacpp import LlamaCpp - -config = ContinueConfig( - ... - models=Models( - default=LlamaCpp( - max_context_length=4096, - server_url="http://localhost:8080") - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "Llama CPP", + "provider": "llama.cpp", + "model": "MODEL_NAME", + "api_base": "http://localhost:8080" + }] +} ``` [View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/llamacpp.py) diff --git a/docs/docs/reference/Models/ollama.md b/docs/docs/reference/Models/ollama.md index b5974bae4..63d96057b 100644 --- a/docs/docs/reference/Models/ollama.md +++ b/docs/docs/reference/Models/ollama.md @@ -4,15 +4,14 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; [Ollama](https://ollama.ai/) is an application for Mac and Linux that makes it easy to locally run open-source models, including Llama-2. Download the app from the website, and it will walk you through setup in a couple of minutes. You can also read more in their [README](https://github.com/jmorganca/ollama). Continue can then be configured to use the `Ollama` LLM class: -```python title="~/.continue/config.py" -from continuedev.libs.llm.ollama import Ollama - -config = ContinueConfig( - ... - models=Models( - default=Ollama(model="llama2") - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "Ollama", + "provider": "ollama", + "model": "llama2-7b", + }] +} ``` [View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/ollama.py) diff --git a/docs/docs/reference/Models/openai.md b/docs/docs/reference/Models/openai.md index f5ad7eb6a..046817fd4 100644 --- a/docs/docs/reference/Models/openai.md +++ b/docs/docs/reference/Models/openai.md @@ -4,21 +4,18 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; The OpenAI class can be used to access OpenAI models like gpt-4 and gpt-3.5-turbo. -If you are locally serving a model that uses an OpenAI-compatible server, you can simply change the `api_base` in the `OpenAI` class like this: +If you are locally serving a model that uses an OpenAI-compatible server, you can simply change the `api_base` like this: -```python title="~/.continue/config.py" -from continuedev.libs.llm.openai import OpenAI - -config = ContinueConfig( - ... - models=Models( - default=OpenAI( - api_key="EMPTY", - model="", - api_base="http://localhost:8000", # change to your server - ) - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "OpenAI-compatible server", + "provider": "openai", + "model": "MODEL_NAME", + "api_key": "EMPTY", + "api_base": "http://localhost:8000" + }] +} ``` 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 540125261..307a86ab1 100644 --- a/docs/docs/reference/Models/openaifreetrial.md +++ b/docs/docs/reference/Models/openaifreetrial.md @@ -7,24 +7,32 @@ With the `OpenAIFreeTrial` `LLM`, new users can try out Continue with GPT-4 usin Once you are using Continue regularly though, you will need to add an OpenAI API key that has access to GPT-4 by following these steps: 1. Copy your API key from https://platform.openai.com/account/api-keys -2. Open `~/.continue/config.py`. You can do this by using the '/config' command in Continue +2. Open `~/.continue/config.json`. You can do this by using the '/config' command in Continue 3. Change the default LLMs to look like this: -```python title="~/.continue/config.py" -API_KEY = "" -config = ContinueConfig( - ... - models=Models( - default=OpenAIFreeTrial(model="gpt-4", api_key=API_KEY), - summarize=OpenAIFreeTrial(model="gpt-3.5-turbo", api_key=API_KEY) - ) -) +```json title="~/.continue/config.json" +{ + "models": [ + { + "title": "GPT-4", + "provider": "openai", + "model": "gpt-4", + "api_key": "YOUR_API_KEY" + }, + { + "title": "GPT-3.5-Turbo", + "provider": "openai", + "model": "gpt-3.5-turbo", + "api_key": "YOUR_API_KEY" + } + ], + "model_roles": { + "default": "GPT-4", + "summarize": "GPT-3.5-Turbo" + } +} ``` -The `OpenAIFreeTrial` class will automatically switch to using your API key instead of ours. If you'd like to explicitly use one or the other, you can use the `ProxyServer` or `OpenAI` classes instead. - -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/openai_free_trial.py) ## Properties diff --git a/docs/docs/reference/Models/replicatellm.md b/docs/docs/reference/Models/replicatellm.md index f79beab59..27ea1d8c3 100644 --- a/docs/docs/reference/Models/replicatellm.md +++ b/docs/docs/reference/Models/replicatellm.md @@ -2,20 +2,17 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; # ReplicateLLM -Replicate is a great option for newly released language models or models that you've deployed through their platform. Sign up for an account [here](https://replicate.ai/), copy your API key, and then select any model from the [Replicate Streaming List](https://replicate.com/collections/streaming-language-models). Change `~/.continue/config.py` to look like this: +Replicate is a great option for newly released language models or models that you've deployed through their platform. Sign up for an account [here](https://replicate.ai/), copy your API key, and then select any model from the [Replicate Streaming List](https://replicate.com/collections/streaming-language-models). Change `~/.continue/config.json` to look like this: -```python title="~/.continue/config.py" -from continuedev.core.models import Models -from continuedev.libs.llm.replicate import ReplicateLLM - -config = ContinueConfig( - ... - models=Models( - default=ReplicateLLM( - model="replicate/codellama-13b-instruct:da5676342de1a5a335b848383af297f592b816b950a43d251a0a9edd0113604b", - api_key="my-replicate-api-key") - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "Replicate CodeLLama", + "provider": "replicate", + "model": "codellama-13b", + "api_key": "YOUR_API_KEY" + }] +} ``` If you don't specify the `model` parameter, it will default to `replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781`. diff --git a/docs/docs/reference/Models/textgenwebui.md b/docs/docs/reference/Models/textgenwebui.md index 1f3725167..2141bf5f5 100644 --- a/docs/docs/reference/Models/textgenwebui.md +++ b/docs/docs/reference/Models/textgenwebui.md @@ -4,17 +4,14 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; TextGenWebUI is a comprehensive, open-source language model UI and local server. You can set it up with an OpenAI-compatible server plugin, but if for some reason that doesn't work, you can use this class like so: -```python title="~/.continue/config.py" -from continuedev.libs.llm.text_gen_webui import TextGenWebUI - -config = ContinueConfig( - ... - models=Models( - default=TextGenWebUI( - model="", - ) - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "Text Generation WebUI", + "provider": "text-gen-webui", + "model": "MODEL_NAME" + }] +} ``` [View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/text_gen_webui.py) diff --git a/docs/docs/reference/Models/togetherllm.md b/docs/docs/reference/Models/togetherllm.md index 3c69ae705..b66f3fe82 100644 --- a/docs/docs/reference/Models/togetherllm.md +++ b/docs/docs/reference/Models/togetherllm.md @@ -2,21 +2,17 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; # TogetherLLM -The Together API is a cloud platform for running large AI models. You can sign up [here](https://api.together.xyz/signup), copy your API key on the initial welcome screen, and then hit the play button on any model from the [Together Models list](https://docs.together.ai/docs/models-inference). Change `~/.continue/config.py` to look like this: +The Together API is a cloud platform for running large AI models. You can sign up [here](https://api.together.xyz/signup), copy your API key on the initial welcome screen, and then hit the play button on any model from the [Together Models list](https://docs.together.ai/docs/models-inference). Change `~/.continue/config.json` to look like this: -```python title="~/.continue/config.py" -from continuedev.core.models import Models -from continuedev.libs.llm.together import TogetherLLM - -config = ContinueConfig( - ... - models=Models( - default=TogetherLLM( - api_key="", - model="togethercomputer/llama-2-13b-chat" - ) - ) -) +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "Together CodeLlama", + "provider": "together", + "model": "codellama-13b", + "api_key": "YOUR_API_KEY" + }] +} ``` [View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/together.py) diff --git a/docs/docs/reference/config.md b/docs/docs/reference/config.md index 3ee31e83f..814724737 100644 --- a/docs/docs/reference/config.md +++ b/docs/docs/reference/config.md @@ -1,6 +1,6 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; -# SerializedContinueConfig +# Configuration Options @@ -18,11 +18,11 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; - + -### Inherited Properties + diff --git a/docs/docs/telemetry.md b/docs/docs/telemetry.md index bd640f69a..c569481c3 100644 --- a/docs/docs/telemetry.md +++ b/docs/docs/telemetry.md @@ -4,7 +4,6 @@ description: Continue collects anonymous usage information keywords: [telemetry, anonymous, usage info, opt out] --- - # 🦔 Telemetry ## Overview @@ -25,13 +24,13 @@ All data is anonymous and cleaned of PII before being sent to PostHog. ## How to opt out -The `~/.continue` directory contains a `config.py` file that looks like this: +The `~/.continue` directory contains a `config.json` file that looks like this: -```python -config = ContinueConfig( - allow_anonymous_telemetry=True, +```json title="~/.continue/config.json" +{ + "allow_anonymous_telemetry": true, ... -) +} ``` -You can turn off anonymous telemetry by changing the value of `allow_anonymous_telemetry` to `False`. +You can turn off anonymous telemetry by changing the value of `allow_anonymous_telemetry` to `false`. diff --git a/docs/docs/walkthroughs/codebase-embeddings.md b/docs/docs/walkthroughs/codebase-embeddings.md index 58be0167c..1f638ce36 100644 --- a/docs/docs/walkthroughs/codebase-embeddings.md +++ b/docs/docs/walkthroughs/codebase-embeddings.md @@ -8,20 +8,15 @@ keywords: [talk, embeddings, codebase, experimental] Continue indexes your codebase so that when you input a message using Command+Enter, it can automatically pull in the most relevant context from throughout your workspace. This is done via a combination of embeddings-based retrieval and keyword search. By default, all embeddings are calculated locally with `all-MiniLM-L6-v2` and stored locally in `~/.continue/embeddings`. -The codebase retrieval feature allows the following customization options by editing `config.py` as follows: +The codebase retrieval feature allows the following customization options by editing `config.json` as follows: -```python -from continuedev.core.config import RetrievalSettings - -... - -config = ContinueConfig( - ... - retrieval_settings=RetrievalSettings( - n_retrieve=100, +```json title="~/.continue/config.json" +{ + "retrieval_settings": { + "n_retrieve": 100, ... - ) -) + } +} ``` ### `n_retrieve` diff --git a/docs/docs/walkthroughs/codellama.md b/docs/docs/walkthroughs/codellama.md index c45bdcc3c..7bf534337 100644 --- a/docs/docs/walkthroughs/codellama.md +++ b/docs/docs/walkthroughs/codellama.md @@ -14,80 +14,72 @@ If you haven't already installed Continue, you can do that [here](https://market 1. Create an account [here](https://api.together.xyz/signup) 2. Copy your API key that appears on the welcome screen -3. Click the "play" button on Code Llama Instruct (13B) on the [Together Models list](https://docs.together.ai/docs/models-inference) -4. Update your Continue config file to look like this: +3. Update your Continue config file like this: -```python -from continuedev.core.models import Models -from continuedev.libs.llm.together import TogetherLLM - -config = ContinueConfig( - ... - models=Models( - default=TogetherLLM( - api_key="", - model="togethercomputer/CodeLlama-13b-Instruct" - ) - ) -) +```json title="~/.continue/config.json" +{ + "models": [ + { + "title": "Code Llama", + "provider": "together", + "model": "togethercomputer/CodeLlama-13b-Instruct", + "api_key": "" + } + ] +} ``` ## Ollama 1. Download Ollama [here](https://ollama.ai/) (it should walk you through the rest of these steps) -2. Open a terminal and run `ollama run codellama`\* -3. Change your Continue config file to look like this: +2. Open a terminal and run `ollama run codellama` +3. Change your Continue config file like this: -```python -from continuedev.libs.llm.ollama import Ollama - -config = ContinueConfig( - ... - models=Models( - default=Ollama(model="codellama") - ) -) +```json title="~/.continue/config.json" +{ + "models": [ + { + "title": "Code Llama", + "provider": "ollama", + "model": "codellama-7b" + } + ] +} ``` -5. Reload the VS Code window for changes to take effect - -\*Only the 7b model is available right now. The others will be ready later today or tomorrow. - ## Replicate 1. Get your Replicate API key [here](https://replicate.ai/) -2. Change your Continue config file to look like this: +2. Change your Continue config file like this: -```python -from continuedev.core.models import Models -from continuedev.libs.llm.replicate import ReplicateLLM - -config = ContinueConfig( - ... - models=Models( - default=ReplicateLLM( - model="replicate/codellama-13b-instruct:da5676342de1a5a335b848383af297f592b816b950a43d251a0a9edd0113604b", - api_key="") - ) -) +```json title="~/.continue/config.json" +{ + "models": [ + { + "title": "Code Llama", + "provider": "replicate", + "model": "codellama-7b", + "api_key": "" + } + ] +} ``` -3. Reload the VS Code window for changes to take effect - ## FastChat API 1. Setup the FastChat API (https://github.com/lm-sys/FastChat) to use one of the Codellama models on Hugging Face (e.g: codellama/CodeLlama-7b-Instruct-hf). 2. Start the OpenAI compatible API (ref: https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md). -3. Change your Continue config file to look like this: +3. Change your Continue config file like this: -```python -config = ContinueConfig( - ... - models=Models(default=OpenAI( - model="CodeLlama-7b-Instruct-hf", - api_base="http://localhost:8000/v1" - )) -) +```json title="~/.continue/config.json" +{ + "models": [ + { + "title": "Code Llama", + "provider": "openai", + "model": "codellama-7b", + "api_base": "http://localhost:8000/v1" + } + ] +} ``` - -4. Reload the VS Code window for changes to take effect. diff --git a/docs/docs/walkthroughs/running-continue-without-internet.md b/docs/docs/walkthroughs/running-continue-without-internet.md index 1ae7b7a41..16d1cbe83 100644 --- a/docs/docs/walkthroughs/running-continue-without-internet.md +++ b/docs/docs/walkthroughs/running-continue-without-internet.md @@ -4,7 +4,6 @@ description: How to run Continue without Internet keywords: [no internet, air-gapped, local model] --- - # Running Continue without Internet Continue can be run even on an air-gapped computer if you use a local model. You'll have to make a few adjustments for this to work. @@ -12,6 +11,6 @@ Continue can be run even on an air-gapped computer if you use a local model. You 1. Download the latest .vsix file from the [Open VSX Registry](https://open-vsx.org/extension/Continue/continue) and [install it to VS Code](https://code.visualstudio.com/docs/editor/extension-marketplace#_install-from-a-vsix). 2. In VS Code settings, search "continue" and check the box that says "Manually Running Server". This will stop Continue from trying to kill and redownload the server binary. 3. Follow instructions to [run Continue manually](./manually-run-continue.md). -4. Open `~/.continue/config.py` and set `allow_anonymous_telemetry=False`. This will stop Continue from attempting requests to PostHog. -5. Also in `config.py`, set the default model to a local model. You can read about the available options [here](../customization/models.md). -6. Restart VS Code for changes to `config.py` to take effect. +4. Open `~/.continue/config.json` and set `"allow_anonymous_telemetry": false`. This will stop Continue from attempting requests to PostHog. +5. Also in `config.json`, set the default model to a local model. You can read about the available options [here](../customization/models.md). +6. Restart VS Code to ensure that the changes to `config.json` take effect. diff --git a/server/continuedev/libs/llm/anthropic.py b/server/continuedev/libs/llm/anthropic.py index 280b20d61..2b969aede 100644 --- a/server/continuedev/libs/llm/anthropic.py +++ b/server/continuedev/libs/llm/anthropic.py @@ -1,24 +1,23 @@ -from typing import Any, Callable, Coroutine, Optional +from typing import Any, Coroutine, Optional from anthropic import AI_PROMPT, HUMAN_PROMPT, AsyncAnthropic from .base import LLM, CompletionOptions -from .prompts.chat import anthropic_template_messages class AnthropicLLM(LLM): """ - Import the `AnthropicLLM` class and set it as the default model: + To setup Anthropic, add the following to your `config.json` file: - ```python title="~/.continue/config.py" - from continuedev.libs.llm.anthropic import AnthropicLLM - - config = ContinueConfig( - ... - models=Models( - default=AnthropicLLM(api_key="", model="claude-2") - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "Anthropic", + "provider": "anthropic", + "model": "claude-2", + "api_key": "YOUR_API_KEY" + }] + } ``` Claude 2 is not yet publicly released. You can request early access [here](https://www.anthropic.com/earlyaccess). diff --git a/server/continuedev/libs/llm/ggml.py b/server/continuedev/libs/llm/ggml.py index ce42a2a97..c9517aa3c 100644 --- a/server/continuedev/libs/llm/ggml.py +++ b/server/continuedev/libs/llm/ggml.py @@ -1,5 +1,5 @@ import json -from typing import Any, Callable, Coroutine, Dict, List, Literal, Optional +from typing import Any, Coroutine, List, Literal, Optional from pydantic import Field, validator @@ -7,27 +7,23 @@ from ...core.main import ChatMessage, ContinueCustomException from ..util.logging import logger from .base import LLM, CompletionOptions from .openai import CHAT_MODELS -from .prompts.chat import llama2_template_messages -from .prompts.edit import codellama_edit_prompt class GGML(LLM): """ See our [5 minute quickstart](https://github.com/continuedev/ggml-server-example) to run any model locally with ggml. While these models don't yet perform as well, they are free, entirely private, and run offline. - Once the model is running on localhost:8000, change `~/.continue/config.py` to look like this: + Once the model is running on localhost:8000, change `~/.continue/config.json` to look like this: - ```python title="~/.continue/config.py" - from continuedev.libs.llm.ggml import GGML - - config = ContinueConfig( - ... - models=Models( - default=GGML( - max_context_length=2048, - server_url="http://localhost:8000") - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "GGML", + "provider": "openai-aiohttp", + "model": "MODEL_NAME", + "api_base": "http://localhost:8000" + }] + } ``` """ @@ -96,7 +92,7 @@ class GGML(LLM): **args, }, headers=self.get_headers(), - proxy=self.proxy, + proxy=self.request_options.proxy, ) as resp: if resp.status != 200: raise Exception( @@ -135,7 +131,7 @@ class GGML(LLM): self.get_full_server_url(endpoint="chat/completions"), json={"messages": messages, "stream": True, **args}, headers=self.get_headers(), - proxy=self.proxy, + proxy=self.request_options.proxy, ) as resp: if resp.status != 200: detail = ( @@ -196,7 +192,7 @@ class GGML(LLM): **args, }, headers=self.get_headers(), - proxy=self.proxy, + proxy=self.request_options.proxy, ) as resp: if resp.status != 200: raise Exception( diff --git a/server/continuedev/libs/llm/google_palm_api.py b/server/continuedev/libs/llm/google_palm_api.py index 3379fefe0..ff26bb115 100644 --- a/server/continuedev/libs/llm/google_palm_api.py +++ b/server/continuedev/libs/llm/google_palm_api.py @@ -9,20 +9,17 @@ from .base import LLM class GooglePaLMAPI(LLM): """ - The Google PaLM API is currently in public preview, so production applications are not supported yet. However, you can [create an API key in Google MakerSuite](https://makersuite.google.com/u/2/app/apikey) and begin trying out the `chat-bison-001` model. Change `~/.continue/config.py` to look like this: + The Google PaLM API is currently in public preview, so production applications are not supported yet. However, you can [create an API key in Google MakerSuite](https://makersuite.google.com/u/2/app/apikey) and begin trying out the `chat-bison-001` model. Change `~/.continue/config.json` to look like this: - ```python title="~/.continue/config.py" - from continuedev.core.models import Models - from continuedev.libs.llm.hf_inference_api import GooglePaLMAPI - - config = ContinueConfig( - ... - models=Models( - default=GooglePaLMAPI( - model="chat-bison-001" - api_key="", - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "Chat Bison", + "provider": "google-palm", + "model": "chat-bison-001", + "api_key": "YOUR_API_KEY" + }] + } ``` """ diff --git a/server/continuedev/libs/llm/hf_inference_api.py b/server/continuedev/libs/llm/hf_inference_api.py index 96a733dde..25cfe3ed9 100644 --- a/server/continuedev/libs/llm/hf_inference_api.py +++ b/server/continuedev/libs/llm/hf_inference_api.py @@ -1,29 +1,25 @@ -from typing import Callable, Dict, List, Optional, Union +from typing import Optional from huggingface_hub import InferenceClient from pydantic import Field from .base import LLM, CompletionOptions -from .prompts.chat import llama2_template_messages -from .prompts.edit import codellama_edit_prompt class HuggingFaceInferenceAPI(LLM): """ - Hugging Face Inference API is a great option for newly released language models. Sign up for an account and add billing [here](https://huggingface.co/settings/billing), access the Inference Endpoints [here](https://ui.endpoints.huggingface.co), click on “New endpoint”, and fill out the form (e.g. select a model like [WizardCoder-Python-34B-V1.0](https://huggingface.co/WizardLM/WizardCoder-Python-34B-V1.0)), and then deploy your model by clicking “Create Endpoint”. Change `~/.continue/config.py` to look like this: + Hugging Face Inference API is a great option for newly released language models. Sign up for an account and add billing [here](https://huggingface.co/settings/billing), access the Inference Endpoints [here](https://ui.endpoints.huggingface.co), click on “New endpoint”, and fill out the form (e.g. select a model like [WizardCoder-Python-34B-V1.0](https://huggingface.co/WizardLM/WizardCoder-Python-34B-V1.0)), and then deploy your model by clicking “Create Endpoint”. Change `~/.continue/config.json` to look like this: - ```python title="~/.continue/config.py" - from continuedev.core.models import Models - from continuedev.libs.llm.hf_inference_api import HuggingFaceInferenceAPI - - config = ContinueConfig( - ... - models=Models( - default=HuggingFaceInferenceAPI( - endpoint_url="", - hf_token="", - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "Hugging Face Inference API", + "provider": "huggingface-inference-api", + "model": "MODEL_NAME", + "api_key": "YOUR_HF_TOKEN", + "api_base": "INFERENCE_API_ENDPOINT_URL" + }] + } ``` """ diff --git a/server/continuedev/libs/llm/hf_tgi.py b/server/continuedev/libs/llm/hf_tgi.py index a2f6ca3ce..2a08c856f 100644 --- a/server/continuedev/libs/llm/hf_tgi.py +++ b/server/continuedev/libs/llm/hf_tgi.py @@ -1,13 +1,10 @@ import json -from typing import Any, Callable, List, Optional +from typing import Any, Optional from pydantic import Field, validator -from ...core.main import ChatMessage from ..util.count_tokens import DEFAULT_MAX_TOKENS from .base import LLM, CompletionOptions -from .prompts.chat import llama2_template_messages -from .prompts.edit import codellama_edit_prompt class HuggingFaceTGI(LLM): @@ -43,7 +40,7 @@ class HuggingFaceTGI(LLM): f"{self.api_base}/generate_stream", json={"inputs": prompt, "parameters": args}, headers={"Content-Type": "application/json"}, - proxy=self.proxy, + proxy=self.request_options.proxy, ) as resp: async for line in resp.content.iter_any(): if line: diff --git a/server/continuedev/libs/llm/hugging_face.py b/server/continuedev/libs/llm/hugging_face.py deleted file mode 100644 index c2e934c09..000000000 --- a/server/continuedev/libs/llm/hugging_face.py +++ /dev/null @@ -1,19 +0,0 @@ -# TODO: This class is far out of date - -from transformers import AutoModelForCausalLM, AutoTokenizer - -from .llm import LLM - - -class HuggingFace(LLM): - def __init__(self, model_path: str = "Salesforce/codegen-2B-mono"): - self.model_path = model_path - self.tokenizer = AutoTokenizer.from_pretrained(model_path) - self.model = AutoModelForCausalLM.from_pretrained(model_path) - - def complete(self, prompt: str, **kwargs): - args = {"max_tokens": 100} - args.update(kwargs) - input_ids = self.tokenizer(prompt, return_tensors="pt").input_ids - generated_ids = self.model.generate(input_ids, max_length=args["max_tokens"]) - return self.tokenizer.decode(generated_ids[0], skip_special_tokens=True) diff --git a/server/continuedev/libs/llm/llamacpp.py b/server/continuedev/libs/llm/llamacpp.py index b1bd042dd..1ca5863ad 100644 --- a/server/continuedev/libs/llm/llamacpp.py +++ b/server/continuedev/libs/llm/llamacpp.py @@ -1,11 +1,9 @@ import json -from typing import Any, Callable, Dict, Optional +from typing import Any, Dict, Optional from pydantic import Field, validator from .base import LLM -from .prompts.chat import llama2_template_messages -from .prompts.edit import codellama_edit_prompt class LlamaCpp(LLM): @@ -16,19 +14,17 @@ class LlamaCpp(LLM): .\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models\meta\llama\codellama-7b-instruct.Q8_0.gguf ``` - After it's up and running, change `~/.continue/config.py` to look like this: + After it's up and running, change `~/.continue/config.json` to look like this: - ```python title="~/.continue/config.py" - from continuedev.libs.llm.llamacpp import LlamaCpp - - config = ContinueConfig( - ... - models=Models( - default=LlamaCpp( - max_context_length=4096, - server_url="http://localhost:8080") - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "Llama CPP", + "provider": "llama.cpp", + "model": "MODEL_NAME", + "api_base": "http://localhost:8080" + }] + } ``` """ diff --git a/server/continuedev/libs/llm/ollama.py b/server/continuedev/libs/llm/ollama.py index 7dca95069..e6fc4f425 100644 --- a/server/continuedev/libs/llm/ollama.py +++ b/server/continuedev/libs/llm/ollama.py @@ -1,5 +1,5 @@ import json -from typing import Any, Callable, Dict, Optional +from typing import Any, Dict, Optional from pydantic import Field, validator @@ -12,15 +12,14 @@ class Ollama(LLM): """ [Ollama](https://ollama.ai/) is an application for Mac and Linux that makes it easy to locally run open-source models, including Llama-2. Download the app from the website, and it will walk you through setup in a couple of minutes. You can also read more in their [README](https://github.com/jmorganca/ollama). Continue can then be configured to use the `Ollama` LLM class: - ```python title="~/.continue/config.py" - from continuedev.libs.llm.ollama import Ollama - - config = ContinueConfig( - ... - models=Models( - default=Ollama(model="llama2") - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "Ollama", + "provider": "ollama", + "model": "llama2-7b", + }] + } ``` """ diff --git a/server/continuedev/libs/llm/openai.py b/server/continuedev/libs/llm/openai.py index 04896a854..66c352639 100644 --- a/server/continuedev/libs/llm/openai.py +++ b/server/continuedev/libs/llm/openai.py @@ -41,21 +41,18 @@ class OpenAI(LLM): """ The OpenAI class can be used to access OpenAI models like gpt-4 and gpt-3.5-turbo. - If you are locally serving a model that uses an OpenAI-compatible server, you can simply change the `api_base` in the `OpenAI` class like this: + If you are locally serving a model that uses an OpenAI-compatible server, you can simply change the `api_base` like this: - ```python title="~/.continue/config.py" - from continuedev.libs.llm.openai import OpenAI - - config = ContinueConfig( - ... - models=Models( - default=OpenAI( - api_key="EMPTY", - model="", - api_base="http://localhost:8000", # change to your server - ) - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "OpenAI-compatible server", + "provider": "openai", + "model": "MODEL_NAME", + "api_key": "EMPTY", + "api_base": "http://localhost:8000" + }] + } ``` Options for serving models locally with an OpenAI-compatible server include: diff --git a/server/continuedev/libs/llm/openai_free_trial.py b/server/continuedev/libs/llm/openai_free_trial.py index 09f45e997..e44c5f1c0 100644 --- a/server/continuedev/libs/llm/openai_free_trial.py +++ b/server/continuedev/libs/llm/openai_free_trial.py @@ -1,9 +1,9 @@ from typing import List, Optional -from ..util.count_tokens import CONTEXT_LENGTH_FOR_MODEL from pydantic import validator from ...core.main import ChatMessage +from ..util.count_tokens import CONTEXT_LENGTH_FOR_MODEL from .base import LLM from .openai import OpenAI from .proxy_server import ProxyServer @@ -16,23 +16,31 @@ class OpenAIFreeTrial(LLM): Once you are using Continue regularly though, you will need to add an OpenAI API key that has access to GPT-4 by following these steps: 1. Copy your API key from https://platform.openai.com/account/api-keys - 2. Open `~/.continue/config.py`. You can do this by using the '/config' command in Continue + 2. Open `~/.continue/config.json`. You can do this by using the '/config' command in Continue 3. Change the default LLMs to look like this: - ```python title="~/.continue/config.py" - API_KEY = "" - config = ContinueConfig( - ... - models=Models( - default=OpenAIFreeTrial(model="gpt-4", api_key=API_KEY), - summarize=OpenAIFreeTrial(model="gpt-3.5-turbo", api_key=API_KEY) - ) - ) + ```json title="~/.continue/config.json" + { + "models": [ + { + "title": "GPT-4", + "provider": "openai", + "model": "gpt-4", + "api_key": "YOUR_API_KEY" + }, + { + "title": "GPT-3.5-Turbo", + "provider": "openai", + "model": "gpt-3.5-turbo", + "api_key": "YOUR_API_KEY" + } + ], + "model_roles": { + "default": "GPT-4", + "summarize": "GPT-3.5-Turbo" + } + } ``` - - The `OpenAIFreeTrial` class will automatically switch to using your API key instead of ours. If you'd like to explicitly use one or the other, you can use the `ProxyServer` or `OpenAI` classes instead. - - 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". """ llm: Optional[LLM] = None diff --git a/server/continuedev/libs/llm/replicate.py b/server/continuedev/libs/llm/replicate.py index e7c1e430f..cce21c4ef 100644 --- a/server/continuedev/libs/llm/replicate.py +++ b/server/continuedev/libs/llm/replicate.py @@ -6,25 +6,21 @@ from pydantic import Field from ...core.main import ChatMessage from .base import LLM -from .prompts.edit import codellama_edit_prompt class ReplicateLLM(LLM): """ - Replicate is a great option for newly released language models or models that you've deployed through their platform. Sign up for an account [here](https://replicate.ai/), copy your API key, and then select any model from the [Replicate Streaming List](https://replicate.com/collections/streaming-language-models). Change `~/.continue/config.py` to look like this: + Replicate is a great option for newly released language models or models that you've deployed through their platform. Sign up for an account [here](https://replicate.ai/), copy your API key, and then select any model from the [Replicate Streaming List](https://replicate.com/collections/streaming-language-models). Change `~/.continue/config.json` to look like this: - ```python title="~/.continue/config.py" - from continuedev.core.models import Models - from continuedev.libs.llm.replicate import ReplicateLLM - - config = ContinueConfig( - ... - models=Models( - default=ReplicateLLM( - model="replicate/codellama-13b-instruct:da5676342de1a5a335b848383af297f592b816b950a43d251a0a9edd0113604b", - api_key="my-replicate-api-key") - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "Replicate CodeLLama", + "provider": "replicate", + "model": "codellama-13b", + "api_key": "YOUR_API_KEY" + }] + } ``` If you don't specify the `model` parameter, it will default to `replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781`. diff --git a/server/continuedev/libs/llm/text_gen_webui.py b/server/continuedev/libs/llm/text_gen_webui.py index 2ddb94d33..3875d53ae 100644 --- a/server/continuedev/libs/llm/text_gen_webui.py +++ b/server/continuedev/libs/llm/text_gen_webui.py @@ -12,17 +12,14 @@ class TextGenWebUI(LLM): """ TextGenWebUI is a comprehensive, open-source language model UI and local server. You can set it up with an OpenAI-compatible server plugin, but if for some reason that doesn't work, you can use this class like so: - ```python title="~/.continue/config.py" - from continuedev.libs.llm.text_gen_webui import TextGenWebUI - - config = ContinueConfig( - ... - models=Models( - default=TextGenWebUI( - model="", - ) - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "Text Generation WebUI", + "provider": "text-gen-webui", + "model": "MODEL_NAME" + }] + } ``` """ diff --git a/server/continuedev/libs/llm/together.py b/server/continuedev/libs/llm/together.py index 48e7df876..ae2d5b4d8 100644 --- a/server/continuedev/libs/llm/together.py +++ b/server/continuedev/libs/llm/together.py @@ -11,21 +11,17 @@ from .base import LLM class TogetherLLM(LLM): """ - The Together API is a cloud platform for running large AI models. You can sign up [here](https://api.together.xyz/signup), copy your API key on the initial welcome screen, and then hit the play button on any model from the [Together Models list](https://docs.together.ai/docs/models-inference). Change `~/.continue/config.py` to look like this: + The Together API is a cloud platform for running large AI models. You can sign up [here](https://api.together.xyz/signup), copy your API key on the initial welcome screen, and then hit the play button on any model from the [Together Models list](https://docs.together.ai/docs/models-inference). Change `~/.continue/config.json` to look like this: - ```python title="~/.continue/config.py" - from continuedev.core.models import Models - from continuedev.libs.llm.together import TogetherLLM - - config = ContinueConfig( - ... - models=Models( - default=TogetherLLM( - api_key="", - model="togethercomputer/llama-2-13b-chat" - ) - ) - ) + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "Together CodeLlama", + "provider": "together", + "model": "codellama-13b", + "api_key": "YOUR_API_KEY" + }] + } ``` """ diff --git a/server/continuedev/models/reference/generate.py b/server/continuedev/models/reference/generate.py index a6647f1bd..792526ad5 100644 --- a/server/continuedev/models/reference/generate.py +++ b/server/continuedev/models/reference/generate.py @@ -85,7 +85,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; {properties} -### Inherited Properties +{"### Inherited Properties" if inherited_properties else ""} {inherited_properties}""" ) @@ -109,6 +109,7 @@ for module_name, module_title in LLM_MODULES: config_module = importlib.import_module("continuedev.core.config") config_obj = getattr(config_module, "SerializedContinueConfig") schema = config_obj.schema() +schema["title"] = "Configuration Options" markdown_docs = docs_from_schema(schema, "core/config.py") with open("docs/docs/reference/config.md", "w") as f: f.write(markdown_docs) diff --git a/server/continuedev/server/window_manager.py b/server/continuedev/server/window_manager.py index 5c36684e6..be6cd8f55 100644 --- a/server/continuedev/server/window_manager.py +++ b/server/continuedev/server/window_manager.py @@ -11,7 +11,7 @@ from ..libs.index.build_index import build_index from ..libs.util.create_async_task import create_async_task from ..libs.util.devdata import dev_data_logger from ..libs.util.logging import logger -from ..libs.util.paths import getConfigFilePath, getDiffsFolderPath +from ..libs.util.paths import getConfigFilePath, getDiffsFolderPath, migration from ..libs.util.telemetry import posthog_logger from ..plugins.context_providers.file import FileContextProvider from ..plugins.context_providers.highlighted_code import HighlightedCodeContextProvider @@ -89,6 +89,12 @@ class Window: async def load( self, config: Optional[ContinueConfig] = None, only_reloading: bool = False ): + async with migration("config_json_001"): + if self.ide is not None: + await self.ide.showMessage( + f"Continue has migrated to using a JSON config file (config.json). To learn more, visit https://continue.dev/docs/config-file-migration." + ) + # Need a non-step way of sending a notification to the GUI. Fine to be displayed similarly # formatted_err = "\n".join(traceback.format_exception(e, e, e.__traceback__))