mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-17 08:29:28 +00:00
core[patch]: use args_schema doc for tool description (#23503)
This commit is contained in:
parent
6f7fe82830
commit
32f8f39974
@ -827,6 +827,8 @@ class StructuredTool(BaseTool):
|
||||
raise ValueError("Function and/or coroutine must be provided")
|
||||
name = name or source_function.__name__
|
||||
description_ = description or source_function.__doc__
|
||||
if description_ is None and args_schema:
|
||||
description_ = args_schema.__doc__
|
||||
if description_ is None:
|
||||
raise ValueError(
|
||||
"Function must have a docstring if description not provided."
|
||||
|
@ -44,6 +44,8 @@ def test_unnamed_decorator() -> None:
|
||||
|
||||
|
||||
class _MockSchema(BaseModel):
|
||||
"""Return the arguments directly."""
|
||||
|
||||
arg1: int
|
||||
arg2: bool
|
||||
arg3: Optional[dict] = None
|
||||
@ -133,7 +135,6 @@ def test_decorator_with_specified_schema() -> None:
|
||||
|
||||
@tool(args_schema=_MockSchema)
|
||||
def tool_func(arg1: int, arg2: bool, arg3: Optional[dict] = None) -> str:
|
||||
"""Return the arguments directly."""
|
||||
return f"{arg1} {arg2} {arg3}"
|
||||
|
||||
assert isinstance(tool_func, BaseTool)
|
||||
|
Loading…
Reference in New Issue
Block a user