diff --git a/docs/docs/customization/overview.md b/docs/docs/customization/overview.md index f87cbc286..c81e4fc89 100644 --- a/docs/docs/customization/overview.md +++ b/docs/docs/customization/overview.md @@ -10,7 +10,7 @@ Continue can be deeply customized by editing `~/.continue/config.json` (`%userpr Currently, you can customize the following: -- [Models](./models.md) - Use Continue with any LLM, including local models, Azure OpenAI service, any OpenAI-compatible API, and more. +- [Models](../model-setup/select-model.md) and [proivders](../model-setup/select-provider.md) - [Context Providers](./context-providers.md) - Just type '@' to easily add attachments to your prompt. Define which sources you want to easily reference, including GitHub Issues, terminal output, and preset URLs. - [Slash Commands](./slash-commands.md) - Call custom prompts or programs written with our SDK by typing `/`. -- [Other Configuration](./other-configuration.md) - Configure other settings like the system message and temperature. +- [Other Configuration](./other-configuration.md) - Configure other settings like the system message and temperature. \ No newline at end of file diff --git a/docs/docs/customization/models.md b/docs/docs/model-setup/configuration.md similarity index 66% rename from docs/docs/customization/models.md rename to docs/docs/model-setup/configuration.md index f579afa6d..cb7b73d40 100644 --- a/docs/docs/customization/models.md +++ b/docs/docs/model-setup/configuration.md @@ -1,32 +1,10 @@ --- -title: Models -description: Swap out different LLM providers -keywords: [openai, anthropic, PaLM, ollama, ggml] +title: Configuration +description: Configure your LLM and model provider +keywords: [configure, llm, provider] --- -# 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.json`. Once you've done this, you will be able to switch between them with the model selection dropdown. - -Commercial Models - -- [OpenAIFreeTrial](../reference/Models/openaifreetrial.md) (default) - Use gpt-4 or gpt-3.5-turbo free with our API key, or with your API key. gpt-4 is probably the most capable model of all options. -- [OpenAI](../reference/Models/openai.md) - Use any OpenAI model with your own key. Can also change the base URL if you have a server that uses the OpenAI API format, including using the Azure OpenAI service, LocalAI, etc. -- [AnthropicLLM](../reference/Models/anthropicllm.md) - Use claude-2 with your Anthropic API key. Claude 2 is also highly capable, and has a 100,000 token context window. -- [GooglePaLMAPI](../reference/Models/googlepalmapi.md) - Try out the `chat-bison-001` model, which is currently in public preview, after creating an API key in [Google MakerSuite](https://makersuite.google.com/u/2/app/apikey) - -Local Models - -- [Ollama](../reference/Models/ollama.md) - If you are on Mac or Linux, Ollama is the simplest way to run open-source models like Code Llama. -- [OpenAI](../reference/Models/openai.md) - If you have access to an OpenAI-compatible server (e.g. llama-cpp-python, LocalAI, FastChat, TextGenWebUI, etc.), you can use the `OpenAI` class and just change the base URL. -- [GGML](../reference/Models/ggml.md) - An alternative way to connect to OpenAI-compatible servers. Will use `aiohttp` directly instead of the `openai` Python package. -- [LlamaCpp](../reference/Models/llamacpp.md) - Build llama.cpp from source and use its built-in API server. - -Open-Source Models (not local) - -- [TogetherLLM](../reference/Models/togetherllm.md) - Use any model from the [Together Models list](https://docs.together.ai/docs/inference-models) with your Together API key. -- [ReplicateLLM](../reference/Models/replicatellm.md) - Use any open-source model from the [Replicate Streaming List](https://replicate.com/collections/streaming-language-models) with your Replicate API key. -- [HuggingFaceInferenceAPI](../reference/Models/huggingfaceinferenceapi.md) - Use any open-source model from the [Hugging Face Inference API](https://huggingface.co/inference-api) with your Hugging Face token. +# Configuration ## Change the default LLM @@ -97,7 +75,7 @@ If by chance the provider has the exact same API interface as OpenAI, the `OpenA 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"]`. -If you want to create an entirely new chat template, this can be done in [config.py](./code-config.md) by defining a function and adding it to the `template_messages` property of your `LLM`. Here is an example of `template_messages` for the Alpaca/Vicuna format: +If you want to create an entirely new chat template, this can be done in [config.py](../customization/code-config.md) by defining a function and adding it to the `template_messages` property of your `LLM`. Here is an example of `template_messages` for the Alpaca/Vicuna format: ```python def template_alpaca_messages(msgs: List[Dict[str, str]]) -> str: @@ -120,7 +98,7 @@ It can then be used like this: ```python title="~/.continue/config.py" def modify_config(config: ContinueConfig) -> ContinueConfig: - config.models[0].template_messages = template_alpaca_messages + config.models.default.template_messages = template_alpaca_messages return config ``` @@ -150,7 +128,7 @@ It can then be used like this in `config.py`: ```python title="~/.continue/config.py" def modify_config(config: ContinueConfig) -> ContinueConfig: - config.models[0].prompt_templates["edit"] = "" + config.models.edit.prompt_templates["edit"] = "" return config ``` diff --git a/docs/docs/model-setup/select-model.md b/docs/docs/model-setup/select-model.md new file mode 100644 index 000000000..e1aca5ad6 --- /dev/null +++ b/docs/docs/model-setup/select-model.md @@ -0,0 +1,45 @@ +--- +title: Select model +description: Swap out different LLMs +keywords: [gpt-4, codellama, claude-2, wizardcoder, wizardcoder] +--- + +# Select a Large Language Model + +Continue makes it easy to swap out different LLMs. You can either click the "+" button next to the model dropdown to configure in the GUI or manually add them to your `config.json`. Once you've done this, you will be able to switch between them in the model selection dropdown. + +**In addition to selecting a LLM, you will need to figure out [what model provider to use](./select-provider.md).** + +## Open-source LLMs + +Models available for configuration in the GUI: +- [Code Llama-Instruct-7B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#1-code-llama) +- [Code Llama-Instruct-13B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#1-code-llama) +- [Code Llama-Instruct-34B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#1-code-llama) +- [WizardCoder-7B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#2-wizardcoder) +- [WizardCoder-13B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#2-wizardcoder) +- [WizardCoder-34B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#2-wizardcoder) +- [Phind-CodeLlama-34B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#3-phind-codellama) +- [Mistral-Instruct-7B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#4-mistral) +- [StarCoder-15B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#5-starcoder) +- [Deepseek-Coder-1.3b-Instruct](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#6-deepseek-coder) +- [Deepseek-Coder-6.7b-Instruct](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#6-deepseek-coder) +- [Deepseek-Coder-33b-Instruct](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#6-deepseek-coder) +- [Llama2-Chat-7B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#7-llama2) +- [Llama2-Chat-13B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#7-llama2) +- [Llama2-Chat-70B](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#7-llama2) +- [CodeUp-13B](https://huggingface.co/deepse/CodeUp-Llama-2-13b-chat-hf) +- [Zephyr-7B](https://huggingface.co/huggingfaceh4/zephyr-7b-beta) + +**You can also use other open-source models**, but you will need to manually add them to your `config.json`. + +## Commercial LLMs + +Models available for configuration in the GUI: +- [GPT-4](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#1-gpt-4) +- [GPT-4-Turbo](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#2-gpt-4-turbo) +- [GPT-3.5-Turbo](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#3-gpt-35-turbo) +- [Claude-2](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#4-claude-2) +- [PaLM-2](https://github.com/continuedev/what-llm-to-use/blob/main/README.md#5-palm-2) + +**You can also use other commercial models**, but you will need to manually add them to your `config.json`. \ No newline at end of file diff --git a/docs/docs/model-setup/select-provider.md b/docs/docs/model-setup/select-provider.md new file mode 100644 index 000000000..bc7e97979 --- /dev/null +++ b/docs/docs/model-setup/select-provider.md @@ -0,0 +1,53 @@ +--- +title: Select a provider +description: Swap out different LLM providers +keywords: [openai, anthropic, PaLM, ollama, ggml] +--- + +# Select a model provider + +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 GUI or manually add them to your `config.json`. Once you've done this, you will be able to switch between them in the model selection dropdown. + +**In addition to selecting a model provider, you will need to figure out [what LLM to use](./select-model.md).** + +## Local + +You can run a model on your local computer using: +- [Ollama](../reference/Model%20Providers/ollama.md) +- [LM Studio](../reference/Model%20Providers/ggml.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) +- [FastChat](../reference/Model%20Providers/openai.md) (OpenAI compatible server) +- [llama-cpp-python](../reference/Model%20Providers/openai.md) (OpenAI compatible server) + +Once you have it running, you will need to configure it in the GUI or manually add it to your `config.json`. + +## Cloud + +You can deploy a model in your [AWS](https://github.com/continuedev/deploy-os-code-llm#aws), [GCP](https://github.com/continuedev/deploy-os-code-llm#gcp), [Azure](https://github.com/continuedev/deploy-os-code-llm#azure), or [other clouds](https://github.com/continuedev/deploy-os-code-llm#others-2) using: +- [HuggingFace TGI](https://github.com/continuedev/deploy-os-code-llm#tgi) +- [vLLM](https://github.com/continuedev/deploy-os-code-llm#vllm) +- [SkyPilot](https://github.com/continuedev/deploy-os-code-llm#skypilot) +- [Anyscale Private Endpoints](https://github.com/continuedev/deploy-os-code-llm#anyscale-private-endpoints) (OpenAI compatible API) + +Once you have it deloyed, you will need to wire up a new LLM class and manually add it to your `config.json`. This requires you to implement the `stream_complete`, `complete`, and `stream_chat` methods. You can see examples in [`server/continuedev/libs/llm`](https://github.com/continuedev/continue/tree/main/server/continuedev/libs/llm). However, if the provider has the exact same API interface as OpenAI, the `OpenAI` class will work for you. You will just need to change the `api_base` parameter. + +## SaaS + +### Open-source LLMs + +You can deploy open-source LLMs on a service using: +- [Together](../reference/Model%20Providers/togetherllm.md) +- [HuggingFace Inference Endpoints](../reference/Model%20Providers/huggingfaceinferenceapi.md) +- [Anyscale Endpoints](../reference/Model%20Providers/openai.md) (OpenAI compatible API) +- [Replicate](../reference/Model%20Providers/replicatellm.md) + +### Commercial LLMs + +You can use commercial LLMs via APIs using: +- [OpenAI API](../reference/Model%20Providers/openai.md) +- [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) \ No newline at end of file diff --git a/docs/docs/reference/Context Providers/filecontextprovider.md b/docs/docs/reference/Context Providers/filecontextprovider.md index f89fef58b..289ad7b76 100644 --- a/docs/docs/reference/Context Providers/filecontextprovider.md +++ b/docs/docs/reference/Context Providers/filecontextprovider.md @@ -15,6 +15,6 @@ The FileContextProvider is a ContextProvider that allows you to search files in - + diff --git a/docs/docs/reference/Models/anthropicllm.md b/docs/docs/reference/Model Providers/anthropicllm.md similarity index 88% rename from docs/docs/reference/Models/anthropicllm.md rename to docs/docs/reference/Model Providers/anthropicllm.md index 61e419b0b..97af029d4 100644 --- a/docs/docs/reference/Models/anthropicllm.md +++ b/docs/docs/reference/Model Providers/anthropicllm.md @@ -30,8 +30,8 @@ Claude 2 is not yet publicly released. You can request early access [here](https - + - + diff --git a/docs/docs/reference/Models/ggml.md b/docs/docs/reference/Model Providers/ggml.md similarity index 81% rename from docs/docs/reference/Models/ggml.md rename to docs/docs/reference/Model Providers/ggml.md index 7bfddcf9c..9aae2ed8f 100644 --- a/docs/docs/reference/Models/ggml.md +++ b/docs/docs/reference/Model Providers/ggml.md @@ -4,6 +4,8 @@ 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. +You can also use this class for [LM Studio](https://lmstudio.ai). + Once the model is running on localhost:8000, change `~/.continue/config.json` to look like this: ```json title="~/.continue/config.json" @@ -24,6 +26,8 @@ Once the model is running on localhost:8000, change `~/.continue/config.json` to + + ### Inherited Properties @@ -33,8 +37,8 @@ Once the model is running on localhost:8000, change `~/.continue/config.json` to - + - + diff --git a/docs/docs/reference/Models/googlepalmapi.md b/docs/docs/reference/Model Providers/googlepalmapi.md similarity index 89% rename from docs/docs/reference/Models/googlepalmapi.md rename to docs/docs/reference/Model Providers/googlepalmapi.md index eacb40958..e10091ebe 100644 --- a/docs/docs/reference/Models/googlepalmapi.md +++ b/docs/docs/reference/Model Providers/googlepalmapi.md @@ -29,7 +29,7 @@ The Google PaLM API is currently in public preview, so production applications a - + - + diff --git a/docs/docs/reference/Models/huggingfaceinferenceapi.md b/docs/docs/reference/Model Providers/huggingfaceinferenceapi.md similarity index 90% rename from docs/docs/reference/Models/huggingfaceinferenceapi.md rename to docs/docs/reference/Model Providers/huggingfaceinferenceapi.md index 2b2d65ee6..8d7ea897f 100644 --- a/docs/docs/reference/Models/huggingfaceinferenceapi.md +++ b/docs/docs/reference/Model Providers/huggingfaceinferenceapi.md @@ -30,7 +30,7 @@ Hugging Face Inference API is a great option for newly released language models. - + - + diff --git a/docs/docs/reference/Models/huggingfacetgi.md b/docs/docs/reference/Model Providers/huggingfacetgi.md similarity index 88% rename from docs/docs/reference/Models/huggingfacetgi.md rename to docs/docs/reference/Model Providers/huggingfacetgi.md index feb20ec79..919199fd2 100644 --- a/docs/docs/reference/Models/huggingfacetgi.md +++ b/docs/docs/reference/Model Providers/huggingfacetgi.md @@ -17,8 +17,8 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; - + - + diff --git a/docs/docs/reference/Models/llamacpp.md b/docs/docs/reference/Model Providers/llamacpp.md similarity index 83% rename from docs/docs/reference/Models/llamacpp.md rename to docs/docs/reference/Model Providers/llamacpp.md index 6d5cdc0c3..d1b494409 100644 --- a/docs/docs/reference/Models/llamacpp.md +++ b/docs/docs/reference/Model Providers/llamacpp.md @@ -25,7 +25,7 @@ After it's up and running, change `~/.continue/config.json` to look like this: ## Properties - + ### Inherited Properties @@ -35,8 +35,8 @@ After it's up and running, change `~/.continue/config.json` to look like this: - + - + diff --git a/docs/docs/reference/Model Providers/llamafile.md b/docs/docs/reference/Model Providers/llamafile.md new file mode 100644 index 000000000..855e32770 --- /dev/null +++ b/docs/docs/reference/Model Providers/llamafile.md @@ -0,0 +1,38 @@ +import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + +# Llamafile + +A [llamafile](https://github.com/Mozilla-Ocho/llamafile#readme) is a self-contained binary that can run an open-source LLM. You can configure this provider in your config.json as follows: + +```json title="~/.continue/config.json" +{ + "models": [{ + "title": "Llamafile", + "provider": "llamafile", + "model": "mistral-7b", + }] +} +``` + +Optionally, you can set the `llamafile_command` property, which will be run to start the llamafile if it isn't already running on port 8080. Be sure to use an absolute path to the llamafile binary. For example: `/Users/yourusername/mistral-7b-instruct-v0.1-Q4_K_M-server.llamafile`. + +[View the source](https://github.com/continuedev/continue/blob/main/server/continuedev/libs/llm/llamafile.py) + +## Properties + + + + + +### Inherited Properties + + + + + + + + + + + diff --git a/docs/docs/reference/Models/ollama.md b/docs/docs/reference/Model Providers/ollama.md similarity index 89% rename from docs/docs/reference/Models/ollama.md rename to docs/docs/reference/Model Providers/ollama.md index 63d96057b..ead7be799 100644 --- a/docs/docs/reference/Models/ollama.md +++ b/docs/docs/reference/Model Providers/ollama.md @@ -27,8 +27,8 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; - + - + diff --git a/docs/docs/reference/Models/openai.md b/docs/docs/reference/Model Providers/openai.md similarity index 72% rename from docs/docs/reference/Models/openai.md rename to docs/docs/reference/Model Providers/openai.md index 046817fd4..5d8c3af71 100644 --- a/docs/docs/reference/Models/openai.md +++ b/docs/docs/reference/Model Providers/openai.md @@ -2,14 +2,45 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; # OpenAI -The OpenAI class can be used to access OpenAI models like gpt-4 and gpt-3.5-turbo. +The OpenAI class can be used to access OpenAI models like GPT-4, GPT-4 Turbo, 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` like this: +### 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. + +### OpenAI compatible servers / APIs + +OpenAI compatible servers +- [text-gen-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai#setup--installation) +- [FastChat](https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md) +- [LocalAI](https://localai.io/basics/getting_started/) +- [llama-cpp-python](https://github.com/abetlen/llama-cpp-python#web-server) + +OpenAI compatible APIs +- [Anyscale Endpoints](https://github.com/continuedev/deploy-os-code-llm#others) +- [Anyscale Private Endpoints](https://github.com/continuedev/deploy-os-code-llm#anyscale-private-endpoints) + +If you are [using an OpenAI compatible server / API](../../model-setup/select-provider#local), you can change the `api_base` like this: ```json title="~/.continue/config.json" { "models": [{ - "title": "OpenAI-compatible server", + "title": "OpenAI-compatible server / API", "provider": "openai", "model": "MODEL_NAME", "api_key": "EMPTY", @@ -18,13 +49,6 @@ If you are locally serving a model that uses an OpenAI-compatible server, you ca } ``` -Options for serving models locally with an OpenAI-compatible server include: - -- [text-gen-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai#setup--installation) -- [FastChat](https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md) -- [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/openai.py) ## Properties @@ -43,7 +67,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/Model Providers/openaifreetrial.md similarity index 86% rename from docs/docs/reference/Models/openaifreetrial.md rename to docs/docs/reference/Model Providers/openaifreetrial.md index 307a86ab1..d5538d42c 100644 --- a/docs/docs/reference/Models/openaifreetrial.md +++ b/docs/docs/reference/Model Providers/openaifreetrial.md @@ -37,7 +37,7 @@ Once you are using Continue regularly though, you will need to add an OpenAI API ## Properties - + ### Inherited Properties @@ -47,8 +47,8 @@ Once you are using Continue regularly though, you will need to add an OpenAI API - + - + diff --git a/docs/docs/reference/Models/queuedllm.md b/docs/docs/reference/Model Providers/queuedllm.md similarity index 89% rename from docs/docs/reference/Models/queuedllm.md rename to docs/docs/reference/Model Providers/queuedllm.md index a835ab3d7..59a0bcea5 100644 --- a/docs/docs/reference/Models/queuedllm.md +++ b/docs/docs/reference/Model Providers/queuedllm.md @@ -31,8 +31,8 @@ config = ContinueConfig( - + - + diff --git a/docs/docs/reference/Models/replicatellm.md b/docs/docs/reference/Model Providers/replicatellm.md similarity index 90% rename from docs/docs/reference/Models/replicatellm.md rename to docs/docs/reference/Model Providers/replicatellm.md index 27ea1d8c3..fb718bf4c 100644 --- a/docs/docs/reference/Models/replicatellm.md +++ b/docs/docs/reference/Model Providers/replicatellm.md @@ -31,7 +31,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/Model Providers/textgenwebui.md similarity index 90% rename from docs/docs/reference/Models/textgenwebui.md rename to docs/docs/reference/Model Providers/textgenwebui.md index 2141bf5f5..10636ff41 100644 --- a/docs/docs/reference/Models/textgenwebui.md +++ b/docs/docs/reference/Model Providers/textgenwebui.md @@ -28,8 +28,8 @@ TextGenWebUI is a comprehensive, open-source language model UI and local server. - + - + diff --git a/docs/docs/reference/Models/togetherllm.md b/docs/docs/reference/Model Providers/togetherllm.md similarity index 89% rename from docs/docs/reference/Models/togetherllm.md rename to docs/docs/reference/Model Providers/togetherllm.md index b66f3fe82..0e9a9da88 100644 --- a/docs/docs/reference/Models/togetherllm.md +++ b/docs/docs/reference/Model Providers/togetherllm.md @@ -29,7 +29,7 @@ The Together API is a cloud platform for running large AI models. You can sign u - + - + diff --git a/docs/docs/reference/config.md b/docs/docs/reference/config.md index 814724737..b746de46a 100644 --- a/docs/docs/reference/config.md +++ b/docs/docs/reference/config.md @@ -10,10 +10,10 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; - + - + diff --git a/docs/docs/walkthroughs/running-continue-without-internet.md b/docs/docs/walkthroughs/running-continue-without-internet.md index 16d1cbe83..4775e7d0b 100644 --- a/docs/docs/walkthroughs/running-continue-without-internet.md +++ b/docs/docs/walkthroughs/running-continue-without-internet.md @@ -12,5 +12,5 @@ Continue can be run even on an air-gapped computer if you use a local model. You 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.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). +5. Also in `config.json`, set the default model to a local model. You can read about the available options [here](../model-setup/select-model.md). 6. Restart VS Code to ensure that the changes to `config.json` take effect. diff --git a/docs/sidebars.js b/docs/sidebars.js index ed27521ae..bfd360c27 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -18,6 +18,17 @@ const sidebars = { "quickstart", "how-to-use-continue", "how-continue-works", + { + type: "category", + label: "🌉 Model setup", + collapsible: true, + collapsed: true, + items: [ + "model-setup/select-provider", + "model-setup/select-model", + "model-setup/configuration", + ], + }, { type: "category", label: "🎨 Customization", @@ -25,7 +36,6 @@ const sidebars = { collapsed: true, items: [ "customization/overview", - "customization/models", "customization/context-providers", "customization/slash-commands", "customization/other-configuration", diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 6f77b4d18..50efe8964 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -107,7 +107,8 @@ "replicate", "text-gen-webui", "google-palm", - "lmstudio" + "lmstudio", + "llamafile" ], "type": "string" }, @@ -460,7 +461,8 @@ "huggingface-tgi", "huggingface-inference-api", "llama.cpp", - "text-gen-webui" + "text-gen-webui", + "llamafile" ] } }, @@ -514,7 +516,10 @@ "wizardcoder-13b", "wizardcoder-34b", "zephyr-7b", - "codeup-13b" + "codeup-13b", + "deepseek-1b", + "deepseek-7b", + "deepseek-33b" ] } } @@ -550,6 +555,23 @@ } } }, + { + "if": { + "properties": { + "provider": { + "const": "llamafile" + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "llamafile_command": { + "type": "string" + } + } + } + }, { "if": { "properties": { diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5c8ec0cc2..29e40746a 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.7.19", + "version": "0.7.23", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.7.19", + "version": "0.7.23", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index a3a20309c..7c3a03e0d 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.7.19", + "version": "0.7.23", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/extensions/vscode/schema/ContinueConfig.d.ts b/extensions/vscode/schema/ContinueConfig.d.ts index 694458fbd..c326e3752 100644 --- a/extensions/vscode/schema/ContinueConfig.d.ts +++ b/extensions/vscode/schema/ContinueConfig.d.ts @@ -32,46 +32,25 @@ export type DisallowedSteps = string[]; */ export type AllowAnonymousTelemetry = boolean; /** - * The title you wish to give your model. + * A title that will identify this model in the model selection dropdown */ export type Title = string; /** - * The provider of the model. This is used to determine the type of model, and how to interact with it. + * The unique ID of the user. */ -export type Provider = - | "openai" - | "openai-free-trial" - | "openai-aiohttp" - | "anthropic" - | "together" - | "ollama" - | "huggingface-tgi" - | "huggingface-inference-api" - | "llama.cpp" - | "replicate" - | "text-gen-webui" - | "google-palm" - | "lmstudio"; +export type UniqueId = string; /** - * The name of the model. Used to autodetect prompt template. + * The name of the model to be used (e.g. gpt-4, codellama) */ export type Model = string; /** - * OpenAI, Anthropic, Together, or other API key + * A system message that will always be followed by the LLM */ -export type ApiKey = string; -/** - * The base URL of the LLM API. - */ -export type ApiBase = string; +export type SystemMessage1 = string; /** * The maximum context length of the LLM in tokens, as counted by count_tokens. */ export type ContextLength = number; -/** - * The chat template used to format messages. This is auto-detected for most models, but can be overridden here. - */ -export type Template = "llama2" | "alpaca" | "zephyr" | "phind" | "anthropic" | "chatml" | "deepseek"; /** * Options for the completion endpoint. Read more about the completion options in the documentation. */ @@ -104,10 +83,6 @@ export type Stop = string[]; * The maximum number of tokens to generate. */ export type MaxTokens = number; -/** - * A system message that will always be followed by the LLM - */ -export type SystemMessage1 = string; /** * Options for the HTTP request to the LLM. */ @@ -128,7 +103,15 @@ export type CaBundlePath = string; * Proxy URL to use when making the HTTP request */ export type Proxy = string; -export type Models = ModelDescription[]; +/** + * The API key for the LLM provider. + */ +export type ApiKey = string; +/** + * The base URL of the LLM API. + */ +export type ApiBase = string; +export type Models = LLM[]; /** * Roles for models. Each entry should be the title of a model in the models array. */ @@ -333,17 +316,17 @@ export interface FunctionCall { arguments: Arguments; [k: string]: unknown; } -export interface ModelDescription { - title: Title; - provider: Provider; +export interface LLM { + title?: Title; + unique_id?: UniqueId; model: Model; + system_message?: SystemMessage1; + context_length?: ContextLength; + completion_options?: CompletionOptions; + request_options?: RequestOptions; + prompt_templates?: PromptTemplates; api_key?: ApiKey; api_base?: ApiBase; - context_length?: ContextLength; - template?: Template; - completion_options?: CompletionOptions; - system_message?: SystemMessage1; - request_options?: RequestOptions; [k: string]: unknown; } export interface BaseCompletionOptions { @@ -370,6 +353,12 @@ export interface RequestOptions1 { export interface Headers { [k: string]: string; } +/** + * A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the "edit" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation. See the documentation for more information. + */ +export interface PromptTemplates { + [k: string]: unknown; +} export interface ModelRoles1 { default: Default; chat?: Chat; diff --git a/extensions/vscode/schema/ModelDescription.d.ts b/extensions/vscode/schema/ModelDescription.d.ts index 2602a8cb3..7b30ae8ba 100644 --- a/extensions/vscode/schema/ModelDescription.d.ts +++ b/extensions/vscode/schema/ModelDescription.d.ts @@ -26,7 +26,8 @@ export type Provider = | "replicate" | "text-gen-webui" | "google-palm" - | "lmstudio"; + | "lmstudio" + | "llamafile"; /** * The name of the model. Used to autodetect prompt template. */ diff --git a/extensions/vscode/schema/ModelProvider.d.ts b/extensions/vscode/schema/ModelProvider.d.ts index e1fb74eba..10d71a774 100644 --- a/extensions/vscode/schema/ModelProvider.d.ts +++ b/extensions/vscode/schema/ModelProvider.d.ts @@ -18,4 +18,5 @@ export type ModelProvider = | "replicate" | "text-gen-webui" | "google-palm" - | "lmstudio"; + | "lmstudio" + | "llamafile"; diff --git a/extensions/vscode/schema/Models.d.ts b/extensions/vscode/schema/Models.d.ts index e24d6d587..a1592ae0a 100644 --- a/extensions/vscode/schema/Models.d.ts +++ b/extensions/vscode/schema/Models.d.ts @@ -86,7 +86,7 @@ export type ApiKey = string; * The base URL of the LLM API. */ export type ApiBase = string; -export type Saved = LLM[]; +export type Saved = (unknown | LLM)[]; export type Temperature1 = number; export type SystemMessage1 = string; @@ -94,10 +94,10 @@ export type SystemMessage1 = string; * Main class that holds the current model configuration */ export interface Models1 { - default: LLM; - summarize: LLM; - edit: LLM; - chat: LLM; + default?: unknown; + summarize?: unknown; + edit?: unknown; + chat?: unknown; saved?: Saved; temperature?: Temperature1; system_message?: SystemMessage1; diff --git a/extensions/vscode/schema/SerializedContinueConfig.d.ts b/extensions/vscode/schema/SerializedContinueConfig.d.ts index b5fff520b..c366a4905 100644 --- a/extensions/vscode/schema/SerializedContinueConfig.d.ts +++ b/extensions/vscode/schema/SerializedContinueConfig.d.ts @@ -34,7 +34,8 @@ export type Provider = | "replicate" | "text-gen-webui" | "google-palm" - | "lmstudio"; + | "lmstudio" + | "llamafile"; /** * The name of the model. Used to autodetect prompt template. */ diff --git a/gui/public/logos/llamafile.png b/gui/public/logos/llamafile.png new file mode 100644 index 000000000..98863d890 Binary files /dev/null and b/gui/public/logos/llamafile.png differ diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index 1a334991b..e32750cf5 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -232,8 +232,8 @@ function ModelSelect(props: {}) { { - if (val === defaultModel.title) return; - client?.setModelForRoleFromTitle("*", val); + if (val === defaultModel?.title) return; + client?.setModelForRoleFromTitle("default", val); }} defaultValue={"GPT-4"} > diff --git a/gui/src/pages/gui.tsx b/gui/src/pages/gui.tsx index accad00b1..8396ccb14 100644 --- a/gui/src/pages/gui.tsx +++ b/gui/src/pages/gui.tsx @@ -428,7 +428,7 @@ function GUI(props: GUIProps) { client?.stopSession(); persistSession(); dispatch(newSession()); - mainTextInputRef.current?.focus(); + mainTextInputRef.current?.focus?.(); } }; @@ -737,7 +737,7 @@ function GUI(props: GUIProps) { value={step.description as string} active={active && isLastUserInput(index)} onEnter={(e, value) => { - if (value) { + if (value && client) { client?.stopSession(); const newHistory = [ ...sessionState.history.slice(0, index), diff --git a/gui/src/pages/settings.tsx b/gui/src/pages/settings.tsx index bf4a4ee19..ad1eebde3 100644 --- a/gui/src/pages/settings.tsx +++ b/gui/src/pages/settings.tsx @@ -11,6 +11,7 @@ import { lightGray, secondaryDark, vscBackground, + vscForeground, } from "../components"; import styled from "styled-components"; import { ArrowLeftIcon } from "@heroicons/react/24/outline"; @@ -85,7 +86,7 @@ const ConfigJsonButton = styled(Button)` margin-left: auto; margin-right: 4px; background-color: transparent; - color: white; + color: ${vscForeground}; border: 1px solid ${lightGray}; &:hover { background-color: ${lightGray}; diff --git a/gui/src/redux/selectors/configSelectors.ts b/gui/src/redux/selectors/configSelectors.ts index e3c6226fe..8d1cbf1db 100644 --- a/gui/src/redux/selectors/configSelectors.ts +++ b/gui/src/redux/selectors/configSelectors.ts @@ -14,5 +14,8 @@ export const contextLengthSelector = (state: RootStore) => { export const defaultModelSelector = (state: RootStore) => { const title = state.serverState.config.model_roles?.default; - return state.serverState.config.models.find((model) => model.title === title); + if (!Array.isArray(state.serverState.config.models)) return; + return state.serverState.config.models?.find( + (model) => model.title === title + ); }; diff --git a/gui/src/schema/ContinueConfig.d.ts b/gui/src/schema/ContinueConfig.d.ts index 694458fbd..c326e3752 100644 --- a/gui/src/schema/ContinueConfig.d.ts +++ b/gui/src/schema/ContinueConfig.d.ts @@ -32,46 +32,25 @@ export type DisallowedSteps = string[]; */ export type AllowAnonymousTelemetry = boolean; /** - * The title you wish to give your model. + * A title that will identify this model in the model selection dropdown */ export type Title = string; /** - * The provider of the model. This is used to determine the type of model, and how to interact with it. + * The unique ID of the user. */ -export type Provider = - | "openai" - | "openai-free-trial" - | "openai-aiohttp" - | "anthropic" - | "together" - | "ollama" - | "huggingface-tgi" - | "huggingface-inference-api" - | "llama.cpp" - | "replicate" - | "text-gen-webui" - | "google-palm" - | "lmstudio"; +export type UniqueId = string; /** - * The name of the model. Used to autodetect prompt template. + * The name of the model to be used (e.g. gpt-4, codellama) */ export type Model = string; /** - * OpenAI, Anthropic, Together, or other API key + * A system message that will always be followed by the LLM */ -export type ApiKey = string; -/** - * The base URL of the LLM API. - */ -export type ApiBase = string; +export type SystemMessage1 = string; /** * The maximum context length of the LLM in tokens, as counted by count_tokens. */ export type ContextLength = number; -/** - * The chat template used to format messages. This is auto-detected for most models, but can be overridden here. - */ -export type Template = "llama2" | "alpaca" | "zephyr" | "phind" | "anthropic" | "chatml" | "deepseek"; /** * Options for the completion endpoint. Read more about the completion options in the documentation. */ @@ -104,10 +83,6 @@ export type Stop = string[]; * The maximum number of tokens to generate. */ export type MaxTokens = number; -/** - * A system message that will always be followed by the LLM - */ -export type SystemMessage1 = string; /** * Options for the HTTP request to the LLM. */ @@ -128,7 +103,15 @@ export type CaBundlePath = string; * Proxy URL to use when making the HTTP request */ export type Proxy = string; -export type Models = ModelDescription[]; +/** + * The API key for the LLM provider. + */ +export type ApiKey = string; +/** + * The base URL of the LLM API. + */ +export type ApiBase = string; +export type Models = LLM[]; /** * Roles for models. Each entry should be the title of a model in the models array. */ @@ -333,17 +316,17 @@ export interface FunctionCall { arguments: Arguments; [k: string]: unknown; } -export interface ModelDescription { - title: Title; - provider: Provider; +export interface LLM { + title?: Title; + unique_id?: UniqueId; model: Model; + system_message?: SystemMessage1; + context_length?: ContextLength; + completion_options?: CompletionOptions; + request_options?: RequestOptions; + prompt_templates?: PromptTemplates; api_key?: ApiKey; api_base?: ApiBase; - context_length?: ContextLength; - template?: Template; - completion_options?: CompletionOptions; - system_message?: SystemMessage1; - request_options?: RequestOptions; [k: string]: unknown; } export interface BaseCompletionOptions { @@ -370,6 +353,12 @@ export interface RequestOptions1 { export interface Headers { [k: string]: string; } +/** + * A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the "edit" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation. See the documentation for more information. + */ +export interface PromptTemplates { + [k: string]: unknown; +} export interface ModelRoles1 { default: Default; chat?: Chat; diff --git a/gui/src/schema/ModelDescription.d.ts b/gui/src/schema/ModelDescription.d.ts index 2602a8cb3..7b30ae8ba 100644 --- a/gui/src/schema/ModelDescription.d.ts +++ b/gui/src/schema/ModelDescription.d.ts @@ -26,7 +26,8 @@ export type Provider = | "replicate" | "text-gen-webui" | "google-palm" - | "lmstudio"; + | "lmstudio" + | "llamafile"; /** * The name of the model. Used to autodetect prompt template. */ diff --git a/gui/src/schema/ModelProvider.d.ts b/gui/src/schema/ModelProvider.d.ts index e1fb74eba..10d71a774 100644 --- a/gui/src/schema/ModelProvider.d.ts +++ b/gui/src/schema/ModelProvider.d.ts @@ -18,4 +18,5 @@ export type ModelProvider = | "replicate" | "text-gen-webui" | "google-palm" - | "lmstudio"; + | "lmstudio" + | "llamafile"; diff --git a/gui/src/schema/Models.d.ts b/gui/src/schema/Models.d.ts index e24d6d587..a1592ae0a 100644 --- a/gui/src/schema/Models.d.ts +++ b/gui/src/schema/Models.d.ts @@ -86,7 +86,7 @@ export type ApiKey = string; * The base URL of the LLM API. */ export type ApiBase = string; -export type Saved = LLM[]; +export type Saved = (unknown | LLM)[]; export type Temperature1 = number; export type SystemMessage1 = string; @@ -94,10 +94,10 @@ export type SystemMessage1 = string; * Main class that holds the current model configuration */ export interface Models1 { - default: LLM; - summarize: LLM; - edit: LLM; - chat: LLM; + default?: unknown; + summarize?: unknown; + edit?: unknown; + chat?: unknown; saved?: Saved; temperature?: Temperature1; system_message?: SystemMessage1; diff --git a/gui/src/schema/SerializedContinueConfig.d.ts b/gui/src/schema/SerializedContinueConfig.d.ts index b5fff520b..c366a4905 100644 --- a/gui/src/schema/SerializedContinueConfig.d.ts +++ b/gui/src/schema/SerializedContinueConfig.d.ts @@ -34,7 +34,8 @@ export type Provider = | "replicate" | "text-gen-webui" | "google-palm" - | "lmstudio"; + | "lmstudio" + | "llamafile"; /** * The name of the model. Used to autodetect prompt template. */ diff --git a/gui/src/util/modelData.ts b/gui/src/util/modelData.ts index 912b7a940..1a7076893 100644 --- a/gui/src/util/modelData.ts +++ b/gui/src/util/modelData.ts @@ -491,6 +491,17 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = { { ...apiBaseInput, defaultValue: "http://localhost:11434" }, ], }, + llamafile: { + title: "llamafile", + provider: "llamafile", + icon: "llamafile.png", + description: + "llamafiles are a self-contained binary to run an open-source LLM", + longDescription: `To get started with llamafiles, find and download a binary on their [GitHub repo](https://github.com/Mozilla-Ocho/llamafile#binary-instructions). Then run it with the following command:\n\n\`\`\`shell\nchmod +x ./llamafile\n./llamafile\n\`\`\``, + tags: [ModelProviderTag["Local"], ModelProviderTag["Open-Source"]], + packages: osModels, + collectInputFor: [...completionParamsInputs], + }, together: { title: "TogetherAI", provider: "together", diff --git a/schema/json/ContinueConfig.json b/schema/json/ContinueConfig.json index b10be7a36..8ef88047a 100644 --- a/schema/json/ContinueConfig.json +++ b/schema/json/ContinueConfig.json @@ -177,48 +177,28 @@ } } }, - "ModelDescription": { - "title": "ModelDescription", + "LLM": { + "title": "LLM", "type": "object", "properties": { "title": { "title": "Title", - "description": "The title you wish to give your model.", + "description": "A title that will identify this model in the model selection dropdown", "type": "string" }, - "provider": { - "title": "Provider", - "description": "The provider of the model. This is used to determine the type of model, and how to interact with it.", - "enum": [ - "openai", - "openai-free-trial", - "openai-aiohttp", - "anthropic", - "together", - "ollama", - "huggingface-tgi", - "huggingface-inference-api", - "llama.cpp", - "replicate", - "text-gen-webui", - "google-palm", - "lmstudio" - ], + "unique_id": { + "title": "Unique Id", + "description": "The unique ID of the user.", "type": "string" }, "model": { "title": "Model", - "description": "The name of the model. Used to autodetect prompt template.", + "description": "The name of the model to be used (e.g. gpt-4, codellama)", "type": "string" }, - "api_key": { - "title": "Api Key", - "description": "OpenAI, Anthropic, Together, or other API key", - "type": "string" - }, - "api_base": { - "title": "Api Base", - "description": "The base URL of the LLM API.", + "system_message": { + "title": "System Message", + "description": "A system message that will always be followed by the LLM", "type": "string" }, "context_length": { @@ -227,20 +207,6 @@ "default": 2048, "type": "integer" }, - "template": { - "title": "Template", - "description": "The chat template used to format messages. This is auto-detected for most models, but can be overridden here.", - "enum": [ - "llama2", - "alpaca", - "zephyr", - "phind", - "anthropic", - "chatml", - "deepseek" - ], - "type": "string" - }, "completion_options": { "title": "Completion Options", "description": "Options for the completion endpoint. Read more about the completion options in the documentation.", @@ -259,11 +225,6 @@ } ] }, - "system_message": { - "title": "System Message", - "description": "A system message that will always be followed by the LLM", - "type": "string" - }, "request_options": { "title": "Request Options", "description": "Options for the HTTP request to the LLM.", @@ -279,11 +240,24 @@ "$ref": "#/definitions/RequestOptions" } ] + }, + "prompt_templates": { + "title": "Prompt Templates", + "description": "A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the \"edit\" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation. See the documentation for more information.", + "type": "object" + }, + "api_key": { + "title": "Api Key", + "description": "The API key for the LLM provider.", + "type": "string" + }, + "api_base": { + "title": "Api Base", + "description": "The base URL of the LLM API.", + "type": "string" } }, "required": [ - "title", - "provider", "model" ] }, @@ -610,12 +584,9 @@ "default": [ { "title": "GPT-4 (trial)", - "provider": "openai-free-trial", "model": "gpt-4", - "api_key": "", - "api_base": null, - "context_length": 2048, - "template": null, + "system_message": null, + "context_length": 8192, "completion_options": { "temperature": null, "top_p": null, @@ -625,19 +596,50 @@ "stop": null, "max_tokens": 1023 }, - "system_message": null, "request_options": { "timeout": 300, "verify_ssl": null, "ca_bundle_path": null, "proxy": null, "headers": null - } + }, + "prompt_templates": {}, + "template_messages": null, + "api_key": "", + "api_base": null, + "llm": { + "title": null, + "model": "gpt-4", + "system_message": null, + "context_length": 2048, + "completion_options": { + "temperature": null, + "top_p": null, + "top_k": null, + "presence_penalty": null, + "frequency_penalty": null, + "stop": null, + "max_tokens": 1023 + }, + "request_options": { + "timeout": 300, + "verify_ssl": null, + "ca_bundle_path": null, + "proxy": null, + "headers": null + }, + "prompt_templates": {}, + "template_messages": null, + "api_key": null, + "api_base": null, + "class_name": "ProxyServer" + }, + "class_name": "OpenAIFreeTrial" } ], "type": "array", "items": { - "$ref": "#/definitions/ModelDescription" + "$ref": "#/definitions/LLM" } }, "model_roles": { diff --git a/schema/json/LLM.json b/schema/json/LLM.json index 6dcf550f9..8003a66a1 100644 --- a/schema/json/LLM.json +++ b/schema/json/LLM.json @@ -149,7 +149,6 @@ "prompt_templates": { "title": "Prompt Templates", "description": "A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the \"edit\" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation. See the documentation for more information.", - "default": {}, "type": "object" }, "api_key": { diff --git a/schema/json/ModelDescription.json b/schema/json/ModelDescription.json index a1670a5dc..a2de7e944 100644 --- a/schema/json/ModelDescription.json +++ b/schema/json/ModelDescription.json @@ -107,7 +107,8 @@ "replicate", "text-gen-webui", "google-palm", - "lmstudio" + "lmstudio", + "llamafile" ], "type": "string" }, diff --git a/schema/json/ModelProvider.json b/schema/json/ModelProvider.json index 477b7963c..82aa9e7ca 100644 --- a/schema/json/ModelProvider.json +++ b/schema/json/ModelProvider.json @@ -13,7 +13,8 @@ "replicate", "text-gen-webui", "google-palm", - "lmstudio" + "lmstudio", + "llamafile" ], "type": "string" } \ No newline at end of file diff --git a/schema/json/Models.json b/schema/json/Models.json index 68cc9d9e8..677a39a5c 100644 --- a/schema/json/Models.json +++ b/schema/json/Models.json @@ -149,7 +149,6 @@ "prompt_templates": { "title": "Prompt Templates", "description": "A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the \"edit\" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation. See the documentation for more information.", - "default": {}, "type": "object" }, "api_key": { @@ -173,23 +172,52 @@ "type": "object", "properties": { "default": { - "$ref": "#/definitions/LLM" + "title": "Default", + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] }, "summarize": { - "$ref": "#/definitions/LLM" + "title": "Summarize", + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] }, "edit": { - "$ref": "#/definitions/LLM" + "title": "Edit", + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] }, "chat": { - "$ref": "#/definitions/LLM" + "title": "Chat", + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] }, "saved": { "title": "Saved", "default": [], "type": "array", "items": { - "$ref": "#/definitions/LLM" + "anyOf": [ + {}, + { + "$ref": "#/definitions/LLM" + } + ] } }, "temperature": { @@ -200,13 +228,7 @@ "title": "System Message", "type": "string" } - }, - "required": [ - "default", - "summarize", - "edit", - "chat" - ] + } } } } \ No newline at end of file diff --git a/schema/json/SerializedContinueConfig.json b/schema/json/SerializedContinueConfig.json index d016de052..9b421b714 100644 --- a/schema/json/SerializedContinueConfig.json +++ b/schema/json/SerializedContinueConfig.json @@ -107,7 +107,8 @@ "replicate", "text-gen-webui", "google-palm", - "lmstudio" + "lmstudio", + "llamafile" ], "type": "string" }, diff --git a/server/continuedev/core/config.py b/server/continuedev/core/config.py index 905da4b1b..685abe3f9 100644 --- a/server/continuedev/core/config.py +++ b/server/continuedev/core/config.py @@ -8,18 +8,22 @@ from pydantic import BaseModel, Field, validator from ..libs.constants.default_config import default_config_json from ..libs.llm.base import LLM +from ..libs.llm.openai_free_trial import OpenAIFreeTrial from ..libs.util.logging import logger -from ..libs.util.paths import getConfigFilePath, getGlobalFolderPath +from ..libs.util.paths import getConfigFilePath, getGlobalFolderPath, sync_migrate from ..libs.util.telemetry import posthog_logger from ..models.llm import BaseCompletionOptions, RequestOptions from .config_utils.context import CONTEXT_PROVIDER_NAME_TO_CLASS, ContextProviderName from .config_utils.shared import ( + MODEL_CLASS_TO_MODEL_PROVIDER, MODEL_PROVIDER_TO_MODEL_CLASS, + STEP_NAMES, ModelProvider, StepName, TemplateType, autodetect_prompt_templates, autodetect_template_function, + autodetect_template_type, ) from .context import ContextProvider from .main import ContextProviderDescription, Policy, SlashCommandDescription, Step @@ -47,11 +51,23 @@ class SlashCommand(BaseModel): def step_is_string(cls, v): if isinstance(v, str): return v - elif isinstance(v, object) and v.__class__.__name__ == "ModelMetaclass": + elif ( + isinstance(v, object) + and v.__class__.__name__ == "ModelMetaclass" + and v.__class__.__name__ in STEP_NAMES + ): return str(v).split(".")[-1].split("'")[0] else: return v + def dict(self, *args, **kwargs): + d = super().dict(*args, **kwargs) + if isinstance(d["step"], str): + d["step"] = d["step"].split(".")[-1] + else: + d["step"] = d["step"].__name__ + return d + def slash_command_description(self) -> SlashCommandDescription: return SlashCommandDescription( name=self.name, @@ -273,6 +289,12 @@ class SerializedContinueConfig(BaseModel): else: config.model_roles.__setattr__(role, title) + def migrate_func(): + if role == "default" and config.model_roles.chat is not None: + config.model_roles.chat = None + + sync_migrate("select_default_model_001", migrate_func) + @staticmethod def add_model(model: ModelDescription): with SerializedContinueConfig.edit_config() as config: @@ -314,11 +336,10 @@ class ContinueConfig(BaseModel): default=True, description="If this field is set to True, we will collect anonymous telemetry as described in the documentation page on telemetry. If set to False, we will not collect any data.", ) - models: List[ModelDescription] = Field( + models: List[LLM] = Field( default=[ - ModelDescription( + OpenAIFreeTrial( title="GPT-4 (trial)", - provider="openai-free-trial", model="gpt-4", api_key="", ) @@ -393,7 +414,10 @@ class ContinueConfig(BaseModel): allow_anonymous_telemetry=config.allow_anonymous_telemetry if config.allow_anonymous_telemetry is not None else True, - models=config.models, + models=[ + ContinueConfig.create_llm(config.completion_options, model) + for model in config.models + ], model_roles=config.model_roles, system_message=config.system_message, completion_options=config.completion_options, @@ -447,6 +471,9 @@ class ContinueConfig(BaseModel): serialized_config = json.loads(contents) + except json.JSONDecodeError as e: + raise e + except ValueError as e: logger.warning(f"Found empty config.json at {filepath}: {e}") with open(filepath, "w") as f: @@ -583,7 +610,9 @@ class ContinueConfig(BaseModel): return SerializedContinueConfig( disallowed_steps=self.disallowed_steps, allow_anonymous_telemetry=self.allow_anonymous_telemetry, - models=self.models, + models=[ + ContinueConfig.model_description_from(model) for model in self.models + ], model_roles=self.model_roles, system_message=self.system_message, completion_options=self.completion_options, @@ -604,28 +633,50 @@ class ContinueConfig(BaseModel): retrieval_settings=self.retrieval_settings, ) - def create_llm(self, model: ModelDescription) -> LLM: + @staticmethod + def create_llm( + completion_options: BaseCompletionOptions, model: ModelDescription + ) -> LLM: model_class = MODEL_CLASSES[MODEL_PROVIDER_TO_MODEL_CLASS[model.provider]] - completion_options = self.completion_options.dict( - exclude_none=True, exclude_defaults=True - ) - completion_options.update( + options = completion_options.dict(exclude_none=True, exclude_defaults=True) + options.update( model.completion_options.dict(exclude_none=True, exclude_defaults=True) ) - if "max_tokens" not in completion_options: - completion_options["max_tokens"] = min(2048, model.context_length // 2) + if "max_tokens" not in options: + options["max_tokens"] = min(2048, model.context_length // 2) # Allow extra fields to be passed through kwargs = {**model.dict(exclude_none=True)} - kwargs["completion_options"] = completion_options - kwargs["template_messages"] = autodetect_template_function(model.model) - kwargs["prompt_templates"] = autodetect_prompt_templates(model.model) + kwargs["completion_options"] = options + kwargs["template_messages"] = autodetect_template_function( + model.model, model.template + ) + kwargs["prompt_templates"] = autodetect_prompt_templates( + model.model, model.template + ) return model_class(**kwargs) + @staticmethod + def model_description_from(llm: LLM) -> ModelDescription: + return ModelDescription( + title=llm.title or "LLM", + provider=MODEL_CLASS_TO_MODEL_PROVIDER.get( + llm.__class__.__name__, "custom" # type: ignore + ), + model=llm.model, + api_key=llm.api_key, + api_base=llm.api_base, + context_length=llm.context_length, + template=autodetect_template_type(llm.model), + completion_options=llm.completion_options, + system_message=llm.system_message, + request_options=llm.request_options, + ) + def construct_models(self) -> Models: - def model_with_title(title: Optional[str], fallback: ModelDescription): + def model_with_title(title: Optional[str], fallback: LLM): return next(filter(lambda x: x.title == title, self.models), fallback) default = model_with_title(self.model_roles.default, self.models[0]) @@ -640,11 +691,10 @@ class ContinueConfig(BaseModel): not in [default.title, chat.title, edit.title, summarize.title] ] - models = Models( - default=self.create_llm(default), - chat=self.create_llm(chat), - edit=self.create_llm(edit), - summarize=self.create_llm(summarize), - saved=[self.create_llm(model) for model in saved], + return Models( + default=default, + chat=chat, + edit=edit, + summarize=summarize, + saved=saved, ) - return models diff --git a/server/continuedev/core/config_utils/shared.py b/server/continuedev/core/config_utils/shared.py index f5931e4d6..8e4417ca7 100644 --- a/server/continuedev/core/config_utils/shared.py +++ b/server/continuedev/core/config_utils/shared.py @@ -18,6 +18,18 @@ from ...libs.llm.prompts.edit import ( zephyr_edit_prompt, ) +STEP_NAMES = [ + "AnswerQuestionChroma", + "GenerateShellCommandStep", + "EditHighlightedCodeStep", + "ShareSessionStep", + "CommentCodeStep", + "ClearHistoryStep", + "StackOverflowStep", + "OpenConfigStep", + "GenerateShellCommandStep", +] + StepName = Literal[ "AnswerQuestionChroma", "GenerateShellCommandStep", @@ -64,8 +76,10 @@ def autodetect_template_type(model: str) -> Optional[TemplateType]: return "chatml" -def autodetect_template_function(model: str): - if template_type := autodetect_template_type(model): +def autodetect_template_function( + model: str, explicit_template: Optional[TemplateType] = None +): + if template_type := explicit_template or autodetect_template_type(model): mapping: Dict[TemplateType, Any] = { "llama2": llama2_template_messages, "alpaca": template_alpaca_messages, @@ -79,8 +93,10 @@ def autodetect_template_function(model: str): return None -def autodetect_prompt_templates(model: str): - template_type = autodetect_template_type(model) +def autodetect_prompt_templates( + model: str, explicit_template: Optional[TemplateType] = None +): + template_type = explicit_template or autodetect_template_type(model) templates = {} @@ -118,6 +134,7 @@ ModelProvider = Literal[ "text-gen-webui", "google-palm", "lmstudio", + "llamafile", ] MODEL_PROVIDER_TO_MODEL_CLASS = { @@ -134,6 +151,7 @@ MODEL_PROVIDER_TO_MODEL_CLASS = { "text-gen-webui": "TextGenWebUI", "google-palm": "GooglePaLMAPI", "lmstudio": "LMStudio", + "llamafile": "Llamafile", } MODEL_CLASS_TO_MODEL_PROVIDER: Dict[str, ModelProvider] = { @@ -149,6 +167,7 @@ MODEL_CLASS_TO_MODEL_PROVIDER: Dict[str, ModelProvider] = { "TextGenWebUI": "text-gen-webui", "GooglePaLMAPI": "google-palm", "LMStudio": "lmstudio", + "Llamafile": "llamafile", } MODELS = [ diff --git a/server/continuedev/core/models.py b/server/continuedev/core/models.py index 74f5a838b..2d871f202 100644 --- a/server/continuedev/core/models.py +++ b/server/continuedev/core/models.py @@ -1,7 +1,7 @@ import uuid -from typing import Any, Callable, Dict, List, Optional, Type +from typing import Any, Callable, Dict, List, Optional, Type, Union -from pydantic import BaseModel, Field, validator +from pydantic import BaseModel, validator from ..libs.llm.anthropic import AnthropicLLM from ..libs.llm.base import LLM @@ -10,6 +10,7 @@ from ..libs.llm.google_palm_api import GooglePaLMAPI from ..libs.llm.hf_inference_api import HuggingFaceInferenceAPI from ..libs.llm.hf_tgi import HuggingFaceTGI from ..libs.llm.llamacpp import LlamaCpp +from ..libs.llm.llamafile import Llamafile from ..libs.llm.lmstudio import LMStudio from ..libs.llm.ollama import Ollama from ..libs.llm.openai import OpenAI @@ -46,6 +47,7 @@ MODEL_CLASSES: Dict[str, Type[LLM]] = { GooglePaLMAPI, TextGenWebUI, LMStudio, + Llamafile, ] } @@ -63,18 +65,19 @@ MODEL_MODULE_NAMES = { "GooglePaLMAPI": "google_palm_api", "TextGenWebUI": "text_gen_webui", "LMStudio": "lmstudio", + "Llamafile": "llamafile", } class Models(BaseModel): """Main class that holds the current model configuration""" - default: LLM - summarize: LLM - edit: LLM - chat: LLM + default: Union[Any, LLM] + summarize: Union[Any, LLM] + edit: Union[Any, LLM] + chat: Union[Any, LLM] - saved: List[LLM] = [] + saved: List[Union[Any, LLM]] = [] temperature: Optional[float] = None system_message: Optional[str] = None @@ -115,9 +118,7 @@ class Models(BaseModel): temperature: Optional[float], ): """Start each of the LLMs, or fall back to default""" - for role in ALL_MODEL_ROLES: - model: LLM = getattr(self, role) - + for model in self.saved + self.all_models: model.start(unique_id) model.write_log = self.write_log diff --git a/server/continuedev/libs/llm/base.py b/server/continuedev/libs/llm/base.py index da3bf3a1e..b3674dab5 100644 --- a/server/continuedev/libs/llm/base.py +++ b/server/continuedev/libs/llm/base.py @@ -5,8 +5,12 @@ from typing import Any, AsyncGenerator, Callable, Coroutine, Dict, List, Optiona import aiohttp import certifi -from pydantic import Field +from pydantic import Field, validator +from ...core.config_utils.shared import ( + autodetect_prompt_templates, + autodetect_template_function, +) from ...core.main import ChatMessage from ...models.llm import BaseCompletionOptions, CompletionOptions, RequestOptions from ...models.main import ContinueBaseModel @@ -58,7 +62,7 @@ class LLM(ContinueBaseModel): ) prompt_templates: dict = Field( - default={}, + default=None, description='A dictionary of prompt templates that can be used to customize the behavior of the LLM in certain situations. For example, set the "edit" key in order to change the prompt that is used for the /edit slash command. Each value in the dictionary is a string templated in mustache syntax, and filled in at runtime with the variables specific to the situation. See the documentation for more information.', ) @@ -103,6 +107,14 @@ class LLM(ContinueBaseModel): }, } + @validator("template_messages", pre=True, always=True) + def set_template_messages(cls, template_messages, values): + return template_messages or autodetect_template_function(values["model"]) + + @validator("prompt_templates", pre=True, always=True) + def set_prompt_templates(cls, prompt_templates, values): + return prompt_templates or autodetect_prompt_templates(values["model"]) + def dict(self, **kwargs): original_dict = super().dict(**kwargs) original_dict.pop("write_log") diff --git a/server/continuedev/libs/llm/ggml.py b/server/continuedev/libs/llm/ggml.py index 226749603..b8343d550 100644 --- a/server/continuedev/libs/llm/ggml.py +++ b/server/continuedev/libs/llm/ggml.py @@ -13,6 +13,8 @@ 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. + You can also use this class for [LM Studio](https://lmstudio.ai). + Once the model is running on localhost:8000, change `~/.continue/config.json` to look like this: ```json title="~/.continue/config.json" diff --git a/server/continuedev/libs/llm/llamacpp.py b/server/continuedev/libs/llm/llamacpp.py index 4d3b6dcf2..366d1c88b 100644 --- a/server/continuedev/libs/llm/llamacpp.py +++ b/server/continuedev/libs/llm/llamacpp.py @@ -39,7 +39,7 @@ class LlamaCpp(LLM): llama_cpp_args: Dict[str, Any] = Field( {"stop": ["[INST]"]}, - description="A list of additional arguments to pass to llama.cpp. See [here](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#api-endpoints) for the complete catalog of options.", + description="A list of additional arguments to pass to llama.cpp. See https://github.com/ggerganov/llama.cpp/tree/master/examples/server#api-endpoints for the complete catalog of options.", ) class Config: diff --git a/server/continuedev/libs/llm/llamafile.py b/server/continuedev/libs/llm/llamafile.py new file mode 100644 index 000000000..89cad006e --- /dev/null +++ b/server/continuedev/libs/llm/llamafile.py @@ -0,0 +1,93 @@ +import asyncio +import socket +import subprocess +from typing import Any, AsyncGenerator, Coroutine, List, Optional + +from continuedev.core.main import ChatMessage +from continuedev.models.llm import CompletionOptions + +from .llamacpp import LlamaCpp + + +def test_port(PORT): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + try: + s.bind(("", PORT)) ## Try to open port + except OSError as e: + if e.errno == 98: ## Errorno 98 means address already bound + return True + elif e.errno == 48: ## Errorno 48 means address already in use + return True + return False + s.close() + return False + + +STARTUP_DELAY = 3.0 + + +class Llamafile(LlamaCpp): + """ + A [llamafile](https://github.com/Mozilla-Ocho/llamafile#readme) is a self-contained binary that can run an open-source LLM. You can configure this provider in your config.json as follows: + + ```json title="~/.continue/config.json" + { + "models": [{ + "title": "Llamafile", + "provider": "llamafile", + "model": "mistral-7b", + }] + } + ``` + + Optionally, you can set the `llamafile_command` property, which will be run to start the llamafile if it isn't already running on port 8080. Be sure to use an absolute path to the llamafile binary. For example: `/Users/yourusername/mistral-7b-instruct-v0.1-Q4_K_M-server.llamafile`. + """ + + llamafile_command: Optional[str] = None + + def check_and_start(self) -> bool: + # Try to start the llamafile if it's not already started on port 8080 + if not self.llamafile_command: + return False + + port = int((self.api_base or ":8080").split(":")[-1]) + + if not test_port(port): + subprocess.Popen( + self.llamafile_command.split(" "), + stdout=subprocess.DEVNULL, + stderr=subprocess.STDOUT, + close_fds=True, + start_new_session=True, + shell=True, + ) + + return True + + return False + + def start(self, unique_id: str | None = None): + super().start(unique_id) + self.check_and_start() + + async def _stream_chat( + self, messages: List[ChatMessage], options: CompletionOptions + ): + if self.check_and_start(): + await asyncio.sleep(STARTUP_DELAY) + + async for message in super()._stream_chat(messages, options): + yield message + + async def _stream_complete(self, prompt, options): + if self.check_and_start(): + await asyncio.sleep(STARTUP_DELAY) + + async for message in super()._stream_complete(prompt, options): + yield message + + async def _complete(self, prompt: str, options: CompletionOptions): + if self.check_and_start(): + await asyncio.sleep(STARTUP_DELAY) + + return await super()._complete(prompt, options) diff --git a/server/continuedev/libs/llm/ollama.py b/server/continuedev/libs/llm/ollama.py index 61aba2873..886783126 100644 --- a/server/continuedev/libs/llm/ollama.py +++ b/server/continuedev/libs/llm/ollama.py @@ -60,6 +60,9 @@ class Ollama(LLM): "wizardcoder-34b": "wizardcoder:34b-python", "zephyr-7b": "zephyr:7b", "codeup-13b": "codeup:13b", + "deepseek-1b": "deepseek-coder:1.3b", + "deepseek-7b": "deepseek-coder:6.7b", + "deepseek-33b": "deepseek-coder:33b", }.get(self.model, self.model) def start(self, *args, **kwargs): diff --git a/server/continuedev/libs/llm/openai.py b/server/continuedev/libs/llm/openai.py index ce0510f9a..6081623d0 100644 --- a/server/continuedev/libs/llm/openai.py +++ b/server/continuedev/libs/llm/openai.py @@ -38,14 +38,45 @@ NON_CHAT_MODELS = { class OpenAI(LLM): """ - The OpenAI class can be used to access OpenAI models like gpt-4 and gpt-3.5-turbo. + The OpenAI class can be used to access OpenAI models like GPT-4, GPT-4 Turbo, 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` like this: + ### 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. + + ### OpenAI compatible servers / APIs + + OpenAI compatible servers + - [text-gen-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai#setup--installation) + - [FastChat](https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md) + - [LocalAI](https://localai.io/basics/getting_started/) + - [llama-cpp-python](https://github.com/abetlen/llama-cpp-python#web-server) + + OpenAI compatible APIs + - [Anyscale Endpoints](https://github.com/continuedev/deploy-os-code-llm#others) + - [Anyscale Private Endpoints](https://github.com/continuedev/deploy-os-code-llm#anyscale-private-endpoints) + + If you are [using an OpenAI compatible server / API](../../model-setup/select-provider#local), you can change the `api_base` like this: ```json title="~/.continue/config.json" { "models": [{ - "title": "OpenAI-compatible server", + "title": "OpenAI-compatible server / API", "provider": "openai", "model": "MODEL_NAME", "api_key": "EMPTY", @@ -53,13 +84,6 @@ class OpenAI(LLM): }] } ``` - - Options for serving models locally with an OpenAI-compatible server include: - - - [text-gen-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai#setup--installation) - - [FastChat](https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md) - - [LocalAI](https://localai.io/basics/getting_started/) - - [llama-cpp-python](https://github.com/abetlen/llama-cpp-python#web-server) """ api_key: str = Field( diff --git a/server/continuedev/libs/util/paths.py b/server/continuedev/libs/util/paths.py index 6fd38a675..8114f8061 100644 --- a/server/continuedev/libs/util/paths.py +++ b/server/continuedev/libs/util/paths.py @@ -1,6 +1,6 @@ import os import re -from typing import Awaitable, Callable, Optional +from typing import Any, Awaitable, Callable, Optional from ..constants.default_config import default_config from ..constants.main import ( @@ -44,6 +44,12 @@ async def migrate(migration_id: str, migrate_func: Callable[[], Awaitable]): markMigrated(migration_id) +def sync_migrate(migration_id: str, migrate_func: Callable[[], Any]): + if not hasMigrated(migration_id): + migrate_func() + markMigrated(migration_id) + + def getSessionsFolderPath(): path = os.path.join(getGlobalFolderPath(), CONTINUE_SESSIONS_FOLDER) os.makedirs(path, exist_ok=True) diff --git a/server/continuedev/models/reference/generate.py b/server/continuedev/models/reference/generate.py index 792526ad5..b8e6677dc 100644 --- a/server/continuedev/models/reference/generate.py +++ b/server/continuedev/models/reference/generate.py @@ -17,6 +17,7 @@ LLM_MODULES = [ ("openai_free_trial", "OpenAIFreeTrial"), ("google_palm_api", "GooglePaLMAPI"), ("queued", "QueuedLLM"), + ("llamafile", "Llamafile"), ] CONTEXT_PROVIDER_MODULES = [ diff --git a/server/continuedev/plugins/context_providers/highlighted_code.py b/server/continuedev/plugins/context_providers/highlighted_code.py index 8f0bac9be..82d3b5f92 100644 --- a/server/continuedev/plugins/context_providers/highlighted_code.py +++ b/server/continuedev/plugins/context_providers/highlighted_code.py @@ -99,7 +99,7 @@ class HighlightedCodeContextProvider(ContextProvider): ) return ChatMessage( role="user", - content=f"Code in this file is highlighted ({item.description.name}):\n```\n{rif.contents}\n```", + content=f"```{item.description.name}\n{rif.contents}\n```", summary=f"Code in this file is highlighted: {item.description.name}", ) diff --git a/server/continuedev/plugins/steps/codebase.py b/server/continuedev/plugins/steps/codebase.py index e5dab20f8..032d050d2 100644 --- a/server/continuedev/plugins/steps/codebase.py +++ b/server/continuedev/plugins/steps/codebase.py @@ -24,42 +24,35 @@ PROMPT = """Use the above code to answer the following question. You should not async def get_faster_model(sdk: ContinueSDK) -> Optional[LLM]: - def get_model_description() -> Optional[ModelDescription]: - # First, check for GPT-3/3.5 - models = sdk.config.models - if gpt3_model := next(filter(lambda m: "gpt-3" in m.model, models), None): - return gpt3_model + # First, check for GPT-3/3.5 + models: List[LLM] = sdk.config.models + if gpt3_model := next(filter(lambda m: "gpt-3" in m.model, models), None): + return gpt3_model - # Then, check for OpenAIFreeTrial - if openai_free_trial_model := next( - filter(lambda m: m.__class__.__name__ == "OpenAIFreeTrial", models), None - ): - new_model = openai_free_trial_model.copy() - new_model.model = "gpt-3.5-turbo" - return new_model + # Then, check for OpenAIFreeTrial + if openai_free_trial_model := next( + filter(lambda m: m.__class__.__name__ == "OpenAIFreeTrial", models), None + ): + new_model = openai_free_trial_model.copy() + new_model.model = "gpt-3.5-turbo" + return new_model - # Then, check for an API Key - if openai_model := next( - filter( - lambda m: hasattr(m, "api_key") - and m.api_key is not None - and m.api_key.startswith("sk-"), - models, - ), - None, - ): - new_model = openai_model.copy() - new_model.model = "gpt-3.5-turbo" - return new_model + # Then, check for an API Key + if openai_model := next( + filter( + lambda m: hasattr(m, "api_key") + and m.api_key is not None + and m.api_key.startswith("sk-"), + models, + ), + None, + ): + new_model = openai_model.copy() + new_model.model = "gpt-3.5-turbo" + return new_model - # Return None, so re-ranking probably shouldn't happen - return None - - if desc := get_model_description(): - llm = sdk.config.create_llm(desc) - llm.start(sdk.ide.window_info.unique_id) - else: - return None + # Return None, so re-ranking probably shouldn't happen + return None class AnswerQuestionChroma(Step): @@ -167,7 +160,10 @@ class AnswerQuestionChroma(Step): model = sdk.models.chat.model # if model == "gpt-4": # model = "gpt-4-32k" # Not publicly available yet? - if model == "gpt-3.5-turbo": + if ( + model == "gpt-3.5-turbo" + and not sdk.models.chat.__class__.__name__ == "OpenAIFreeTrial" + ): model = "gpt-3.5-turbo-16k" await sdk.run_step( diff --git a/server/pyproject.toml b/server/pyproject.toml index 74da69b61..fc2309244 100644 --- a/server/pyproject.toml +++ b/server/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "continuedev" -version = "0.1.99" +version = "0.1.101" description = "" authors = ["Nate Sesti "] readme = "README.md"