test_decorator_response_rewriting() — langchain Function Reference
Architecture documentation for the test_decorator_response_rewriting() function in test_wrap_model_call.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ce851a35_30b0_29ef_8d49_d99ddedef310["test_decorator_response_rewriting()"] 5a3c6db0_0302_046a_d217_22fb3d4e632e["TestWrapModelCallDecorator"] ce851a35_30b0_29ef_8d49_d99ddedef310 -->|defined in| 5a3c6db0_0302_046a_d217_22fb3d4e632e style ce851a35_30b0_29ef_8d49_d99ddedef310 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 1080–1099
def test_decorator_response_rewriting(self) -> None:
"""Test decorator for rewriting responses."""
@wrap_model_call
def uppercase_responses(
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelCallResult:
result = handler(request)
# result is ModelResponse, extract AIMessage from it
ai_message = result.result[0]
assert isinstance(ai_message.content, str)
return AIMessage(content=ai_message.content.upper())
model = GenericFakeChatModel(messages=iter([AIMessage(content="hello world")]))
agent = create_agent(model=model, middleware=[uppercase_responses])
result = agent.invoke({"messages": [HumanMessage("Test")]})
assert result["messages"][1].content == "HELLO WORLD"
Domain
Subdomains
Source
Frequently Asked Questions
What does test_decorator_response_rewriting() do?
test_decorator_response_rewriting() 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_decorator_response_rewriting() defined?
test_decorator_response_rewriting() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 1080.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free