_configure() — langchain Function Reference
Architecture documentation for the _configure() function in manager.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 9459fba6_8a00_1919_2b50_35cd43b2bdcd["_configure()"] ef55be46_0333_682d_8311_b4dd35c3e34c["manager.py"] 9459fba6_8a00_1919_2b50_35cd43b2bdcd -->|defined in| ef55be46_0333_682d_8311_b4dd35c3e34c ba6695e3_66d3_2ef4_027e_436cea7aa24c["configure()"] ba6695e3_66d3_2ef4_027e_436cea7aa24c -->|calls| 9459fba6_8a00_1919_2b50_35cd43b2bdcd afb047d4_a471_790b_b243_a82244ee2e5e["configure()"] afb047d4_a471_790b_b243_a82244ee2e5e -->|calls| 9459fba6_8a00_1919_2b50_35cd43b2bdcd 8f5c28a1_3a23_8028_f981_7f47a86dd32b["_get_debug()"] 9459fba6_8a00_1919_2b50_35cd43b2bdcd -->|calls| 8f5c28a1_3a23_8028_f981_7f47a86dd32b f8b97710_364f_a2bb_125c_cabc205b2475["copy()"] 9459fba6_8a00_1919_2b50_35cd43b2bdcd -->|calls| f8b97710_364f_a2bb_125c_cabc205b2475 style 9459fba6_8a00_1919_2b50_35cd43b2bdcd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/callbacks/manager.py lines 2299–2472
def _configure(
callback_manager_cls: type[T],
inheritable_callbacks: Callbacks = None,
local_callbacks: Callbacks = None,
inheritable_tags: list[str] | None = None,
local_tags: list[str] | None = None,
inheritable_metadata: dict[str, Any] | None = None,
local_metadata: dict[str, Any] | None = None,
*,
verbose: bool = False,
) -> T:
"""Configure the callback manager.
Args:
callback_manager_cls: The callback manager class.
inheritable_callbacks: The inheritable callbacks.
local_callbacks: The local callbacks.
inheritable_tags: The inheritable tags.
local_tags: The local tags.
inheritable_metadata: The inheritable metadata.
local_metadata: The local metadata.
verbose: Whether to enable verbose mode.
Raises:
RuntimeError: If `LANGCHAIN_TRACING` is set but `LANGCHAIN_TRACING_V2` is not.
Returns:
The configured callback manager.
"""
tracing_context = get_tracing_context()
tracing_metadata = tracing_context["metadata"]
tracing_tags = tracing_context["tags"]
run_tree: Run | None = tracing_context["parent"]
parent_run_id = None if run_tree is None else run_tree.id
callback_manager = callback_manager_cls(
handlers=[],
parent_run_id=parent_run_id,
)
if inheritable_callbacks or local_callbacks:
if isinstance(inheritable_callbacks, list) or inheritable_callbacks is None:
inheritable_callbacks_ = inheritable_callbacks or []
callback_manager = callback_manager_cls(
handlers=inheritable_callbacks_.copy(),
inheritable_handlers=inheritable_callbacks_.copy(),
parent_run_id=parent_run_id,
)
else:
parent_run_id_ = inheritable_callbacks.parent_run_id
# Break ties between the external tracing context and inherited context
if parent_run_id is not None and (
parent_run_id_ is None
# If the LC parent has already been reflected
# in the run tree, we know the run_tree is either the
# same parent or a child of the parent.
or (run_tree and str(parent_run_id_) in run_tree.dotted_order)
):
parent_run_id_ = parent_run_id
# Otherwise, we assume the LC context has progressed
# beyond the run tree and we should not inherit the parent.
callback_manager = callback_manager_cls(
handlers=inheritable_callbacks.handlers.copy(),
inheritable_handlers=inheritable_callbacks.inheritable_handlers.copy(),
parent_run_id=parent_run_id_,
tags=inheritable_callbacks.tags.copy(),
inheritable_tags=inheritable_callbacks.inheritable_tags.copy(),
metadata=inheritable_callbacks.metadata.copy(),
inheritable_metadata=inheritable_callbacks.inheritable_metadata.copy(),
)
local_handlers_ = (
local_callbacks
if isinstance(local_callbacks, list)
else (local_callbacks.handlers if local_callbacks else [])
)
for handler in local_handlers_:
callback_manager.add_handler(handler, inherit=False)
if inheritable_tags or local_tags:
callback_manager.add_tags(inheritable_tags or [])
callback_manager.add_tags(local_tags or [], inherit=False)
if inheritable_metadata or local_metadata:
callback_manager.add_metadata(inheritable_metadata or {})
callback_manager.add_metadata(local_metadata or {}, inherit=False)
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does _configure() do?
_configure() is a function in the langchain codebase, defined in libs/core/langchain_core/callbacks/manager.py.
Where is _configure() defined?
_configure() is defined in libs/core/langchain_core/callbacks/manager.py at line 2299.
What does _configure() call?
_configure() calls 2 function(s): _get_debug, copy.
What calls _configure()?
_configure() is called by 2 function(s): configure, configure.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free