Skip to content

The agent engineering platform.

Lint

Nuno Campose35ea565d154
diff --git a/libs/langchain/langchain/tools/base.py b/libs/langchain/langchain/tools/base.py
index b56c1b0882..269e2b4846 100644
--- a/libs/langchain/langchain/tools/base.py
+++ b/libs/langchain/langchain/tools/base.py
@@ -771,23 +771,25 @@ def tool(
def _make_with_name(tool_name: str) -> Callable:
def _make_tool(dec_func: Union[Callable, Runnable]) -> BaseTool:
if isinstance(dec_func, Runnable):
- if dec_func.input_schema.schema().get("type") != "object":
+ runnable = dec_func
+
+ if runnable.input_schema.schema().get("type") != "object":
raise ValueError("Runnable must have an object schema.")
async def ainvoke_wrapper(
callbacks: Optional[Callbacks] = None, **kwargs: Any
) -> Any:
- return await dec_func.ainvoke(kwargs, {"callbacks": callbacks})
+ return await runnable.ainvoke(kwargs, {"callbacks": callbacks})
def invoke_wrapper(
callbacks: Optional[Callbacks] = None, **kwargs: Any
) -> Any:
- return dec_func.invoke(kwargs, {"callbacks": callbacks})
+ return runnable.invoke(kwargs, {"callbacks": callbacks})
coroutine = ainvoke_wrapper
func = invoke_wrapper
- schema = dec_func.input_schema
- description = repr(dec_func)
+ schema: Optional[Type[BaseModel]] = runnable.input_schema
+ description = repr(runnable)
elif inspect.iscoroutinefunction(dec_func):
coroutine = dec_func
func = None