add option to provide full watsonx endpoint

This commit is contained in:
Adam Shedivy 2024-09-03 10:11:17 -05:00
parent 8ccdb1798a
commit f7e03598f1
12 changed files with 36 additions and 5 deletions

View file

@ -18,5 +18,8 @@
"binary/": false,
"**/core/vendor/**": true,
"**/gui/dist": true
}
},
"eslint.workingDirectories": [
"./core"
]
}

View file

@ -57,6 +57,7 @@
"adf-to-md": "^1.1.0",
"async-mutex": "^0.5.0",
"axios": "^1.6.7",
"cheerio": "^1.0.0-rc.12",
"commander": "^12.0.0",
"comment-json": "^4.2.3",
"dbinfoz": "^0.1.4",

1
core/index.d.ts vendored
View file

@ -362,6 +362,7 @@ export interface LLMOptions {
watsonxProjectId?: string;
watsonxStopToken?: string;
watsonxApiVersion?: string;
watsonxFullUrl?: string;
cacheSystemMessage?: boolean;
}

View file

@ -118,6 +118,7 @@ export abstract class BaseLLM implements ILLM {
watsonxProjectId?: string;
watsonxStopToken?: string;
watsonxApiVersion?: string;
watsonxFullUrl?: string;
cacheSystemMessage?: boolean;
@ -180,6 +181,7 @@ export abstract class BaseLLM implements ILLM {
this.watsonxProjectId = options.watsonxProjectId;
this.watsonxStopToken = options.watsonxStopToken;
this.watsonxApiVersion = options.watsonxApiVersion;
this.watsonxFullUrl = options.watsonxFullUrl;
this.cacheSystemMessage = options.cacheSystemMessage;

View file

@ -84,6 +84,10 @@ class WatsonX extends BaseLLM {
}
}
getWatsonxEndpoint(): string {
return this.watsonxFullUrl ?? `${this.watsonxUrl}/ml/v1/text/generation_stream?version=${this.watsonxApiVersion}`;
}
static providerName: ModelProvider = "watsonx";
protected _convertMessage(message: ChatMessage) {
@ -186,8 +190,9 @@ class WatsonX extends BaseLLM {
const stopToken =
this.watsonxStopToken ??
(options.model?.includes("granite") ? "<|im_end|>" : undefined);
const url = this.getWatsonxEndpoint();
var response = await this.fetch(
`${this.watsonxUrl}/ml/v1/text/generation_stream?version=${this.watsonxApiVersion}`,
url,
{
method: "POST",
headers: {

View file

@ -1255,6 +1255,9 @@
"watsonxStopToken": {
"type": "string"
},
"watsonxFullUrl": {
"type": "string"
},
"model": {
"enum": [
"ibm/granite-13b-chat-v2",

View file

@ -1255,6 +1255,9 @@
"watsonxStopToken": {
"type": "string"
},
"watsonxFullUrl": {
"type": "string"
},
"model": {
"enum": [
"ibm/granite-13b-chat-v2",

View file

@ -1255,6 +1255,9 @@
"watsonxStopToken": {
"type": "string"
},
"watsonxFullUrl": {
"type": "string"
},
"model": {
"enum": [
"ibm/granite-13b-chat-v2",

View file

@ -1390,6 +1390,9 @@
"watsonxStopToken": {
"type": "string"
},
"watsonxFullUrl": {
"type": "string"
},
"model": {
"enum": [
"ibm/granite-13b-chat-v2",

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.9.206",
"version": "0.9.207",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.9.206",
"version": "0.9.207",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",

View file

@ -2,7 +2,7 @@
"name": "continue",
"icon": "media/icon.png",
"author": "Continue Dev, Inc",
"version": "0.9.206",
"version": "0.9.207",
"repository": {
"type": "git",
"url": "https://github.com/continuedev/continue"

View file

@ -513,6 +513,13 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
placeholder: "Enter the API Version",
defaultValue: "2023-05-29"
},
{
inputType: "text",
key: "watsonxFullUrl",
label: "Full watsonx URL",
placeholder: "http://us-south.dataplatform.cloud.ibm.com/m1/v1/text/generation_stream?version=2023-05-29",
required: false
},
// {
// inputType: "text",
// key: "title",