bind_tools() — langchain Function Reference
Architecture documentation for the bind_tools() function in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD c13fd55f_31c2_4cb3_a17b_a17f81e436ed["bind_tools()"] 19e4be00_71fb_5390_6768_f6e6158f49b4["ChatOllama"] c13fd55f_31c2_4cb3_a17b_a17f81e436ed -->|defined in| 19e4be00_71fb_5390_6768_f6e6158f49b4 e8d6a68e_9c70_dc39_2fed_312e948801f8["with_structured_output()"] e8d6a68e_9c70_dc39_2fed_312e948801f8 -->|calls| c13fd55f_31c2_4cb3_a17b_a17f81e436ed style c13fd55f_31c2_4cb3_a17b_a17f81e436ed fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/ollama/langchain_ollama/chat_models.py lines 1233–1254
def bind_tools(
self,
tools: Sequence[dict[str, Any] | type | Callable | BaseTool],
*,
tool_choice: dict | str | Literal["auto", "any"] | bool | None = None, # noqa: PYI051, ARG002
**kwargs: Any,
) -> Runnable[LanguageModelInput, AIMessage]:
"""Bind tool-like objects to this chat model.
Assumes model is compatible with OpenAI tool-calling API.
Args:
tools: A list of tool definitions to bind to this chat model.
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)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does bind_tools() do?
bind_tools() is a function in the langchain codebase, defined in libs/partners/ollama/langchain_ollama/chat_models.py.
Where is bind_tools() defined?
bind_tools() is defined in libs/partners/ollama/langchain_ollama/chat_models.py at line 1233.
What calls bind_tools()?
bind_tools() is called by 1 function(s): with_structured_output.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free