__init__() — langchain Function Reference
Architecture documentation for the __init__() function in context_editing.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 01e32015_213d_50ed_0d7e_96a1cc300601["__init__()"] 670767f0_01ad_c9dd_6835_d1a9fb775005["ContextEditingMiddleware"] 01e32015_213d_50ed_0d7e_96a1cc300601 -->|defined in| 670767f0_01ad_c9dd_6835_d1a9fb775005 style 01e32015_213d_50ed_0d7e_96a1cc300601 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/context_editing.py lines 200–218
def __init__(
self,
*,
edits: Iterable[ContextEdit] | None = None,
token_count_method: Literal["approximate", "model"] = "approximate", # noqa: S107
) -> None:
"""Initialize an instance of context editing middleware.
Args:
edits: Sequence of edit strategies to apply.
Defaults to a single `ClearToolUsesEdit` mirroring Anthropic defaults.
token_count_method: Whether to use approximate token counting
(faster, less accurate) or exact counting implemented by the
chat model (potentially slower, more accurate).
"""
super().__init__()
self.edits = list(edits or (ClearToolUsesEdit(),))
self.token_count_method = token_count_method
Domain
Subdomains
Source
Frequently Asked Questions
What does __init__() do?
__init__() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/context_editing.py.
Where is __init__() defined?
__init__() is defined in libs/langchain_v1/langchain/agents/middleware/context_editing.py at line 200.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free