FakeModel Class — langchain Architecture
Architecture documentation for the FakeModel class in test_tool_emulator.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 255a89fb_052f_a9ce_4fd8_704e7d3961b7["FakeModel"] 0f829642_e361_67a1_cbca_f82839bbbd31["GenericFakeChatModel"] 255a89fb_052f_a9ce_4fd8_704e7d3961b7 -->|extends| 0f829642_e361_67a1_cbca_f82839bbbd31 18e85ff8_9a5d_f800_f722_027398dc89e7["BaseTool"] 255a89fb_052f_a9ce_4fd8_704e7d3961b7 -->|extends| 18e85ff8_9a5d_f800_f722_027398dc89e7 5b00cf78_0f18_c9ad_fc5f_85cc0378daf1["test_tool_emulator.py"] 255a89fb_052f_a9ce_4fd8_704e7d3961b7 -->|defined in| 5b00cf78_0f18_c9ad_fc5f_85cc0378daf1 04203ae8_f25e_48de_e145_afd595f0eb7e["bind_tools()"] 255a89fb_052f_a9ce_4fd8_704e7d3961b7 -->|method| 04203ae8_f25e_48de_e145_afd595f0eb7e
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py lines 42–82
class FakeModel(GenericFakeChatModel):
"""Fake model that supports bind_tools."""
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 FakeModel.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_emulator.py.
Where is FakeModel defined?
FakeModel is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py at line 42.
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