From ff6e3558d764ccfd34db9d008abd37411dc758b0 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Tue, 9 Dec 2025 19:51:04 -0500 Subject: [PATCH] docs(fireworks,groq,huggingface,mistralai,ollama,openai): x-ref `convert_to_openai_tool` (#34276) --- libs/partners/fireworks/langchain_fireworks/chat_models.py | 7 +++---- libs/partners/groq/langchain_groq/chat_models.py | 7 +++---- .../langchain_huggingface/chat_models/huggingface.py | 7 +++---- libs/partners/mistralai/langchain_mistralai/chat_models.py | 7 +++---- libs/partners/ollama/langchain_ollama/chat_models.py | 6 +++--- libs/partners/openai/langchain_openai/chat_models/base.py | 4 ++-- 6 files changed, 17 insertions(+), 21 deletions(-) diff --git a/libs/partners/fireworks/langchain_fireworks/chat_models.py b/libs/partners/fireworks/langchain_fireworks/chat_models.py index e2d183faebe..ef818c0c41d 100644 --- a/libs/partners/fireworks/langchain_fireworks/chat_models.py +++ b/libs/partners/fireworks/langchain_fireworks/chat_models.py @@ -669,8 +669,8 @@ class ChatFireworks(BaseChatModel): Args: tools: A list of tool definitions to bind to this chat model. - Supports any tool definition handled by - `langchain_core.utils.function_calling.convert_to_openai_tool`. + + Supports any tool definition handled by [`convert_to_openai_tool`][langchain_core.utils.function_calling.convert_to_openai_tool]. tool_choice: Which tool to require the model to call. Must be the name of the single provided function, `'auto'` to automatically determine which function to call @@ -679,8 +679,7 @@ class ChatFireworks(BaseChatModel): `{"type": "function", "function": {"name": <>}}`. **kwargs: Any additional parameters to pass to `langchain_fireworks.chat_models.ChatFireworks.bind` - - """ + """ # noqa: E501 formatted_tools = [convert_to_openai_tool(tool) for tool in tools] if tool_choice is not None and tool_choice: if isinstance(tool_choice, str) and ( diff --git a/libs/partners/groq/langchain_groq/chat_models.py b/libs/partners/groq/langchain_groq/chat_models.py index 6646ec72120..ea5265336ef 100644 --- a/libs/partners/groq/langchain_groq/chat_models.py +++ b/libs/partners/groq/langchain_groq/chat_models.py @@ -829,8 +829,8 @@ class ChatGroq(BaseChatModel): Args: tools: A list of tool definitions to bind to this chat model. - Supports any tool definition handled by - `langchain_core.utils.function_calling.convert_to_openai_tool`. + + Supports any tool definition handled by [`convert_to_openai_tool`][langchain_core.utils.function_calling.convert_to_openai_tool]. tool_choice: Which tool to require the model to call. Must be the name of the single provided function, `'auto'` to automatically determine which function to call @@ -839,8 +839,7 @@ class ChatGroq(BaseChatModel): `{"type": "function", "function": {"name": <>}}`. **kwargs: Any additional parameters to pass to the `langchain.runnable.Runnable` constructor. - - """ + """ # noqa: E501 formatted_tools = [convert_to_openai_tool(tool) for tool in tools] if tool_choice is not None and tool_choice: if tool_choice == "any": diff --git a/libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py b/libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py index 2f61bf9ef85..725c40337e9 100644 --- a/libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py +++ b/libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py @@ -947,8 +947,8 @@ class ChatHuggingFace(BaseChatModel): Args: tools: A list of tool definitions to bind to this chat model. - Supports any tool definition handled by - `langchain_core.utils.function_calling.convert_to_openai_tool`. + + Supports any tool definition handled by [`convert_to_openai_tool`][langchain_core.utils.function_calling.convert_to_openai_tool]. tool_choice: Which tool to require the model to call. Must be the name of the single provided function or `'auto'` to automatically determine which function to call @@ -956,8 +956,7 @@ class ChatHuggingFace(BaseChatModel): {"type": "function", "function": {"name": <>}}. **kwargs: Any additional parameters to pass to the `langchain.runnable.Runnable` constructor. - - """ + """ # noqa: E501 formatted_tools = [convert_to_openai_tool(tool) for tool in tools] if tool_choice is not None and tool_choice: if len(formatted_tools) != 1: diff --git a/libs/partners/mistralai/langchain_mistralai/chat_models.py b/libs/partners/mistralai/langchain_mistralai/chat_models.py index c56c4deb271..3a2681d7bc1 100644 --- a/libs/partners/mistralai/langchain_mistralai/chat_models.py +++ b/libs/partners/mistralai/langchain_mistralai/chat_models.py @@ -792,8 +792,8 @@ class ChatMistralAI(BaseChatModel): Args: tools: A list of tool definitions to bind to this chat model. - Supports any tool definition handled by - `langchain_core.utils.function_calling.convert_to_openai_tool`. + + Supports any tool definition handled by [`convert_to_openai_tool`][langchain_core.utils.function_calling.convert_to_openai_tool]. tool_choice: Which tool to require the model to call. Must be the name of the single provided function or `'auto'` to automatically determine which function to call @@ -801,8 +801,7 @@ class ChatMistralAI(BaseChatModel): {"type": "function", "function": {"name": <>}}. kwargs: Any additional parameters are passed directly to `self.bind(**kwargs)`. - - """ + """ # noqa: E501 formatted_tools = [convert_to_openai_tool(tool) for tool in tools] if tool_choice: tool_names = [] diff --git a/libs/partners/ollama/langchain_ollama/chat_models.py b/libs/partners/ollama/langchain_ollama/chat_models.py index fb8901fa8bd..890f47f39d6 100644 --- a/libs/partners/ollama/langchain_ollama/chat_models.py +++ b/libs/partners/ollama/langchain_ollama/chat_models.py @@ -1235,13 +1235,13 @@ class ChatOllama(BaseChatModel): Args: tools: A list of tool definitions to bind to this chat model. - Supports any tool definition handled by - `langchain_core.utils.function_calling.convert_to_openai_tool`. + + Supports any tool definition handled by [`convert_to_openai_tool`][langchain_core.utils.function_calling.convert_to_openai_tool]. tool_choice: If provided, which tool for model to call. **This parameter is currently ignored as it is not supported by Ollama.** kwargs: Any additional parameters are passed directly to `self.bind(**kwargs)`. - """ + """ # noqa: E501 formatted_tools = [convert_to_openai_tool(tool) for tool in tools] return super().bind(tools=formatted_tools, **kwargs) diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 9672cb752e4..8428c03e402 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -1815,8 +1815,8 @@ class BaseChatOpenAI(BaseChatModel): Args: tools: A list of tool definitions to bind to this chat model. - Supports any tool definition handled by - `langchain_core.utils.function_calling.convert_to_openai_tool`. + + Supports any tool definition handled by [`convert_to_openai_tool`][langchain_core.utils.function_calling.convert_to_openai_tool]. tool_choice: Which tool to require the model to call. Options are: - `str` of the form `'<>'`: calls `<>` tool.