structured.py — langchain Source File
Architecture documentation for structured.py, a python file in the langchain codebase. 12 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e2b42561_e8d8_9592_fe37_dc30b0a196de["structured.py"] c990f2d7_9509_7cea_ca95_51ad57dbe5c6["functools"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> c990f2d7_9509_7cea_ca95_51ad57dbe5c6 243100a0_4629_4394_a66b_1f67b00ce784["textwrap"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> 243100a0_4629_4394_a66b_1f67b00ce784 cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 614e7b9f_ed51_0780_749c_ff40b74963fc["inspect"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> 614e7b9f_ed51_0780_749c_ff40b74963fc 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> 91721f45_4909_e489_8c1f_084f8bd87145 f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> f3bc7443_c889_119d_0744_aacc3620d8d2 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c["langchain_core.runnables"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c 17795dda_8689_7308_3ff9_4b900129bd10["langchain_core.tools.base"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> 17795dda_8689_7308_3ff9_4b900129bd10 1014fe78_cb2c_fde4_a624_ae899aa7ca8e["langchain_core.utils.pydantic"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> 1014fe78_cb2c_fde4_a624_ae899aa7ca8e d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] e2b42561_e8d8_9592_fe37_dc30b0a196de --> d758344f_537f_649e_f467_b9d7442e86df style e2b42561_e8d8_9592_fe37_dc30b0a196de fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Structured tool."""
from __future__ import annotations
import functools
import textwrap
from collections.abc import Awaitable, Callable
from inspect import signature
from typing import (
TYPE_CHECKING,
Annotated,
Any,
Literal,
)
from pydantic import Field, SkipValidation
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 (
_EMPTY_SET,
FILTERED_ARGS,
ArgsSchema,
BaseTool,
_get_runnable_config_param,
_is_injected_arg_type,
create_schema_from_function,
)
from langchain_core.utils.pydantic import is_basemodel_subclass
if TYPE_CHECKING:
from langchain_core.messages import ToolCall
class StructuredTool(BaseTool):
"""Tool that can operate on any number of inputs."""
description: str = ""
args_schema: Annotated[ArgsSchema, SkipValidation()] = Field(
..., description="The tool schema."
)
"""The input arguments' schema."""
func: Callable[..., Any] | None = None
"""The function to run when the tool is called."""
coroutine: Callable[..., Awaitable[Any]] | None = None
"""The asynchronous version of the function."""
# --- Runnable ---
# TODO: Is this needed?
@override
async def ainvoke(
// ... (212 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- collections.abc
- functools
- inspect
- langchain_core.callbacks
- langchain_core.messages
- langchain_core.runnables
- langchain_core.tools.base
- langchain_core.utils.pydantic
- pydantic
- textwrap
- typing
- typing_extensions
Source
Frequently Asked Questions
What does structured.py do?
structured.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 structured.py?
structured.py defines 2 function(s): _filter_schema_args, langchain_core.
What does structured.py depend on?
structured.py imports 12 module(s): collections.abc, functools, inspect, langchain_core.callbacks, langchain_core.messages, langchain_core.runnables, langchain_core.tools.base, langchain_core.utils.pydantic, and 4 more.
Where is structured.py in the architecture?
structured.py is located at libs/core/langchain_core/tools/structured.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