test_multi_stage_transformation() — langchain Function Reference
Architecture documentation for the test_multi_stage_transformation() function in test_wrap_model_call.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD be254382_5e25_6c31_08a9_3ec5230f084d["test_multi_stage_transformation()"] cb947a63_4e84_45da_09d8_177d819abead["TestResponseRewriting"] be254382_5e25_6c31_08a9_3ec5230f084d -->|defined in| cb947a63_4e84_45da_09d8_177d819abead style be254382_5e25_6c31_08a9_3ec5230f084d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py lines 346–371
def test_multi_stage_transformation(self) -> None:
"""Test middleware applying multiple transformations."""
class MultiTransformMiddleware(AgentMiddleware):
def wrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelCallResult:
result = handler(request)
# result is ModelResponse, extract AIMessage from it
ai_message = result.result[0]
# First transformation: uppercase
assert isinstance(ai_message.content, str)
content = ai_message.content.upper()
# Second transformation: add prefix and suffix
content = f"[START] {content} [END]"
return AIMessage(content=content)
model = GenericFakeChatModel(messages=iter([AIMessage(content="hello")]))
agent = create_agent(model=model, middleware=[MultiTransformMiddleware()])
result = agent.invoke({"messages": [HumanMessage("Test")]})
assert result["messages"][1].content == "[START] HELLO [END]"
Domain
Subdomains
Source
Frequently Asked Questions
What does test_multi_stage_transformation() do?
test_multi_stage_transformation() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py.
Where is test_multi_stage_transformation() defined?
test_multi_stage_transformation() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 346.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free