test_apply_to_input_only() — langchain Function Reference
Architecture documentation for the test_apply_to_input_only() function in test_pii.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 20ab26af_f02d_055e_5ebd_45c47423fc7a["test_apply_to_input_only()"] 74acad26_e3cd_8385_fcb7_9bf787fa3f4a["TestPIIMiddlewareIntegration"] 20ab26af_f02d_055e_5ebd_45c47423fc7a -->|defined in| 74acad26_e3cd_8385_fcb7_9bf787fa3f4a style 20ab26af_f02d_055e_5ebd_45c47423fc7a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 357–372
def test_apply_to_input_only(self) -> None:
"""Test that middleware only processes input when configured."""
middleware = PIIMiddleware(
"email", strategy="redact", apply_to_input=True, apply_to_output=False
)
# Should process HumanMessage
state = AgentState[Any](messages=[HumanMessage("Email: test@example.com")])
result = middleware.before_model(state, Runtime())
assert result is not None
assert "[REDACTED_EMAIL]" in result["messages"][0].content
# Should not process AIMessage
state = AgentState[Any](messages=[AIMessage("My email is ai@example.com")])
result = middleware.after_model(state, Runtime())
assert result is None
Domain
Subdomains
Source
Frequently Asked Questions
What does test_apply_to_input_only() do?
test_apply_to_input_only() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py.
Where is test_apply_to_input_only() defined?
test_apply_to_input_only() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py at line 357.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free