From 487ea20a141ec4cab40469cd0a2233ccada1a3a7 Mon Sep 17 00:00:00 2001 From: Sahand Sojoodi Date: Tue, 8 Oct 2024 15:57:44 -0400 Subject: [PATCH] Adding Cerebras related info --- core/index.d.ts | 7 +++++- core/llm/llms/Cerebras.ts | 20 ++++++++++++++++ core/llm/llms/index.ts | 2 ++ .../model-providers/more/cerebras.md | 20 ++++++++++++++++ .../src/main/resources/config_schema.json | 23 +++++++++++++++++-- extensions/vscode/config_schema.json | 23 +++++++++++++++++-- 6 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 core/llm/llms/Cerebras.ts create mode 100644 docs/docs/customize/model-providers/more/cerebras.md diff --git a/core/index.d.ts b/core/index.d.ts index 7c47ff5e5..7c69beac3 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -644,7 +644,9 @@ type ModelProvider = | "sambanova" | "nvidia" | "vllm" - | "mock"; + | "mock" + | "cerebras"; + export type ModelName = | "AUTODETECT" @@ -683,6 +685,9 @@ export type ModelName = // Llama 3 | "llama3-8b" | "llama3-70b" + // Llama 3.1 + | "llama3.1-8b" + | "llama3.1-70b" // Other Open-source | "phi2" | "phind-codellama-34b" diff --git a/core/llm/llms/Cerebras.ts b/core/llm/llms/Cerebras.ts new file mode 100644 index 000000000..103994221 --- /dev/null +++ b/core/llm/llms/Cerebras.ts @@ -0,0 +1,20 @@ +import { LLMOptions, ModelProvider } from "../../index.js"; +import OpenAI from "./OpenAI.js"; + +class Cerebras extends OpenAI { + static providerName: ModelProvider = "cerebras"; + static defaultOptions: Partial = { + apiBase: "https://api.cerebras.ai/v1/", + }; + maxStopWords: number | undefined = 4; + + private static modelConversion: { [key: string]: string } = { + "llama3.1-8b": "llama3.1-8b", + "llama3.1-70b": "llama-3.1-70b", + }; + protected _convertModelName(model: string): string { + return Cerebras.modelConversion[model] ?? model; + } +} + +export default Cerebras; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index dedae7795..ea8968f5a 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -11,6 +11,7 @@ import Anthropic from "./Anthropic"; import Azure from "./Azure"; import Bedrock from "./Bedrock"; import BedrockImport from "./BedrockImport"; +import Cerebras from "./Cerebras"; import Cloudflare from "./Cloudflare"; import Cohere from "./Cohere"; import DeepInfra from "./DeepInfra"; @@ -77,6 +78,7 @@ const LLMs = [ Vllm, SambaNova, Mock, + Cerebras, ]; export async function llmFromDescription( diff --git a/docs/docs/customize/model-providers/more/cerebras.md b/docs/docs/customize/model-providers/more/cerebras.md new file mode 100644 index 000000000..57d549830 --- /dev/null +++ b/docs/docs/customize/model-providers/more/cerebras.md @@ -0,0 +1,20 @@ +# Cerebras Inference + +Cerebras Inference uses specialized silicon to provides fast inference for the Llama3.1 8B and Llama3.1 70B models. + +1. Create an account in the portal [here](https://cloud.cerebras.ai/). +2. Create and copy the API key for use in Continue. +3. Update your Continue config file: + +```json title="config.json" +{ + "models": [ + { + "title": "Cerebras Llama 3.1 70B", + "provider": "cerebras", + "model": "llama3.1-70b", + "apiKey": "YOUR_API_KEY" + } + ] +} +``` diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 77de3cf8a..87b026e38 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -194,7 +194,8 @@ "openrouter", "sambanova", "nvidia", - "vllm" + "vllm", + "cerebras" ], "markdownEnumDescriptions": [ "### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)", @@ -224,7 +225,8 @@ "### IBM watsonx\nwatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.", "### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys).", "### NVIDIA NIMs\nNVIDIA offers a single API to access almost any language model. To find out more, visit the [LLM APIs Documentation](https://docs.api.nvidia.com/nim/reference/llm-apis).\nFor information specific to getting a key, please check out the [docs here](https://docs.nvidia.com/nim/large-language-models/latest/getting-started.html#option-1-from-api-catalog)", - "### vLLM\nvLLM is a highly performant way of hosting LLMs for a team. To get started, follow their [quickstart](https://docs.vllm.ai/en/latest/getting_started/quickstart.html) to set up your server." + "### vLLM\nvLLM is a highly performant way of hosting LLMs for a team. To get started, follow their [quickstart](https://docs.vllm.ai/en/latest/getting_started/quickstart.html) to set up your server.", + "### Cerebras\nCerebras Inference uses specialized silicon to provides superfast inference. To get started, get your API keys from [their console](https://cloud.cerebras.ai/)." ], "type": "string" }, @@ -1142,6 +1144,23 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["cerebras"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "enum": ["llama3.1-8b", "llama3.1-70b"] + } + } + } + }, { "if": { "properties": { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 77de3cf8a..87b026e38 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -194,7 +194,8 @@ "openrouter", "sambanova", "nvidia", - "vllm" + "vllm", + "cerebras" ], "markdownEnumDescriptions": [ "### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)", @@ -224,7 +225,8 @@ "### IBM watsonx\nwatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.", "### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys).", "### NVIDIA NIMs\nNVIDIA offers a single API to access almost any language model. To find out more, visit the [LLM APIs Documentation](https://docs.api.nvidia.com/nim/reference/llm-apis).\nFor information specific to getting a key, please check out the [docs here](https://docs.nvidia.com/nim/large-language-models/latest/getting-started.html#option-1-from-api-catalog)", - "### vLLM\nvLLM is a highly performant way of hosting LLMs for a team. To get started, follow their [quickstart](https://docs.vllm.ai/en/latest/getting_started/quickstart.html) to set up your server." + "### vLLM\nvLLM is a highly performant way of hosting LLMs for a team. To get started, follow their [quickstart](https://docs.vllm.ai/en/latest/getting_started/quickstart.html) to set up your server.", + "### Cerebras\nCerebras Inference uses specialized silicon to provides superfast inference. To get started, get your API keys from [their console](https://cloud.cerebras.ai/)." ], "type": "string" }, @@ -1142,6 +1144,23 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["cerebras"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "enum": ["llama3.1-8b", "llama3.1-70b"] + } + } + } + }, { "if": { "properties": {