FakeModel Class — langchain Architecture
Architecture documentation for the FakeModel class in test_tool_selection.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 3502e89c_e0e8_295a_749b_99c4941d1f17["FakeModel"] 0f829642_e361_67a1_cbca_f82839bbbd31["GenericFakeChatModel"] 3502e89c_e0e8_295a_749b_99c4941d1f17 -->|extends| 0f829642_e361_67a1_cbca_f82839bbbd31 18e85ff8_9a5d_f800_f722_027398dc89e7["BaseTool"] 3502e89c_e0e8_295a_749b_99c4941d1f17 -->|extends| 18e85ff8_9a5d_f800_f722_027398dc89e7 f96107c8_8757_b550_ad6f_b1dcda0da20b["test_tool_selection.py"] 3502e89c_e0e8_295a_749b_99c4941d1f17 -->|defined in| f96107c8_8757_b550_ad6f_b1dcda0da20b 8c05d6e0_bec9_08ba_634c_28e62e666d85["bind_tools()"] 3502e89c_e0e8_295a_749b_99c4941d1f17 -->|method| 8c05d6e0_bec9_08ba_634c_28e62e666d85
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_selection.py lines 56–94
class FakeModel(GenericFakeChatModel):
tool_style: Literal["openai", "anthropic"] = "openai"
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)
Defined In
Extends
Source
Frequently Asked Questions
What is the FakeModel class?
FakeModel is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_selection.py.
Where is FakeModel defined?
FakeModel is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_selection.py at line 56.
What does FakeModel extend?
FakeModel extends GenericFakeChatModel, BaseTool.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free