Home / Function/ _run() — langchain Function Reference

_run() — langchain Function Reference

Architecture documentation for the _run() function in simple.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  ec4709dd_d97d_2a9b_7714_d254d0086ca6["_run()"]
  4ddde15c_138a_6971_91c4_325c8c3034dd["Tool"]
  ec4709dd_d97d_2a9b_7714_d254d0086ca6 -->|defined in| 4ddde15c_138a_6971_91c4_325c8c3034dd
  style ec4709dd_d97d_2a9b_7714_d254d0086ca6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tools/simple.py lines 99–124

    def _run(
        self,
        *args: Any,
        config: RunnableConfig,
        run_manager: CallbackManagerForToolRun | None = None,
        **kwargs: Any,
    ) -> Any:
        """Use the tool.

        Args:
            *args: Positional arguments to pass to the tool
            config: Configuration for the run
            run_manager: Optional callback manager to use for the run
            **kwargs: Keyword arguments to pass to the tool

        Returns:
            The result of the tool execution
        """
        if self.func:
            if run_manager and signature(self.func).parameters.get("callbacks"):
                kwargs["callbacks"] = run_manager.get_child()
            if config_param := _get_runnable_config_param(self.func):
                kwargs[config_param] = config
            return self.func(*args, **kwargs)
        msg = "Tool does not support sync invocation."
        raise NotImplementedError(msg)

Subdomains

Frequently Asked Questions

What does _run() do?
_run() is a function in the langchain codebase, defined in libs/core/langchain_core/tools/simple.py.
Where is _run() defined?
_run() is defined in libs/core/langchain_core/tools/simple.py at line 99.

Analyze Your Own Codebase

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

Try Supermodel Free