mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-05 09:25:14 +03:00
fix(langchain): re-export PIIMatch from middleware package (#39291)
Closes #38718 `PIIMatch` was already in `pii.py`'s `__all__`, but not re-exported from the package `__init__`, forcing custom PII detector authors to import it from the private `_redaction` module. --------- Co-authored-by: @abhi-0203 <abhi-0203@users.noreply.github.com>
This commit is contained in:
1 parent
b7e5dda39e
commit
0cd7003c11
2 files changed
+22
-1
No files matched your search
@@ -11,7 +11,7 @@ from langchain.agents.middleware.human_in_the_loop import (
|
||||
from langchain.agents.middleware.model_call_limit import ModelCallLimitMiddleware
|
||||
from langchain.agents.middleware.model_fallback import ModelFallbackMiddleware
|
||||
from langchain.agents.middleware.model_retry import ModelRetryMiddleware
|
||||
from langchain.agents.middleware.pii import PIIDetectionError, PIIMiddleware
|
||||
from langchain.agents.middleware.pii import PIIDetectionError, PIIMatch, PIIMiddleware
|
||||
from langchain.agents.middleware.provider_tool_search import ProviderToolSearchMiddleware
|
||||
from langchain.agents.middleware.shell_tool import (
|
||||
CodexSandboxExecutionPolicy,
|
||||
@@ -70,6 +70,7 @@ __all__ = [
|
||||
"ModelRetryMiddleware",
|
||||
"OutputAgentState",
|
||||
"PIIDetectionError",
|
||||
"PIIMatch",
|
||||
"PIIMiddleware",
|
||||
"ProviderToolSearchMiddleware",
|
||||
"RedactionRule",
|
||||
|
||||
@@ -19,7 +19,9 @@ from langgraph.stream._types import ProtocolEvent
|
||||
from langgraph.stream.transformers import MessagesTransformer
|
||||
|
||||
from langchain.agents import AgentState
|
||||
from langchain.agents import middleware as middleware_package
|
||||
from langchain.agents.factory import create_agent
|
||||
from langchain.agents.middleware import PIIMatch as PublicPIIMatch
|
||||
from langchain.agents.middleware._redaction import RedactionRule
|
||||
from langchain.agents.middleware.pii import (
|
||||
PIIDetectionError,
|
||||
@@ -34,6 +36,24 @@ from langchain.agents.middleware.pii import (
|
||||
)
|
||||
from tests.unit_tests.agents.model import FakeToolCallingModel
|
||||
|
||||
# ============================================================================
|
||||
# Public Export Tests
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TestPIIMatchPublicExport:
|
||||
"""Test that `PIIMatch` is importable from the public middleware package.
|
||||
|
||||
Regression test: `PIIMatch` was only exported from the private
|
||||
`_redaction` module, forcing custom-detector authors to import from it
|
||||
directly instead of `langchain.agents.middleware`.
|
||||
"""
|
||||
|
||||
def test_pii_match_importable_from_middleware_package(self) -> None:
|
||||
assert PublicPIIMatch is PIIMatch
|
||||
assert "PIIMatch" in middleware_package.__all__
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Detection Function Tests
|
||||
# ============================================================================
|
||||
|
||||
Reference in new issue
Block a user