-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feature(community): Enable using chat and llms without providing project/space/development id (lightweight engine IBM) #7781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
818c888
f818281
0dc5cac
450f6cd
dd83aa9
b1ad066
bb3c2cf
ebe39f9
9a06b28
b9f65ac
fa73d2f
e953757
dfae651
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,11 +184,6 @@ export class WatsonxLLM< | |
) | ||
throw new Error("Maximum 1 id type can be specified per instance"); | ||
|
||
if (!("projectId" in fields || "spaceId" in fields || "idOrName" in fields)) | ||
throw new Error( | ||
"No id specified! At least id of 1 type has to be specified" | ||
); | ||
Comment on lines
-187
to
-190
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here |
||
|
||
this.serviceUrl = fields?.serviceUrl; | ||
const { | ||
watsonxAIApikey, | ||
|
@@ -281,7 +276,7 @@ export class WatsonxLLM< | |
return { spaceId: this.spaceId, modelId: this.model }; | ||
else if (this.idOrName) | ||
return { idOrName: this.idOrName, modelId: this.model }; | ||
else return { spaceId: this.spaceId, modelId: this.model }; | ||
else return { modelId: this.model }; | ||
} | ||
|
||
async listModels() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,24 +125,21 @@ describe("LLM unit tests", () => { | |
|
||
testProperties(instance, testProps); | ||
}); | ||
}); | ||
|
||
describe("Negative tests", () => { | ||
test("Missing id", async () => { | ||
const testProps: WatsonxInputLLM = { | ||
model: "ibm/granite-13b-chat-v2", | ||
version: "2024-05-31", | ||
serviceUrl: process.env.WATSONX_AI_SERVICE_URL as string, | ||
}; | ||
expect( | ||
() => | ||
new WatsonxLLM({ | ||
...testProps, | ||
...fakeAuthProp, | ||
}) | ||
).toThrowError(); | ||
const instance = new WatsonxLLM({ | ||
...testProps, | ||
...fakeAuthProp, | ||
}); | ||
expect(instance).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe("Negative tests", () => { | ||
test("Missing other props", async () => { | ||
// @ts-expect-error Intentionally passing not enough parameters | ||
const testPropsProjectId: WatsonxInputLLM = { | ||
|
@@ -156,17 +153,6 @@ describe("LLM unit tests", () => { | |
...fakeAuthProp, | ||
}) | ||
).toThrowError(); | ||
// @ts-expect-error Intentionally passing not enough parameters | ||
const testPropsServiceUrl: WatsonxInputLLM = { | ||
serviceUrl: process.env.WATSONX_AI_SERVICE_URL as string, | ||
}; | ||
expect( | ||
() => | ||
new WatsonxLLM({ | ||
...testPropsServiceUrl, | ||
...fakeAuthProp, | ||
}) | ||
).toThrowError(); | ||
Comment on lines
-159
to
-169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming it's possible to check for the lightweight engine, you could keep this logic here, but pass whatever is necessary to detect that use |
||
const testPropsVersion = { | ||
version: "2024-05-31", | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep this check and only bypass it when the lightweight engine is in use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that would enforce us to use a flag ex.
lightweight: true
. Unless user uses a lightweight engine the API is going to throw an error "No spaceId nor projectId is present" so this is taken care of there.Also, we want to match with our Python Langchain SDK implementation. Assuming whenever id is not passed user chooses lightweight engine. If id of any type is mistakenly not passed the API will throw an error letting user know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FilipZmijewski just to clarify, are you saying that the API does check this and therefore the check in our code is unnecessary? The benefit of having the check in our code is that it causes us to throw a nice/readable error. Is there no other way that we can infer that the user is using the lightweight engine?
By the way, feel free to reply in your native language if you're more comfortable that way. LLMs are very good at translating these days 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjamincburns We would like to match the solution with what we have in SDK (both python and node.js) and also langchain IBM python meaning "no id provided -> lightweight engine in use". In case of lightweight engine unavailable the API will throw an error, quite clear to understand,
Missing either space_id or project_id or wml_instance_crn
. One thing that could be added is disabling error check depending onserviceUrl
provided but this is not ideal since not allIBM watsonx.ai software
instalations will allow user to use lightweight engine.Haha, thanks. I enjoy speaking/writing in English so that works!