bind_tools() — langchain Function Reference
Architecture documentation for the bind_tools() function in test_tool_selection.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 8c05d6e0_bec9_08ba_634c_28e62e666d85["bind_tools()"] 3502e89c_e0e8_295a_749b_99c4941d1f17["FakeModel"] 8c05d6e0_bec9_08ba_634c_28e62e666d85 -->|defined in| 3502e89c_e0e8_295a_749b_99c4941d1f17 style 8c05d6e0_bec9_08ba_634c_28e62e666d85 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_selection.py lines 59–94
def bind_tools(
self,
tools: Sequence[dict[str, Any] | type[BaseModel] | Callable[..., Any] | BaseTool],
**_kwargs: Any,
) -> Runnable[LanguageModelInput, AIMessage]:
if len(tools) == 0:
msg = "Must provide at least one tool"
raise ValueError(msg)
tool_dicts = []
for tool_ in tools:
if isinstance(tool_, dict):
tool_dicts.append(tool_)
continue
if not isinstance(tool_, BaseTool):
msg = "Only BaseTool and dict is supported by FakeToolCallingModel.bind_tools"
raise TypeError(msg)
# NOTE: this is a simplified tool spec for testing purposes only
if self.tool_style == "openai":
tool_dicts.append(
{
"type": "function",
"function": {
"name": tool_.name,
},
}
)
elif self.tool_style == "anthropic":
tool_dicts.append(
{
"name": tool_.name,
}
)
return self.bind(tools=tool_dicts)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does bind_tools() do?
bind_tools() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_selection.py.
Where is bind_tools() defined?
bind_tools() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_selection.py at line 59.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free