test_uppercase_response() — langchain Function Reference
Architecture documentation for the test_uppercase_response() function in test_wrap_model_call.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 524fa244_8ce7_483e_cb05_d1be1817c300["test_uppercase_response()"] cb947a63_4e84_45da_09d8_177d819abead["TestResponseRewriting"] 524fa244_8ce7_483e_cb05_d1be1817c300 -->|defined in| cb947a63_4e84_45da_09d8_177d819abead style 524fa244_8ce7_483e_cb05_d1be1817c300 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 299–319
def test_uppercase_response(self) -> None:
"""Test middleware that transforms response to uppercase."""
class UppercaseMiddleware(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]
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=[UppercaseMiddleware()])
result = agent.invoke({"messages": [HumanMessage("Test")]})
assert result["messages"][1].content == "HELLO WORLD"
Domain
Subdomains
Source
Frequently Asked Questions
What does test_uppercase_response() do?
test_uppercase_response() 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_uppercase_response() defined?
test_uppercase_response() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 299.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free