Home / Function/ __call__() — langchain Function Reference

__call__() — langchain Function Reference

Architecture documentation for the __call__() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b350c2bd_ec11_d5c0_502b_65a6d1ee41a2["__call__()"]
  f3cef70e_11b0_61c9_7ec0_7308f4b45056["Chain"]
  b350c2bd_ec11_d5c0_502b_65a6d1ee41a2 -->|defined in| f3cef70e_11b0_61c9_7ec0_7308f4b45056
  cbab652e_92a7_bf56_f96d_801fd5f6dacd["invoke()"]
  b350c2bd_ec11_d5c0_502b_65a6d1ee41a2 -->|calls| cbab652e_92a7_bf56_f96d_801fd5f6dacd
  style b350c2bd_ec11_d5c0_502b_65a6d1ee41a2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/base.py lines 369–418

    def __call__(
        self,
        inputs: dict[str, Any] | Any,
        return_only_outputs: bool = False,  # noqa: FBT001,FBT002
        callbacks: Callbacks = None,
        *,
        tags: list[str] | None = None,
        metadata: dict[str, Any] | None = None,
        run_name: str | None = None,
        include_run_info: bool = False,
    ) -> dict[str, Any]:
        """Execute the chain.

        Args:
            inputs: Dictionary of inputs, or single input if chain expects
                only one param. Should contain all inputs specified in
                `Chain.input_keys` except for inputs that will be set by the chain's
                memory.
            return_only_outputs: Whether to return only outputs in the
                response. If `True`, only new keys generated by this chain will be
                returned. If `False`, both input keys and new keys generated by this
                chain will be returned.
            callbacks: Callbacks to use for this chain run. These will be called in
                addition to callbacks passed to the chain during construction, but only
                these runtime callbacks will propagate to calls to other objects.
            tags: List of string tags to pass to all callbacks. These will be passed in
                addition to tags passed to the chain during construction, but only
                these runtime tags will propagate to calls to other objects.
            metadata: Optional metadata associated with the chain.
            run_name: Optional name for this run of the chain.
            include_run_info: Whether to include run info in the response. Defaults
                to False.

        Returns:
            A dict of named outputs. Should contain all outputs specified in
                `Chain.output_keys`.
        """
        config = {
            "callbacks": callbacks,
            "tags": tags,
            "metadata": metadata,
            "run_name": run_name,
        }

        return self.invoke(
            inputs,
            cast("RunnableConfig", {k: v for k, v in config.items() if v is not None}),
            return_only_outputs=return_only_outputs,
            include_run_info=include_run_info,
        )

Subdomains

Calls

Frequently Asked Questions

What does __call__() do?
__call__() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/base.py.
Where is __call__() defined?
__call__() is defined in libs/langchain/langchain_classic/chains/base.py at line 369.
What does __call__() call?
__call__() calls 1 function(s): invoke.

Analyze Your Own Codebase

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

Try Supermodel Free