Home / Function/ _set_config_context() — langchain Function Reference

_set_config_context() — langchain Function Reference

Architecture documentation for the _set_config_context() function in config.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  abb3eedf_1961_2c87_d361_c10a29c4c763["_set_config_context()"]
  4d16987d_fe07_22bb_f46d_7daeb24e0367["config.py"]
  abb3eedf_1961_2c87_d361_c10a29c4c763 -->|defined in| 4d16987d_fe07_22bb_f46d_7daeb24e0367
  style abb3eedf_1961_2c87_d361_c10a29c4c763 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/config.py lines 152–184

def _set_config_context(
    config: RunnableConfig,
) -> tuple[Token[RunnableConfig | None], dict[str, Any] | None]:
    """Set the child Runnable config + tracing context.

    Args:
        config: The config to set.

    Returns:
        The token to reset the config and the previous tracing context.
    """
    config_token = var_child_runnable_config.set(config)
    current_context = None
    if (
        (callbacks := config.get("callbacks"))
        and (
            parent_run_id := getattr(callbacks, "parent_run_id", None)
        )  # Is callback manager
        and (
            tracer := next(
                (
                    handler
                    for handler in getattr(callbacks, "handlers", [])
                    if isinstance(handler, LangChainTracer)
                ),
                None,
            )
        )
        and (run := tracer.run_map.get(str(parent_run_id)))
    ):
        current_context = get_tracing_context()
        _set_tracing_context({"parent": run})
    return config_token, current_context

Subdomains

Frequently Asked Questions

What does _set_config_context() do?
_set_config_context() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/config.py.
Where is _set_config_context() defined?
_set_config_context() is defined in libs/core/langchain_core/runnables/config.py at line 152.

Analyze Your Own Codebase

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

Try Supermodel Free