mirror of
https://github.com/hwchase17/langchain.git
synced 2026-04-23 20:23:59 +00:00
perf(core): cache BaseTool.tool_call_schema and args as cached_property
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -552,6 +552,7 @@ class ChildTool(BaseTool):
|
||||
|
||||
model_config = ConfigDict(
|
||||
arbitrary_types_allowed=True,
|
||||
ignored_types=(functools.cached_property,),
|
||||
)
|
||||
|
||||
@property
|
||||
@@ -564,7 +565,7 @@ class ChildTool(BaseTool):
|
||||
keys = {k for k in self.args if k != "kwargs"}
|
||||
return len(keys) == 1
|
||||
|
||||
@property
|
||||
@functools.cached_property
|
||||
def args(self) -> dict:
|
||||
"""Get the tool's input arguments schema.
|
||||
|
||||
@@ -583,7 +584,7 @@ class ChildTool(BaseTool):
|
||||
json_schema = input_schema.model_json_schema()
|
||||
return cast("dict", json_schema["properties"])
|
||||
|
||||
@property
|
||||
@functools.cached_property
|
||||
def tool_call_schema(self) -> ArgsSchema:
|
||||
"""Get the schema for tool calls, excluding injected arguments.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user