@ -43,9 +43,9 @@ class _MockSchema(BaseModel):
class _MockStructuredTool ( BaseTool ) :
name = " structured_api "
name : str = " structured_api "
args_schema : Type [ BaseModel ] = _MockSchema
description = " A Structured Tool "
description : str = " A Structured Tool "
def _run ( self , arg1 : int , arg2 : bool , arg3 : Optional [ dict ] = None ) - > str :
return f " { arg1 } { arg2 } { arg3 } "
@ -69,10 +69,10 @@ def test_misannotated_base_tool_raises_error() -> None:
with pytest . raises ( SchemaAnnotationError ) :
class _MisAnnotatedTool ( BaseTool ) :
name = " structured_api "
name : str = " structured_api "
# This would silently be ignored without the custom metaclass
args_schema : BaseModel = _MockSchema # type: ignore
description = " A Structured Tool "
description : str = " A Structured Tool "
def _run ( self , arg1 : int , arg2 : bool , arg3 : Optional [ dict ] = None ) - > str :
return f " { arg1 } { arg2 } { arg3 } "
@ -87,9 +87,9 @@ def test_forward_ref_annotated_base_tool_accepted() -> None:
""" Test that a using forward ref annotation syntax is accepted. """ " "
class _ForwardRefAnnotatedTool ( BaseTool ) :
name = " structured_api "
name : str = " structured_api "
args_schema : " Type[BaseModel] " = _MockSchema
description = " A Structured Tool "
description : str = " A Structured Tool "
def _run ( self , arg1 : int , arg2 : bool , arg3 : Optional [ dict ] = None ) - > str :
return f " { arg1 } { arg2 } { arg3 } "
@ -104,9 +104,9 @@ def test_subclass_annotated_base_tool_accepted() -> None:
""" Test BaseTool child w/ custom schema isn ' t overwritten. """
class _ForwardRefAnnotatedTool ( BaseTool ) :
name = " structured_api "
name : str = " structured_api "
args_schema : Type [ _MockSchema ] = _MockSchema
description = " A Structured Tool "
description : str = " A Structured Tool "
def _run ( self , arg1 : int , arg2 : bool , arg3 : Optional [ dict ] = None ) - > str :
return f " { arg1 } { arg2 } { arg3 } "
@ -154,8 +154,8 @@ def test_decorated_function_schema_equivalent() -> None:
def test_args_kwargs_filtered ( ) - > None :
class _SingleArgToolWithKwargs ( BaseTool ) :
name = " single_arg_tool "
description = " A single arged tool with kwargs "
name : str = " single_arg_tool "
description : str = " A single arged tool with kwargs "
def _run (
self ,
@ -177,8 +177,8 @@ def test_args_kwargs_filtered() -> None:
assert tool . is_single_input
class _VarArgToolWithKwargs ( BaseTool ) :
name = " single_arg_tool "
description = " A single arged tool with kwargs "
name : str = " single_arg_tool "
description : str = " A single arged tool with kwargs "
def _run (
self ,
@ -269,8 +269,8 @@ def test_base_tool_inheritance_base_schema() -> None:
""" Test schema is correctly inferred when inheriting from BaseTool. """
class _MockSimpleTool ( BaseTool ) :
name = " simple_tool "
description = " A Simple Tool "
name : str = " simple_tool "
description : str = " A Simple Tool "
def _run ( self , tool_input : str ) - > str :
return f " { tool_input } "
@ -593,8 +593,8 @@ async def test_create_async_tool() -> None:
class _FakeExceptionTool ( BaseTool ) :
name = " exception "
description = " an exception-throwing tool "
name : str = " exception "
description : str = " an exception-throwing tool "
exception : Exception = ToolException ( )
def _run ( self ) - > str :