Home / Function/ _apply_redact_strategy() — langchain Function Reference

_apply_redact_strategy() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  098fc190_8120_3755_549b_42f1179f630e["_apply_redact_strategy()"]
  be639235_9a02_cc2d_5a7d_637d822fb3b3["_redaction.py"]
  098fc190_8120_3755_549b_42f1179f630e -->|defined in| be639235_9a02_cc2d_5a7d_637d822fb3b3
  a830b2dc_75ff_a1e7_d25c_7de2223efe55["apply_strategy()"]
  a830b2dc_75ff_a1e7_d25c_7de2223efe55 -->|calls| 098fc190_8120_3755_549b_42f1179f630e
  style 098fc190_8120_3755_549b_42f1179f630e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/_redaction.py lines 239–244

def _apply_redact_strategy(content: str, matches: list[PIIMatch]) -> str:
    result = content
    for match in sorted(matches, key=operator.itemgetter("start"), reverse=True):
        replacement = f"[REDACTED_{match['type'].upper()}]"
        result = result[: match["start"]] + replacement + result[match["end"] :]
    return result

Domain

Subdomains

Called By

Frequently Asked Questions

What does _apply_redact_strategy() do?
_apply_redact_strategy() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py.
Where is _apply_redact_strategy() defined?
_apply_redact_strategy() is defined in libs/langchain_v1/langchain/agents/middleware/_redaction.py at line 239.
What calls _apply_redact_strategy()?
_apply_redact_strategy() is called by 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