Skip to content

Commit

Permalink
required tool_choice added for ChatHuggingFace (#28851)
Browse files Browse the repository at this point in the history
- **Description:** HuggingFace Inference Client V3 now supports
`required` as tool_choice which has been added.
- **Issue:** #28842
  • Loading branch information
keenborder786 authored Dec 20, 2024
1 parent fcba567 commit 8cf5f20
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 8cf5f20

Please sign in to comment.