-
Notifications
You must be signed in to change notification settings - Fork 19.3k
fix(langchain): correctly initialize huggingface models in init_chat_model #33167
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
base: master
Are you sure you want to change the base?
fix(langchain): correctly initialize huggingface models in init_chat_model #33167
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
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.
@aaronseq12 thanks for the contribution -- there seem to be a lot of typos in this PR, do you want to try and resolve?
@eyurtsev yup got some time free, will be working on this! |
- Move exception messages to variables to satisfy EM101 rule - Use shorter, more concise error messages to satisfy TRY003 rule
Linting Issues FixedI've resolved the Ruff linting errors that were preventing this PR from passing checks: Issues Resolved:EM101 Rule Violations:
TRY003 Rule Violations:
Changes Made:
The PR should now pass all linting checks while maintaining the same functional behavior for HuggingFace model initialization. |
Description:
This change fixes a
ValidationError
that occurred when usinginit_chat_model
withmodel_provider="huggingface"
.The previous implementation incorrectly passed all keyword arguments directly to the
ChatHuggingFace
constructor, which expects anllm
object rather than amodel_id
. This caused a Pydantic error when arguments liketask
were provided.The fix updates the logic to first correctly instantiate a
HuggingFacePipeline
object using thefrom_model_id
class method, which properly handles arguments liketask
. This initialized pipeline object is then passed to theChatHuggingFace
wrapper, resolving the issue.A unit test has been added to verify the fix and prevent regressions.
Closes #28226
Issue:
Fixes #28226
Dependencies:
None