mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-13 06:40:04 +00:00
huggingface: Undefined model_id fix (#31358)
**Description:** This change fixes the undefined model_id issue when instantiating [ChatHuggingFace](https://github.com/langchain-ai/langchain/blob/master/libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py#L306) **Issue:** Fixes https://github.com/langchain-ai/langchain/issues/31357 @baskaryan @hwchase17
This commit is contained in:
parent
b7f34749b1
commit
729526ff7c
@ -775,12 +775,12 @@ class ChatHuggingFace(BaseChatModel):
|
|||||||
elif _is_huggingface_pipeline(self.llm):
|
elif _is_huggingface_pipeline(self.llm):
|
||||||
from transformers import AutoTokenizer # type: ignore[import]
|
from transformers import AutoTokenizer # type: ignore[import]
|
||||||
|
|
||||||
|
self.model_id = self.model_id or self.llm.model_id
|
||||||
self.tokenizer = (
|
self.tokenizer = (
|
||||||
AutoTokenizer.from_pretrained(self.model_id)
|
AutoTokenizer.from_pretrained(self.model_id)
|
||||||
if self.tokenizer is None
|
if self.tokenizer is None
|
||||||
else self.tokenizer
|
else self.tokenizer
|
||||||
)
|
)
|
||||||
self.model_id = self.llm.model_id
|
|
||||||
return
|
return
|
||||||
elif _is_huggingface_endpoint(self.llm):
|
elif _is_huggingface_endpoint(self.llm):
|
||||||
self.model_id = self.llm.repo_id or self.llm.model
|
self.model_id = self.llm.repo_id or self.llm.model
|
||||||
|
Loading…
Reference in New Issue
Block a user