diff --git a/core/index.d.ts b/core/index.d.ts index 64fe1c6fa..d3ff2a4b8 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -352,6 +352,7 @@ export interface LLMOptions { watsonxUsername?: string; watsonxPassword?: string; watsonxProjectId?: string; + watsonxStopToken?: string; } type RequireAtLeastOne = Pick< T, diff --git a/core/llm/index.ts b/core/llm/index.ts index 8ecc954be..ca3c032a6 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -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}/`; diff --git a/core/llm/llms/WatsonX.ts b/core/llm/llms/WatsonX.ts index 29ca63c39..747a10c6a 100644 --- a/core/llm/llms/WatsonX.ts +++ b/core/llm/llms/WatsonX.ts @@ -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, diff --git a/docs/docs/reference/Model Providers/watsonx.md b/docs/docs/reference/Model Providers/watsonx.md index 1d672fee3..b6a239946 100644 --- a/docs/docs/reference/Model Providers/watsonx.md +++ b/docs/docs/reference/Model Providers/watsonx.md @@ -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. diff --git a/docs/docs/setup/model-providers.md b/docs/docs/setup/model-providers.md index af7559dad..3681a2bb9 100644 --- a/docs/docs/setup/model-providers.md +++ b/docs/docs/setup/model-providers.md @@ -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 diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index ae3f26e66..180454880 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -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" diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index ae3f26e66..180454880 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -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" diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index ae3f26e66..180454880 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -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" diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 222e41a7b..fcbba3140 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -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" diff --git a/gui/src/pages/AddNewModel/ConfigureProvider.tsx b/gui/src/pages/AddNewModel/ConfigureProvider.tsx index f4a199c21..b46db1931 100644 --- a/gui/src/pages/AddNewModel/ConfigureProvider.tsx +++ b/gui/src/pages/AddNewModel/ConfigureProvider.tsx @@ -161,7 +161,7 @@ function ConfigureProvider() { />
- {/* 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" ? ( diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index 21fddbb17..1c7756e3d 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -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", diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 6d6f51e73..85d566a11 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -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://.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,