11import asyncio
22import inspect
3- from typing import TYPE_CHECKING , Any , Callable , Optional , Tuple , Type , get_origin , get_type_hints
3+ from typing import TYPE_CHECKING , Any , Callable , Tuple , Type , get_origin , get_type_hints
44
55from jsonschema import ValidationError , validate
66from pydantic import BaseModel , TypeAdapter , create_model
@@ -24,21 +24,21 @@ class Tool(BaseType):
2424 """
2525
2626 func : Callable
27- name : Optional [ str ] = None
28- desc : Optional [ str ] = None
29- args : Optional [ dict [str , Any ]] = None
30- arg_types : Optional [ dict [str , Any ]] = None
31- arg_desc : Optional [ dict [str , str ]] = None
27+ name : str | None = None
28+ desc : str | None = None
29+ args : dict [str , Any ] | None = None
30+ arg_types : dict [str , Any ] | None = None
31+ arg_desc : dict [str , str ] | None = None
3232 has_kwargs : bool = False
3333
3434 def __init__ (
3535 self ,
3636 func : Callable ,
37- name : Optional [ str ] = None ,
38- desc : Optional [ str ] = None ,
39- args : Optional [ dict [str , Any ]] = None ,
40- arg_types : Optional [ dict [str , Any ]] = None ,
41- arg_desc : Optional [ dict [str , str ]] = None ,
37+ name : str | None = None ,
38+ desc : str | None = None ,
39+ args : dict [str , Any ] | None = None ,
40+ arg_types : dict [str , Any ] | None = None ,
41+ arg_desc : dict [str , str ] | None = None ,
4242 ):
4343 """Initialize the Tool class.
4444
@@ -71,7 +71,7 @@ def foo(x: int, y: str = "hello"):
7171 super ().__init__ (func = func , name = name , desc = desc , args = args , arg_types = arg_types , arg_desc = arg_desc )
7272 self ._parse_function (func , arg_desc )
7373
74- def _parse_function (self , func : Callable , arg_desc : Optional [ dict [str , str ]] = None ):
74+ def _parse_function (self , func : Callable , arg_desc : dict [str , str ] | None = None ):
7575 """Helper method that parses a function to extract the name, description, and args.
7676
7777 This is a helper function that automatically infers the name, description, and args of the tool from the
0 commit comments