Skip to content

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

Merged
merged 13 commits into from
Mar 11, 2025

Conversation

FilipZmijewski
Copy link
Contributor

@FilipZmijewski FilipZmijewski commented Feb 28, 2025

Providing small changes in order to allow user to use inference methods in both LLM and chat class

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 28, 2025
@FilipZmijewski FilipZmijewski marked this pull request as draft February 28, 2025 15:46
@dosubot dosubot bot added auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features labels Feb 28, 2025
@FilipZmijewski FilipZmijewski marked this pull request as ready for review February 28, 2025 16:35
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. auto:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Feb 28, 2025
@FilipZmijewski FilipZmijewski changed the title feature: Enable using chat and alms without providing project/space/development id (lightweight engine) feature(community): Enable using chat and alms without providing project/space/development id (lightweight engine) Mar 4, 2025
Comment on lines -468 to -471
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"
);
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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 😄

Copy link
Contributor Author

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 on serviceUrl provided but this is not ideal since not all IBM watsonx.ai software instalations will allow user to use lightweight engine.

Haha, thanks. I enjoy speaking/writing in English so that works!

Comment on lines -187 to -190
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"
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here

Comment on lines -159 to -169
// @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();
Copy link
Collaborator

Choose a reason for hiding this comment

The 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

@FilipZmijewski FilipZmijewski changed the title feature(community): Enable using chat and alms without providing project/space/development id (lightweight engine) feature(community): Enable using chat and llms without providing project/space/development id (lightweight engine) Mar 4, 2025
Copy link
Collaborator

@benjamincburns benjamincburns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarifications!

@dosubot dosubot bot added lgtm PRs that are ready to be merged as-is size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 6, 2025
Copy link

vercel bot commented Mar 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Mar 7, 2025 9:45am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Mar 7, 2025 9:45am

@FilipZmijewski FilipZmijewski force-pushed the main branch 2 times, most recently from 61f672a to ccbe52d Compare March 7, 2025 09:12
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. size:XL This PR changes 500-999 lines, ignoring generated files. labels Mar 7, 2025
@FilipZmijewski
Copy link
Contributor Author

@benjamincburns previous tests failed for some reason, I merged with main and hopefully this is fine now.

@FilipZmijewski FilipZmijewski changed the title feature(community): Enable using chat and llms without providing project/space/development id (lightweight engine) feature(community): Enable using chat and llms without providing project/space/development id (lightweight engine IBM) Mar 11, 2025
@jacoblee93 jacoblee93 merged commit b86367a into langchain-ai:main Mar 11, 2025
34 checks passed
@jacoblee93
Copy link
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features auto:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs lgtm PRs that are ready to be merged as-is size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants