test_custom_model_instance() — langchain Function Reference
Architecture documentation for the test_custom_model_instance() function in test_tool_emulator.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 286d6868_28ee_bf52_fa3f_4a97ef6da38f["test_custom_model_instance()"] b7251e9a_e972_0104_74b3_75fbbecbaa7b["TestLLMToolEmulatorModelConfiguration"] 286d6868_28ee_bf52_fa3f_4a97ef6da38f -->|defined in| b7251e9a_e972_0104_74b3_75fbbecbaa7b style 286d6868_28ee_bf52_fa3f_4a97ef6da38f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py lines 379–406
def test_custom_model_instance(self) -> None:
"""Test passing a BaseChatModel instance for emulation."""
agent_model = FakeModel(
messages=cycle(
[
AIMessage(
content="",
tool_calls=[{"name": "search_web", "id": "1", "args": {"query": "test"}}],
),
AIMessage(content="Done."),
]
)
)
custom_emulator_model = FakeEmulatorModel(responses=["Custom emulated response"])
emulator = LLMToolEmulator(tools=["search_web"], model=custom_emulator_model)
agent = create_agent(
model=agent_model,
tools=[search_web],
middleware=[emulator],
)
result = agent.invoke({"messages": [HumanMessage("Search for test")]})
# Should use the custom model for emulation
assert isinstance(result["messages"][-1], AIMessage)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_custom_model_instance() do?
test_custom_model_instance() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py.
Where is test_custom_model_instance() defined?
test_custom_model_instance() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_emulator.py at line 379.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free