diff --git a/core/llm/llms/NCompass.ts b/core/llm/llms/NCompass.ts new file mode 100644 index 000000000..56fad94c5 --- /dev/null +++ b/core/llm/llms/NCompass.ts @@ -0,0 +1,62 @@ +import { ChatMessage, CompletionOptions, LLMOptions } from "../../index.js"; +import { ChatCompletionCreateParams } from "openai/resources/index"; + +import OpenAI from "./OpenAI.js"; + +class NCompass extends OpenAI { + static providerName = "ncompass"; + static defaultOptions: Partial = { + apiBase: "https://api.ncompass.tech/v1" + }; + static embeddingsApiEndpoint: "https://api.gcp.ncompass.tech/v1/embeddings" + + private static modelConversion: { [key: string]: string } = { + "qwen2.5-coder-32b": "Qwen/Qwen2.5-Coder-32B-Instruct", + "qwen2.5-72b": "Qwen/Qwen2.5-72B-Instruct", + "llama3.3-70b": "meta-llama/Llama-3.3-70B-Instruct", + "llama3.1-8b": "meta-llama/Llama-3.1-8B-Instruct", + }; + protected _convertModelName(model: string): string { + return NCompass.modelConversion[model] ?? model; + } + + protected _convertArgs( + options: CompletionOptions, + messages: ChatMessage[], + ): ChatCompletionCreateParams { + const finalOptions = super._convertArgs(options, messages); + finalOptions.model = this._convertModelName(options.model); + return finalOptions; + } + + protected _getHeaders() { + const headers = super._getHeaders() as { "Content-Type": string; Authorization: string; "api-key": string; Accept?: string }; + headers["Accept"] = "text/event-stream"; + return headers; + } + + protected async _embed(chunks: string[]): Promise { + const resp = await this.fetch(NCompass.embeddingsApiEndpoint, { + method: "POST", + body: JSON.stringify({ + input: chunks, + model: this.model, + ...this.extraBodyProperties(), + }), + headers: { + Authorization: `Bearer ${this.apiKey}`, + "Content-Type": "application/json", + }, + }); + + if (!resp.ok) { + throw new Error(await resp.text()); + } + + const data = (await resp.json()) as any; + return data.data.map((result: { embedding: number[] }) => result.embedding); + } + +} + +export default NCompass; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index 20bc8b710..32cda4aec 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -19,6 +19,7 @@ import Cohere from "./Cohere"; import DeepInfra from "./DeepInfra"; import Deepseek from "./Deepseek"; import Fireworks from "./Fireworks"; +import NCompass from "./NCompass"; import Flowise from "./Flowise"; import FreeTrial from "./FreeTrial"; import FunctionNetwork from "./FunctionNetwork"; @@ -81,6 +82,7 @@ export const LLMClasses = [ Flowise, Groq, Fireworks, + NCompass, ContinueProxy, Cloudflare, Deepseek, diff --git a/docs/docs/customize/model-providers/more/ncompass.mdx b/docs/docs/customize/model-providers/more/ncompass.mdx new file mode 100644 index 000000000..e6f98c296 --- /dev/null +++ b/docs/docs/customize/model-providers/more/ncompass.mdx @@ -0,0 +1,34 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + +# nCompass + +The nCompass Technologies API exposes an extremely fast inference engine for open-source language models. You can sign up [here](https://app.ncompass.tech/api-settings), copy your API key on the initial welcome screen, and then hit the play button on any model from the [nCompass Models list](https://console.ncompass.tech/models). Change `~/.continue/config.json` to look like this: + + + + ```yaml title="Package or config.yaml" + models: + - name: Ncompass Qwen2.5 Coder + provider: ncompass + model: Qwen/Qwen2.5-Coder-32B-Instruct + apiKey: + ``` + + + ```json title="config.json" + { + "models": [ + { + "title": "Ncompass Qwen2.5 Coder", + "provider": "ncompass", + "model": "Qwen/Qwen2.5-Coder-32B-Instruct", + "apiKey": "" + } + ] + } + ``` + + + +[View the source](https://github.com/continuedev/continue/blob/main/core/llm/llms/NCompass.ts) diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index a2d2f119d..e43fa81a9 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -193,6 +193,7 @@ "deepinfra", "groq", "fireworks", + "ncompass", "cloudflare", "deepseek", "azure", @@ -238,6 +239,7 @@ "### DeepInfra\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/deepinfra)", "### Groq\nGroq provides extremely fast inference of open-source language models. To get started, obtain an API key from [their console](https://console.groq.com/keys).", "### Fireworks\nFireworks is a fast inference engine for open-source language models. To get started, obtain an API key from [their console](https://fireworks.ai/api-keys).", + "### Ncompass\nnCompass is an extremely fast inference engine for open-source language models. To get started, obtain an API key from [their console](https://app.ncompass.tech/api-settings).", "### Cloudflare Workers AI\n\n[Reference](https://developers.cloudflare.com/workers-ai/)", "### Deepseek\n Deepseek's API provides the best pricing for their state-of-the-art Deepseek Coder models. To get started, obtain an API key from [their console](https://platform.deepseek.com/api_keys)", "### Azure OpenAI\n Azure OpenAI lets you securely run OpenAI's models on Azure. To get started, follow the steps [here](https://docs.continue.dev/reference/Model%20Providers/azure)", @@ -265,7 +267,7 @@ }, "apiKey": { "title": "Api Key", - "description": "OpenAI, Anthropic, Cohere, Together, Novita AI, or other API key", + "description": "OpenAI, Anthropic, Cohere, Together, Novita AI, nCompass, or other API key", "type": "string" }, "apiBase": { @@ -482,6 +484,7 @@ "huggingface-inference-api", "replicate", "together", + "ncompass", "novita", "cloudflare", "sambanova", @@ -1370,6 +1373,23 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["ncompass"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "enum": ["qwen2.5-coder-32b", "qwen2.5-72b", "llama3.3-70b"] + } + } + } + }, { "if": { "properties": { diff --git a/gui/public/logos/ncompass.png b/gui/public/logos/ncompass.png new file mode 100644 index 000000000..09c306695 Binary files /dev/null and b/gui/public/logos/ncompass.png differ diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index acb558115..28e1ba3e1 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -498,7 +498,20 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 8192, }, icon: "meta.png", - providerOptions: ["groq", "scaleway", "nebius"], + providerOptions: ["groq", "scaleway", "nebius", "ncompass"], + isOpenSource: false, + }, + llama3370bChat: { + title: "Llama3.3 70b Chat", + description: "A model from Meta, fine-tuned for chat", + refUrl: "", + params: { + title: "Llama3.3-70b", + model: "llama3.3-70b", + contextLength: 65536, + }, + icon: "meta.png", + providerOptions: ["ncompass"], isOpenSource: false, }, llama3170bChat: { @@ -1373,7 +1386,7 @@ export const models: { [key: string]: ModelPackage } = { contextLength: 32_000, }, icon: "qwen.png", - providerOptions: ["scaleway", "nebius"], + providerOptions: ["scaleway", "nebius", "ncompass"], isOpenSource: true, }, grokBeta: { diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 9809ab7b8..c759ef4d9 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -409,6 +409,38 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n }), apiKeyUrl: "https://api.together.xyz/settings/api-keys", }, + ncompass: { + title: "nCompass", + provider: "ncompass", + refPage: "ncompass", + description: + "Use the nCompass API for extremely fast streaming of open-source models", + icon: "ncompass.png", + longDescription: `nCompass is an extremely fast inference engine for open-source language models. To get started, obtain an API key from [their console](https://app.ncompass.tech/api-settings).`, + tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource], + params: { + apiKey: "", + }, + collectInputFor: [ + { + inputType: "text", + key: "apiKey", + label: "API Key", + placeholder: "Enter your nCompass API key", + required: true, + }, + ...completionParamsInputsConfigs, + ], + packages: [ + models.llama318bChat, + models.llama3370bChat, + models.Qwen25Coder32b, + ].map((p) => { + p.params.contextLength = 4096; + return p; + }), + apiKeyUrl: "https://app.ncompass.tech/api-settings", + }, novita: { title: "NovitaAI", provider: "novita", diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index 094920e63..5f2dd4eae 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -73,6 +73,8 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined { return openAICompatible("https://api.fireworks.ai/inference/v1/", config); case "together": return openAICompatible("https://api.together.xyz/v1/", config); + case "ncompass": + return openAICompatible("https://api.ncompass.tech/v1", config); case "novita": return openAICompatible("https://api.novita.ai/v3/openai", config); case "nebius":