Home / Function/ patch_config() — langchain Function Reference

patch_config() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  cd508af1_56d4_d79e_3d0e_5e0f0df7aaa2["patch_config()"]
  4d16987d_fe07_22bb_f46d_7daeb24e0367["config.py"]
  cd508af1_56d4_d79e_3d0e_5e0f0df7aaa2 -->|defined in| 4d16987d_fe07_22bb_f46d_7daeb24e0367
  7079a884_2cef_5b12_cc79_e93a4668dcc5["call_func_with_variable_args()"]
  7079a884_2cef_5b12_cc79_e93a4668dcc5 -->|calls| cd508af1_56d4_d79e_3d0e_5e0f0df7aaa2
  5296012e_747a_52b7_f095_725e749951ec["acall_func_with_variable_args()"]
  5296012e_747a_52b7_f095_725e749951ec -->|calls| cd508af1_56d4_d79e_3d0e_5e0f0df7aaa2
  79a92f47_0451_ce36_938e_d386903a786f["ensure_config()"]
  cd508af1_56d4_d79e_3d0e_5e0f0df7aaa2 -->|calls| 79a92f47_0451_ce36_938e_d386903a786f
  style cd508af1_56d4_d79e_3d0e_5e0f0df7aaa2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/config.py lines 315–354

def patch_config(
    config: RunnableConfig | None,
    *,
    callbacks: BaseCallbackManager | None = None,
    recursion_limit: int | None = None,
    max_concurrency: int | None = None,
    run_name: str | None = None,
    configurable: dict[str, Any] | None = None,
) -> RunnableConfig:
    """Patch a config with new values.

    Args:
        config: The config to patch.
        callbacks: The callbacks to set.
        recursion_limit: The recursion limit to set.
        max_concurrency: The max concurrency to set.
        run_name: The run name to set.
        configurable: The configurable to set.

    Returns:
        The patched config.
    """
    config = ensure_config(config)
    if callbacks is not None:
        # If we're replacing callbacks, we need to unset run_name
        # As that should apply only to the same run as the original callbacks
        config["callbacks"] = callbacks
        if "run_name" in config:
            del config["run_name"]
        if "run_id" in config:
            del config["run_id"]
    if recursion_limit is not None:
        config["recursion_limit"] = recursion_limit
    if max_concurrency is not None:
        config["max_concurrency"] = max_concurrency
    if run_name is not None:
        config["run_name"] = run_name
    if configurable is not None:
        config["configurable"] = {**config.get("configurable", {}), **configurable}
    return config

Subdomains

Frequently Asked Questions

What does patch_config() do?
patch_config() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/config.py.
Where is patch_config() defined?
patch_config() is defined in libs/core/langchain_core/runnables/config.py at line 315.
What does patch_config() call?
patch_config() calls 1 function(s): ensure_config.
What calls patch_config()?
patch_config() is called by 2 function(s): acall_func_with_variable_args, call_func_with_variable_args.

Analyze Your Own Codebase

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

Try Supermodel Free