Fixed formatting changes
This commit is contained in:
parent
a6dfdef585
commit
b7cc65bc68
6 changed files with 50 additions and 49 deletions
14
core/index.d.ts
vendored
14
core/index.d.ts
vendored
|
|
@ -345,12 +345,12 @@ export interface LLMOptions {
|
|||
capabilities?: ModelCapability;
|
||||
|
||||
// WatsonX options
|
||||
WatsonxUrl?: string;
|
||||
WatsonxApiKey?: string;
|
||||
WatsonxZenApiKeyBase64?:string// Required if using watsonx software with ZenApiKey auth
|
||||
WatsonxUsername?:string;
|
||||
WatsonxPassword?:string;
|
||||
WatsonxProjectId?: string;
|
||||
watsonxUrl?: string;
|
||||
watsonxApiKey?: string;
|
||||
watsonxZenApiKeyBase64?:string// Required if using watsonx software with ZenApiKey auth
|
||||
watsonxUsername?:string;
|
||||
watsonxPassword?:string;
|
||||
watsonxProjectId?: string;
|
||||
}
|
||||
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
|
||||
T,
|
||||
|
|
@ -603,7 +603,7 @@ type ModelProvider =
|
|||
| "azure"
|
||||
| "openai-aiohttp"
|
||||
| "msty"
|
||||
| "WatsonX";
|
||||
| "watsonx";
|
||||
|
||||
export type ModelName =
|
||||
| "AUTODETECT"
|
||||
|
|
|
|||
|
|
@ -107,12 +107,12 @@ export abstract class BaseLLM implements ILLM {
|
|||
|
||||
// For WatsonX only.
|
||||
|
||||
WatsonxUrl?: string;
|
||||
WatsonxApiKey?: string;
|
||||
WatsonxZenApiKeyBase64?:string = "YOUR_WATSONX_ZENAPIKEY" // Required if using watsonx software with ZenApiKey auth
|
||||
WatsonxUsername?:string;
|
||||
WatsonxPassword?:string;
|
||||
WatsonxProjectId?: string;
|
||||
watsonxUrl?: string;
|
||||
watsonxApiKey?: string;
|
||||
watsonxZenApiKeyBase64?:string = "YOUR_WATSONX_ZENAPIKEY" // Required if using watsonx software with ZenApiKey auth
|
||||
watsonxUsername?:string;
|
||||
watsonxPassword?:string;
|
||||
watsonxProjectId?: string;
|
||||
|
||||
|
||||
private _llmOptions: LLMOptions;
|
||||
|
|
@ -167,11 +167,11 @@ export abstract class BaseLLM implements ILLM {
|
|||
this.aiGatewaySlug = options.aiGatewaySlug;
|
||||
this.apiBase = options.apiBase;
|
||||
// for watsonx only
|
||||
this.WatsonxUrl = options.WatsonxUrl;
|
||||
this.WatsonxApiKey = options.WatsonxApiKey;
|
||||
this.WatsonxProjectId = options.WatsonxProjectId;
|
||||
this.WatsonxUsername = options.WatsonxUsername;
|
||||
this.WatsonxPassword = options.WatsonxPassword;
|
||||
this.watsonxUrl = options.watsonxUrl;
|
||||
this.watsonxApiKey = options.watsonxApiKey;
|
||||
this.watsonxProjectId = options.watsonxProjectId;
|
||||
this.watsonxUsername = options.watsonxUsername;
|
||||
this.watsonxPassword = options.watsonxPassword;
|
||||
|
||||
if (this.apiBase && !this.apiBase.endsWith("/")) {
|
||||
this.apiBase = `${this.apiBase}/`;
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ class WatsonX extends BaseLLM {
|
|||
super(options);
|
||||
}
|
||||
async getBearerToken(): Promise<{ token: string, expiration: number }> {
|
||||
if (this.WatsonxUrl != null && this.WatsonxUrl.includes("cloud.ibm.com")) {
|
||||
if (this.watsonxUrl != null && this.watsonxUrl.includes("cloud.ibm.com")) {
|
||||
// watsonx SaaS
|
||||
const wxToken = await (await fetch(`https://iam.cloud.ibm.com/identity/token?apikey=${this.WatsonxApiKey}&grant_type=urn:ibm:params:oauth:grant-type:apikey`, {
|
||||
const wxToken = await (await fetch(`https://iam.cloud.ibm.com/identity/token?apikey=${this.watsonxApiKey}&grant_type=urn:ibm:params:oauth:grant-type:apikey`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
|
|
@ -35,27 +35,27 @@ class WatsonX extends BaseLLM {
|
|||
};
|
||||
} else {
|
||||
// watsonx Software
|
||||
if (this.WatsonxZenApiKeyBase64 && this.WatsonxZenApiKeyBase64 !== "YOUR_WATSONX_ZENAPIKEY") {
|
||||
if (this.watsonxZenApiKeyBase64 && this.watsonxZenApiKeyBase64 !== "YOUR_WATSONX_ZENAPIKEY") {
|
||||
// Using ZenApiKey auth
|
||||
return {
|
||||
token: this.WatsonxZenApiKeyBase64,
|
||||
token: this.watsonxZenApiKeyBase64,
|
||||
expiration: -1
|
||||
};
|
||||
} else {
|
||||
// Using username/password auth
|
||||
|
||||
const wxToken = await (await fetch(`${this.WatsonxUrl}/icp4d-api/v1/authorize`, {
|
||||
const wxToken = await (await fetch(`${this.watsonxUrl}/icp4d-api/v1/authorize`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
"username": this.WatsonxUsername,
|
||||
"password": this.WatsonxPassword
|
||||
"username": this.watsonxUsername,
|
||||
"password": this.watsonxPassword
|
||||
})
|
||||
})).json();
|
||||
const wxTokenExpiry = await (await fetch(`${this.WatsonxUrl}/usermgmt/v1/user/tokenExpiry`, {
|
||||
const wxTokenExpiry = await (await fetch(`${this.watsonxUrl}/usermgmt/v1/user/tokenExpiry`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
|
|
@ -70,7 +70,7 @@ class WatsonX extends BaseLLM {
|
|||
}
|
||||
}
|
||||
|
||||
static providerName: ModelProvider = "WatsonX";
|
||||
static providerName: ModelProvider = "watsonx";
|
||||
|
||||
protected _convertMessage(message: ChatMessage) {
|
||||
if (typeof message.content === "string") {
|
||||
|
|
@ -155,7 +155,7 @@ class WatsonX extends BaseLLM {
|
|||
} else {
|
||||
console.log(`Reusing token (expires in ${(watsonxConfig.accessToken.expiration - now) / 60} mins)`);
|
||||
}
|
||||
var streamResponse = await fetch(`${this.WatsonxUrl}/ml/v1/text/generation_stream?version=2023-05-29`, {
|
||||
var streamResponse = await fetch(`${this.watsonxUrl}/ml/v1/text/generation_stream?version=2023-05-29`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -171,7 +171,7 @@ class WatsonX extends BaseLLM {
|
|||
"repetition_penalty": 1
|
||||
},
|
||||
"model_id": options.model,
|
||||
"project_id": this.WatsonxProjectId
|
||||
"project_id": this.watsonxProjectId
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ function ConfigureProvider() {
|
|||
|
||||
{modelInfo?.collectInputFor?.map((d, idx) => {
|
||||
// Check the attribute is only for Watson X
|
||||
if (d.iswatsonxattribute) return null;
|
||||
if (d.isWatsonxAttribute) return null;
|
||||
if (d.required) return null;
|
||||
return (
|
||||
<div key={idx}>
|
||||
|
|
@ -214,7 +214,7 @@ function ConfigureProvider() {
|
|||
</details>
|
||||
)}
|
||||
|
||||
{(modelInfo?.collectInputFor?.filter((d) => d.iswatsonxattribute)
|
||||
{(modelInfo?.collectInputFor?.filter((d) => d.isWatsonxAttribute)
|
||||
.length || 0) > 0 && (
|
||||
<details>
|
||||
<summary className="mb-2 cursor-pointer">
|
||||
|
|
@ -223,7 +223,7 @@ function ConfigureProvider() {
|
|||
|
||||
{modelInfo?.collectInputFor?.map((d, idx) => {
|
||||
// Check the attribute is only for Watson X
|
||||
if (d.iswatsonxattribute)
|
||||
if (d.isWatsonxAttribute)
|
||||
return (
|
||||
<div key={idx}>
|
||||
<label htmlFor={d.key}>{d.label}</label>
|
||||
|
|
@ -248,7 +248,7 @@ function ConfigureProvider() {
|
|||
disabled={
|
||||
disableModelCards() ||
|
||||
modelInfo?.collectInputFor
|
||||
?.filter((d) => d.iswatsonxattribute)
|
||||
?.filter((d) => d.isWatsonxAttribute)
|
||||
.some((d) => !formMethods.watch(d.key))
|
||||
}
|
||||
showStop={false}
|
||||
|
|
|
|||
|
|
@ -693,7 +693,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 20_000,
|
||||
title: "Granite Chat",
|
||||
},
|
||||
providerOptions: ["WatsonX"],
|
||||
providerOptions: ["watsonx"],
|
||||
icon: "",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -706,7 +706,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 20_000,
|
||||
title: "Granite Code",
|
||||
},
|
||||
providerOptions: ["WatsonX"],
|
||||
providerOptions: ["watsonx"],
|
||||
icon: "WatsonX.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -719,7 +719,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
contextLength: 20_000,
|
||||
title: "WatsonX - Mistral",
|
||||
},
|
||||
providerOptions: ["WatsonX"],
|
||||
providerOptions: ["watsonx"],
|
||||
icon: "mistral.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -729,7 +729,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
"Llama-3 is an auto-regressive language model that uses an optimized transformer architecture.",
|
||||
params: {
|
||||
title: "Meta-llama3-8b",
|
||||
model: "meta-llama/llama-3-8b-chat",
|
||||
model: "meta-llama/llama-3-8b-instruct",
|
||||
contextLength: 20_000,
|
||||
},
|
||||
icon: "meta.png",
|
||||
|
|
@ -739,17 +739,17 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
description: "The number of parameters in the model",
|
||||
options: {
|
||||
"8b": {
|
||||
model: "meta-llama/llama-3-8b-chat",
|
||||
model: "meta-llama/llama-3-8b-instruct",
|
||||
title: "Meta-llama3-8b",
|
||||
},
|
||||
"70b": {
|
||||
model: "meta-llama/llama-3-70b-chat",
|
||||
model: "meta-llama/llama-3-70b-instruct",
|
||||
title: "Meta-llama3-70b",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
providerOptions: ["WatsonX"],
|
||||
providerOptions: ["watsonx"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
AUTODETECT: {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export interface InputDescriptor {
|
|||
required?: boolean;
|
||||
description?: string;
|
||||
[key: string]: any;
|
||||
isWatsonxAttribute?: boolean;
|
||||
}
|
||||
|
||||
export interface ProviderInfo {
|
||||
|
|
@ -504,9 +505,9 @@ After it's up and running, you can start using Continue.`,
|
|||
],
|
||||
collectInputFor: [...completionParamsInputsConfigs],
|
||||
},
|
||||
WatsonX: {
|
||||
watsonx: {
|
||||
title: "WatsonX",
|
||||
provider: "WatsonX",
|
||||
provider: "watsonx",
|
||||
refPage: "watsonX",
|
||||
description:
|
||||
"Explore foundation models from IBM and other third-parties depending on your use case.",
|
||||
|
|
@ -514,35 +515,35 @@ After it's up and running, you can start using Continue.`,
|
|||
collectInputFor: [
|
||||
{
|
||||
inputType: "text",
|
||||
key: "WatsonxUrl",
|
||||
key: "watsonxUrl",
|
||||
label: "WatsonX URL",
|
||||
placeholder: "Enter your WatsonxUrl",
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
key: "WatsonxApiKey",
|
||||
key: "watsonxApiKey",
|
||||
label: "WatsonX API Key",
|
||||
placeholder: "Enter your API key",
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
key: "WatsonxProjectId",
|
||||
key: "watsonxProjectId",
|
||||
label: "WatsonX Project Id",
|
||||
placeholder: "Enter your project Id",
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
key: "WatsonxUsername",
|
||||
key: "watsonxUsername",
|
||||
label: "WatsonX username",
|
||||
placeholder: "Enter your Username",
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
key: "WatsonxPassword",
|
||||
key: "wsatsonxPassword",
|
||||
label: "WatsonX Password",
|
||||
placeholder: "Enter your password",
|
||||
required: true,
|
||||
|
|
@ -552,14 +553,14 @@ After it's up and running, you can start using Continue.`,
|
|||
key: "title",
|
||||
label: "Model name",
|
||||
placeholder: "Enter the Model name",
|
||||
iswatsonxattribute: true,
|
||||
isWatsonxAttribute: true,
|
||||
},
|
||||
{
|
||||
inputType: "text",
|
||||
key: "model",
|
||||
label: "Model Id",
|
||||
placeholder: "Enter the model id",
|
||||
iswatsonxattribute: true,
|
||||
isWatsonxAttribute: true,
|
||||
},
|
||||
|
||||
...completionParamsInputsConfigs,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue