test_custom_callable_detector() — langchain Function Reference
Architecture documentation for the test_custom_callable_detector() function in test_pii.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 1360b6fe_5bcd_382a_b076_d28c73bb0fba["test_custom_callable_detector()"] e5e43364_b415_657a_0443_07c4b33daca1["TestCustomDetector"] 1360b6fe_5bcd_382a_b076_d28c73bb0fba -->|defined in| e5e43364_b415_657a_0443_07c4b33daca1 style 1360b6fe_5bcd_382a_b076_d28c73bb0fba fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py lines 532–558
def test_custom_callable_detector(self) -> None:
# Custom detector function
def detect_custom(content: str) -> list[PIIMatch]:
matches = []
if "CONFIDENTIAL" in content:
idx = content.index("CONFIDENTIAL")
matches.append(
PIIMatch(
type="confidential",
value="CONFIDENTIAL",
start=idx,
end=idx + 12,
)
)
return matches
middleware = PIIMiddleware(
"confidential",
detector=detect_custom,
strategy="redact",
)
state = AgentState[Any](messages=[HumanMessage("This is CONFIDENTIAL information")])
result = middleware.before_model(state, Runtime())
assert result is not None
assert "[REDACTED_CONFIDENTIAL]" in result["messages"][0].content
Domain
Subdomains
Source
Frequently Asked Questions
What does test_custom_callable_detector() do?
test_custom_callable_detector() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py.
Where is test_custom_callable_detector() defined?
test_custom_callable_detector() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_pii.py at line 532.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free