Fix watsonx stop tokens (#1959)
* add stop token param for watsonx provider * add stop token to config_schema * add stop token param for watsonx provider * add stop token to config_schema * update model id for granite code, remove system message * update code instruct model id in config schemas * add stop token param for watsonx provider * add stop token to config_schema * update model id for granite code, remove system message * update code instruct model id in config schemas * use lowercase x * remove rpg test file
This commit is contained in:
parent
042f308b44
commit
eabcdd16dd
12 changed files with 52 additions and 31 deletions
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -352,6 +352,7 @@ export interface LLMOptions {
|
|||
watsonxUsername?: string;
|
||||
watsonxPassword?: string;
|
||||
watsonxProjectId?: string;
|
||||
watsonxStopToken?: string;
|
||||
}
|
||||
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
|
||||
T,
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
watsonxUsername?: string;
|
||||
watsonxPassword?: string;
|
||||
watsonxProjectId?: string;
|
||||
watsonxStopToken?: string;
|
||||
|
||||
private _llmOptions: LLMOptions;
|
||||
|
||||
|
|
@ -176,6 +177,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
this.watsonxProjectId = options.watsonxProjectId;
|
||||
this.watsonxUsername = options.watsonxUsername;
|
||||
this.watsonxPassword = options.watsonxPassword;
|
||||
this.watsonxStopToken = options.watsonxStopToken;
|
||||
|
||||
if (this.apiBase && !this.apiBase.endsWith("/")) {
|
||||
this.apiBase = `${this.apiBase}/`;
|
||||
|
|
|
|||
|
|
@ -175,6 +175,8 @@ class WatsonX extends BaseLLM {
|
|||
if (watsonxConfig.accessToken.token === undefined) {
|
||||
throw new Error(`Something went wrong. Check your credentials, please.`);
|
||||
}
|
||||
|
||||
const stopToken = this.watsonxStopToken ?? (options.model.includes("granite") ? "<|im_end|>" : undefined);
|
||||
var streamResponse = await fetch(
|
||||
`${this.watsonxUrl}/ml/v1/text/generation_stream?version=2023-05-29`,
|
||||
{
|
||||
|
|
@ -189,7 +191,8 @@ class WatsonX extends BaseLLM {
|
|||
decoding_method: "greedy",
|
||||
max_new_tokens: options.maxTokens ?? 1024,
|
||||
min_new_tokens: 1,
|
||||
stop_sequences: [],
|
||||
stop_sequences: stopToken ? [stopToken] : [],
|
||||
include_stop_sequence: false,
|
||||
repetition_penalty: 1,
|
||||
},
|
||||
model_id: options.model,
|
||||
|
|
@ -231,12 +234,10 @@ class WatsonX extends BaseLLM {
|
|||
generatedChunk += result.generated_text || "";
|
||||
});
|
||||
} catch (e) {
|
||||
throw e;
|
||||
console.error(`Error parsing JSON string: ${dataStr}`, e);
|
||||
}
|
||||
}
|
||||
});
|
||||
generatedChunk = generatedChunk.replaceAll("<|im_end|>", " ");
|
||||
generatedChunk = generatedChunk.replaceAll("<|im_start|> ", "\n");
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: generatedChunk,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# WatsonX
|
||||
# Watsonx
|
||||
|
||||
Watsonx, 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.
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ You can run a model on your local computer using:
|
|||
- [TensorRT-LLM](https://github.com/NVIDIA/trt-llm-as-openai-windows?tab=readme-ov-file#examples) (OpenAI compatible server)
|
||||
- [IPEX-LLM](../reference/Model%20Providers/ipex_llm.md) (Local LLM on Intel GPU)
|
||||
- [Msty](../reference/Model%20Providers/msty.md)
|
||||
- [WatsonX](../reference/Model%20Providers/watsonx.md)
|
||||
- [Watsonx](../reference/Model%20Providers/watsonx.md)
|
||||
|
||||
### Remote
|
||||
|
||||
|
|
|
|||
7
docs/static/schemas/config.json
vendored
7
docs/static/schemas/config.json
vendored
|
|
@ -214,7 +214,7 @@
|
|||
"### 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)",
|
||||
"### 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)",
|
||||
"### 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."
|
||||
"### 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."
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
@ -1235,10 +1235,13 @@
|
|||
"watsonxProjectId": {
|
||||
"type": "string"
|
||||
},
|
||||
"watsonxStopToken": {
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
"enum": [
|
||||
"ibm/granite-13b-chat-v2",
|
||||
"ibm/granite-13b-instruct-v2",
|
||||
"ibm/granite-20b-code-instruct",
|
||||
"mistralai/mistral-large",
|
||||
"meta-llama/llama-3-8b-instruct",
|
||||
"meta-llama/llama-3-70b-instruct"
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@
|
|||
"### 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)",
|
||||
"### 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)",
|
||||
"### 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."
|
||||
"### 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."
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
@ -1235,10 +1235,13 @@
|
|||
"watsonxProjectId": {
|
||||
"type": "string"
|
||||
},
|
||||
"watsonxStopToken": {
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
"enum": [
|
||||
"ibm/granite-13b-chat-v2",
|
||||
"ibm/granite-13b-instruct-v2",
|
||||
"ibm/granite-20b-code-instruct",
|
||||
"mistralai/mistral-large",
|
||||
"meta-llama/llama-3-8b-instruct",
|
||||
"meta-llama/llama-3-70b-instruct"
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@
|
|||
"### 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)",
|
||||
"### 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)",
|
||||
"### 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."
|
||||
"### 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."
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
@ -1235,10 +1235,13 @@
|
|||
"watsonxProjectId": {
|
||||
"type": "string"
|
||||
},
|
||||
"watsonxStopToken": {
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
"enum": [
|
||||
"ibm/granite-13b-chat-v2",
|
||||
"ibm/granite-13b-instruct-v2",
|
||||
"ibm/granite-20b-code-instruct",
|
||||
"mistralai/mistral-large",
|
||||
"meta-llama/llama-3-8b-instruct",
|
||||
"meta-llama/llama-3-70b-instruct"
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@
|
|||
"### 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)",
|
||||
"### 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)",
|
||||
"### 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."
|
||||
"### 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."
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
@ -1370,10 +1370,13 @@
|
|||
"watsonxProjectId": {
|
||||
"type": "string"
|
||||
},
|
||||
"watsonxStopToken": {
|
||||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
"enum": [
|
||||
"ibm/granite-13b-chat-v2",
|
||||
"ibm/granite-13b-instruct-v2",
|
||||
"ibm/granite-20b-code-instruct",
|
||||
"mistralai/mistral-large",
|
||||
"meta-llama/llama-3-8b-instruct",
|
||||
"meta-llama/llama-3-70b-instruct"
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ function ConfigureProvider() {
|
|||
/>
|
||||
<br />
|
||||
|
||||
{/* The WatsonX Authentication coukd be done by two different ways
|
||||
{/* The Watsonx Authentication coukd be done by two different ways
|
||||
1 ==> Using Api key
|
||||
2 ==> Using Credentials */}
|
||||
{providerName === "watsonx" ? (
|
||||
|
|
|
|||
|
|
@ -722,7 +722,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
isOpenSource: false,
|
||||
},
|
||||
graniteChat: {
|
||||
title: "WatsonX - Granite Chat",
|
||||
title: "Watsonx - Granite Chat",
|
||||
description:
|
||||
"The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
|
||||
params: {
|
||||
|
|
@ -735,27 +735,26 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
isOpenSource: false,
|
||||
},
|
||||
graniteCode: {
|
||||
title: "WatsonX - Granite Code",
|
||||
title: "Watsonx - Granite Code",
|
||||
description:
|
||||
"The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
|
||||
params: {
|
||||
model: "ibm/granite-13b-instruct-v2",
|
||||
model: "ibm/granite-20b-code-instruct",
|
||||
contextLength: 20_000,
|
||||
title: "Granite Code",
|
||||
systemMessage: `You are Granite Chat, an AI language model developed by IBM. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior. You always respond to greetings (for example, hi, hello, g'day, morning, afternoon, evening, night, what's up, nice to meet you, sup, etc) with "Hello! I am Granite Chat, created by IBM. How can I help you today?". Please do not say anything else and do not start a conversation.`,
|
||||
title: "Granite Code"
|
||||
},
|
||||
providerOptions: ["watsonx"],
|
||||
icon: "WatsonX.png",
|
||||
icon: "Watsonx.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
MistralLarge: {
|
||||
title: "WatsonX - Mistral",
|
||||
title: "Watsonx - Mistral",
|
||||
description:
|
||||
"Mistral Large, the most advanced Large Language Model (LLM) developed by Mistral Al, is an exceptionally powerful model.",
|
||||
params: {
|
||||
model: "mistralai/mistral-large",
|
||||
contextLength: 20_000,
|
||||
title: "WatsonX - Mistral",
|
||||
title: "Watsonx - Mistral",
|
||||
},
|
||||
providerOptions: ["watsonx"],
|
||||
icon: "mistral.png",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export interface InputDescriptor {
|
|||
required?: boolean;
|
||||
description?: string;
|
||||
[key: string]: any;
|
||||
// the following are used only for WatsonX provider
|
||||
// the following are used only for Watsonx provider
|
||||
// these attributes are used to determine whether the input is used in Api Authentication or Credentials section
|
||||
isWatsonxAuthenticatedByApiKey?: boolean;
|
||||
isWatsonxAuthenticatedByCredentials?: boolean;
|
||||
|
|
@ -482,7 +482,7 @@ After it's up and running, you can start using Continue.`,
|
|||
],
|
||||
},
|
||||
watsonx: {
|
||||
title: "WatsonX",
|
||||
title: "Watsonx",
|
||||
provider: "watsonx",
|
||||
refPage: "watsonX",
|
||||
description:
|
||||
|
|
@ -492,7 +492,7 @@ After it's up and running, you can start using Continue.`,
|
|||
{
|
||||
inputType: "text",
|
||||
key: "watsonxUrl",
|
||||
label: "WatsonX URL",
|
||||
label: "Watsonx URL",
|
||||
placeholder: "http://<region>.dataplatform.cloud.ibm.com",
|
||||
required: true,
|
||||
isWatsonxAuthenticatedByApiKey: true,
|
||||
|
|
@ -501,7 +501,7 @@ After it's up and running, you can start using Continue.`,
|
|||
{
|
||||
inputType: "text",
|
||||
key: "watsonxApiKey",
|
||||
label: "WatsonX API Key",
|
||||
label: "Watsonx API Key",
|
||||
placeholder: "Enter your API key",
|
||||
required: true,
|
||||
isWatsonxAuthenticatedByApiKey: true,
|
||||
|
|
@ -509,7 +509,7 @@ After it's up and running, you can start using Continue.`,
|
|||
{
|
||||
inputType: "text",
|
||||
key: "watsonxProjectId",
|
||||
label: "WatsonX Project Id",
|
||||
label: "Watsonx Project Id",
|
||||
placeholder: "Enter your project Id",
|
||||
required: true,
|
||||
isWatsonxAuthenticatedByApiKey: true,
|
||||
|
|
@ -518,7 +518,7 @@ After it's up and running, you can start using Continue.`,
|
|||
{
|
||||
inputType: "text",
|
||||
key: "watsonxUsername",
|
||||
label: "WatsonX Username",
|
||||
label: "Watsonx Username",
|
||||
placeholder: "Enter your Username",
|
||||
required: true,
|
||||
isWatsonxAuthenticatedByCredentials: true,
|
||||
|
|
@ -526,7 +526,7 @@ After it's up and running, you can start using Continue.`,
|
|||
{
|
||||
inputType: "text",
|
||||
key: "watsonxPassword",
|
||||
label: "WatsonX Password",
|
||||
label: "Watsonx Password",
|
||||
placeholder: "Enter your password",
|
||||
required: true,
|
||||
isWatsonxAuthenticatedByCredentials: true,
|
||||
|
|
@ -545,10 +545,16 @@ After it's up and running, you can start using Continue.`,
|
|||
placeholder: "ibm/granite-13b-chat-v2",
|
||||
isWatsonxAttribute: true,
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
key: "watsonxStopToken",
|
||||
label: "Stop Token",
|
||||
placeholder: "<|im_end|>",
|
||||
},
|
||||
|
||||
...completionParamsInputsConfigs,
|
||||
],
|
||||
icon: "WatsonX.png",
|
||||
icon: "Watsonx.png",
|
||||
tags: [ModelProviderTags.RequiresApiKey],
|
||||
packages: [
|
||||
models.graniteCode,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue