From f921ade6e4de4dda0f9c4fcbbd014a2fa3e5b1d2 Mon Sep 17 00:00:00 2001 From: keenborder786 <21110290@lums.edu.pk> Date: Fri, 20 Dec 2024 21:49:47 +0500 Subject: [PATCH] [chore]: tool_choice added --- .../langchain_huggingface/chat_models/huggingface.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py b/libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py index 593df16133bbe..30510ca10fe50 100644 --- a/libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py +++ b/libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py @@ -474,7 +474,9 @@ def bind_tools( self, tools: Sequence[Union[Dict[str, Any], Type, Callable, BaseTool]], *, - tool_choice: Optional[Union[dict, str, Literal["auto", "none"], bool]] = None, + tool_choice: Optional[ + Union[dict, str, Literal["auto", "none", "required"], bool] + ] = None, **kwargs: Any, ) -> Runnable[LanguageModelInput, BaseMessage]: """Bind tool-like objects to this chat model. @@ -502,7 +504,7 @@ def bind_tools( f"tool. Received {len(formatted_tools)} tools." ) if isinstance(tool_choice, str): - if tool_choice not in ("auto", "none"): + if tool_choice not in ("auto", "none", "required"): tool_choice = { "type": "function", "function": {"name": tool_choice},