Home / Function/ apply() — langchain Function Reference

apply() — langchain Function Reference

Architecture documentation for the apply() function in _redaction.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  fae00189_d2f4_7398_49ea_3100608cdf41["apply()"]
  197cc226_edf5_ed4b_2144_a18d26749cbf["ResolvedRedactionRule"]
  fae00189_d2f4_7398_49ea_3100608cdf41 -->|defined in| 197cc226_edf5_ed4b_2144_a18d26749cbf
  a830b2dc_75ff_a1e7_d25c_7de2223efe55["apply_strategy()"]
  fae00189_d2f4_7398_49ea_3100608cdf41 -->|calls| a830b2dc_75ff_a1e7_d25c_7de2223efe55
  style fae00189_d2f4_7398_49ea_3100608cdf41 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/_redaction.py lines 409–422

    def apply(self, content: str) -> tuple[str, list[PIIMatch]]:
        """Apply this rule to content, returning new content and matches.

        Args:
            content: The text content to scan and redact.

        Returns:
            A tuple of (updated content, list of detected matches).
        """
        matches = self.detector(content)
        if not matches:
            return content, []
        updated = apply_strategy(content, matches, self.strategy)
        return updated, matches

Domain

Subdomains

Frequently Asked Questions

What does apply() do?
apply() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py.
Where is apply() defined?
apply() is defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py at line 409.
What does apply() call?
apply() calls 1 function(s): apply_strategy.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free