This commit is contained in:
Nate 2024-08-28 10:12:44 -07:00
commit f75bc28479
11 changed files with 63 additions and 11 deletions

View file

@ -489,6 +489,7 @@ declare global {
| "flowise"
| "groq"
| "custom"
| "nvidia"
| "msty";
export type ModelName =

3
core/index.d.ts vendored
View file

@ -619,7 +619,8 @@ type ModelProvider =
| "openai-aiohttp"
| "msty"
| "watsonx"
| "openrouter";
| "openrouter"
| "nvidia";
export type ModelName =
| "AUTODETECT"

View file

@ -104,6 +104,9 @@ describe("BaseLLM", () => {
baseLLM.apiBase = "api.groq.com";
expect(baseLLM.supportsCompletions()).toBe(false);
baseLLM.apiBase = "integrate.api.nvidia.com";
expect(baseLLM.supportsCompletions()).toBe(false);
baseLLM.apiBase = "api.mistral.ai";
expect(baseLLM.supportsCompletions()).toBe(false);

View file

@ -68,6 +68,7 @@ export abstract class BaseLLM implements ILLM {
this.apiBase?.includes("api.groq.com") ||
this.apiBase?.includes("api.mistral.ai") ||
this.apiBase?.includes(":1337") ||
this.apiBase?.includes("integrate.api.nvidia.com") ||
this._llmOptions.useLegacyCompletionsEndpoint?.valueOf() === false
) {
// Jan + Groq + Mistral don't support completions : (

33
core/llm/llms/Nvidia.ts Normal file
View file

@ -0,0 +1,33 @@
import { LLMOptions, ModelProvider, ChatMessage } from "../../index.js";
import OpenAI from "./OpenAI.js";
class Nvidia extends OpenAI {
// NVIDIA NIMs currently limits the number of stops for Starcoder 2 to 4
// https://docs.api.nvidia.com/nim/reference/bigcode-starcoder2-7b-infer
protected maxStopWordsStarCoder = 4;
static providerName: ModelProvider = "nvidia";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "https://integrate.api.nvidia.com/v1/",
useLegacyCompletionsEndpoint: false,
};
protected _convertArgs(options: any, messages: ChatMessage[]) {
const url = new URL(this.apiBase!);
const finalOptions = {
messages: messages.map(this._convertMessage),
model: this._convertModelName(options.model),
max_tokens: options.maxTokens,
temperature: options.temperature,
top_p: options.topP,
frequency_penalty: options.frequencyPenalty,
presence_penalty: options.presencePenalty,
stop: options.model.includes("starcoder2")
? options.stop?.slice(0, this.maxStopWordsStarCoder)
: options.stop,
};
return finalOptions;
}
}
export default Nvidia;

View file

@ -38,6 +38,7 @@ import TextGenWebUI from "./TextGenWebUI";
import Together from "./Together";
import WatsonX from "./WatsonX";
import ContinueProxy from "./stubs/ContinueProxy";
import Nvidia from "./Nvidia";
const LLMs = [
Anthropic,
@ -70,6 +71,7 @@ const LLMs = [
Azure,
WatsonX,
OpenRouter,
Nvidia,
];
export async function llmFromDescription(

View file

@ -191,7 +191,8 @@
"azure",
"msty",
"watsonx",
"openrouter"
"openrouter",
"nvidia"
],
"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)",
@ -219,7 +220,8 @@
"### 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)",
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/Msty)",
"### 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)."
"### 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)"
],
"type": "string"
},

View file

@ -191,7 +191,8 @@
"azure",
"msty",
"watsonx",
"openrouter"
"openrouter",
"nvidia"
],
"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)",
@ -219,8 +220,8 @@
"### 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)",
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/Msty)",
"### 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)."
],
"### 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)" ],
"type": "string"
},
"model": {

View file

@ -191,7 +191,8 @@
"azure",
"msty",
"watsonx",
"openrouter"
"openrouter",
"nvidia"
],
"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)",
@ -219,8 +220,8 @@
"### 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)",
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/Msty)",
"### 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)."
],
"### 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)" ],
"type": "string"
},
"model": {

View file

@ -194,7 +194,8 @@
"azure",
"msty",
"watsonx",
"openrouter"
"openrouter",
"nvidia"
],
"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)",
@ -222,7 +223,8 @@
"### 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)",
"### Msty\nMsty is the simplest way to get started with online or local LLMs on all desktop platforms - Windows, Mac, and Linux. No fussing around, one-click and you are up and running. To get started, follow these steps:\n1. Download from [Msty.app](https://msty.app/), open the application, and click 'Setup Local AI'.\n2. Go to the Local AI Module page and download a model of your choice.\n3. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://continue.dev/docs/reference/Model%20Providers/Msty)",
"### 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)."
"### 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)"
],
"type": "string"
},

View file

@ -53,6 +53,11 @@ export function constructLlmApi(config: LlmApiConfig): BaseLlmApi {
...config,
apiBase: "https://api.groq.com/openai/v1/",
});
case "nvidia":
return new OpenAIApi({
...config,
apiBase: "https://integrate.api.nvidia.com/v1/",
});
case "fireworks":
return new OpenAIApi({
...config,