Home / Function/ invoke() — langchain Function Reference

invoke() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  85609be6_cbc7_0689_ac1a_dce4dde514b5["invoke()"]
  c6a370e4_a02a_c56a_38eb_7ca734dcbfea["RunnableLambda"]
  85609be6_cbc7_0689_ac1a_dce4dde514b5 -->|defined in| c6a370e4_a02a_c56a_38eb_7ca734dcbfea
  424a7613_4cfe_67c7_0e4e_df9c17b111eb["_call_with_config()"]
  85609be6_cbc7_0689_ac1a_dce4dde514b5 -->|calls| 424a7613_4cfe_67c7_0e4e_df9c17b111eb
  style 85609be6_cbc7_0689_ac1a_dce4dde514b5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/base.py lines 4997–5025

    def invoke(
        self,
        input: Input,
        config: RunnableConfig | None = None,
        **kwargs: Any | None,
    ) -> Output:
        """Invoke this `Runnable` synchronously.

        Args:
            input: The input to this `Runnable`.
            config: The config to use.
            **kwargs: Additional keyword arguments.

        Returns:
            The output of this `Runnable`.

        Raises:
            TypeError: If the `Runnable` is a coroutine function.

        """
        if hasattr(self, "func"):
            return self._call_with_config(
                self._invoke,
                input,
                ensure_config(config),
                **kwargs,
            )
        msg = "Cannot invoke a coroutine function synchronously.Use `ainvoke` instead."
        raise TypeError(msg)

Domain

Subdomains

Frequently Asked Questions

What does invoke() do?
invoke() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/base.py.
Where is invoke() defined?
invoke() is defined in libs/core/langchain_core/runnables/base.py at line 4997.
What does invoke() call?
invoke() calls 1 function(s): _call_with_config.

Analyze Your Own Codebase

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

Try Supermodel Free