Skip to content

Conversation

aaron-seq
Copy link

@aaron-seq aaron-seq commented Sep 14, 2025

Description:

This change fixes a ValidationError that occurred when using init_chat_model with model_provider="huggingface".

The previous implementation incorrectly passed all keyword arguments directly to the ChatHuggingFace constructor, which expects an llm object rather than a model_id. This caused a Pydantic error when arguments like task were provided.

The fix updates the logic to first correctly instantiate a HuggingFacePipeline object using the from_model_id class method, which properly handles arguments like task. This initialized pipeline object is then passed to the ChatHuggingFace wrapper, resolving the issue.

A unit test has been added to verify the fix and prevent regressions.

Issue:

Fixes #28226

Dependencies:

None

Copy link

vercel bot commented Sep 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
langchain Ready Ready Preview Comment Sep 25, 2025 0:45am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix langchain Related to the package `langchain`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

init_chat_model doesn't work with huggingface models

2 participants