simple.py — langchain Source File
Architecture documentation for simple.py, a python file in the langchain codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 9d355c0c_a962_0eca_ed0e_1965c24ec58d["simple.py"] cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] 9d355c0c_a962_0eca_ed0e_1965c24ec58d --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 614e7b9f_ed51_0780_749c_ff40b74963fc["inspect"] 9d355c0c_a962_0eca_ed0e_1965c24ec58d --> 614e7b9f_ed51_0780_749c_ff40b74963fc 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 9d355c0c_a962_0eca_ed0e_1965c24ec58d --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] 9d355c0c_a962_0eca_ed0e_1965c24ec58d --> 91721f45_4909_e489_8c1f_084f8bd87145 f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"] 9d355c0c_a962_0eca_ed0e_1965c24ec58d --> f3bc7443_c889_119d_0744_aacc3620d8d2 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c["langchain_core.runnables"] 9d355c0c_a962_0eca_ed0e_1965c24ec58d --> 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c 17795dda_8689_7308_3ff9_4b900129bd10["langchain_core.tools.base"] 9d355c0c_a962_0eca_ed0e_1965c24ec58d --> 17795dda_8689_7308_3ff9_4b900129bd10 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 9d355c0c_a962_0eca_ed0e_1965c24ec58d --> d758344f_537f_649e_f467_b9d7442e86df style 9d355c0c_a962_0eca_ed0e_1965c24ec58d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Tool that takes in function or coroutine directly."""
from __future__ import annotations
from collections.abc import Awaitable, Callable
from inspect import signature
from typing import (
TYPE_CHECKING,
Any,
)
from typing_extensions import override
# Cannot move to TYPE_CHECKING as _run/_arun parameter annotations are needed at runtime
from langchain_core.callbacks import (
AsyncCallbackManagerForToolRun, # noqa: TC001
CallbackManagerForToolRun, # noqa: TC001
)
from langchain_core.runnables import RunnableConfig, run_in_executor
from langchain_core.tools.base import (
ArgsSchema,
BaseTool,
ToolException,
_get_runnable_config_param,
)
if TYPE_CHECKING:
from langchain_core.messages import ToolCall
class Tool(BaseTool):
"""Tool that takes in function or coroutine directly."""
description: str = ""
func: Callable[..., str] | None
"""The function to run when the tool is called."""
coroutine: Callable[..., Awaitable[str]] | None = None
"""The asynchronous version of the function."""
# --- Runnable ---
@override
async def ainvoke(
self,
input: str | dict | ToolCall,
config: RunnableConfig | None = None,
**kwargs: Any,
) -> Any:
if not self.coroutine:
# If the tool does not implement async, fall back to default implementation
return await run_in_executor(config, self.invoke, input, config, **kwargs)
return await super().ainvoke(input, config, **kwargs)
# --- Tool ---
@property
def args(self) -> dict:
// ... (145 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- collections.abc
- inspect
- langchain_core.callbacks
- langchain_core.messages
- langchain_core.runnables
- langchain_core.tools.base
- typing
- typing_extensions
Source
Frequently Asked Questions
What does simple.py do?
simple.py is a source file in the langchain codebase, written in python. It belongs to the AgentOrchestration domain, ToolInterface subdomain.
What functions are defined in simple.py?
simple.py defines 1 function(s): langchain_core.
What does simple.py depend on?
simple.py imports 8 module(s): collections.abc, inspect, langchain_core.callbacks, langchain_core.messages, langchain_core.runnables, langchain_core.tools.base, typing, typing_extensions.
Where is simple.py in the architecture?
simple.py is located at libs/core/langchain_core/tools/simple.py (domain: AgentOrchestration, subdomain: ToolInterface, directory: libs/core/langchain_core/tools).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free