@@ -82,7 +82,7 @@ def __init__(
82
82
83
83
# the following properties are set to help anyone that might inspect it determine usage
84
84
self .__name__ = name
85
- self .__doc__ = self ._create_docstring ( )
85
+ self .__doc__ = create_docstring ( self .__description , self . __params )
86
86
self .__signature__ = Signature (
87
87
parameters = inspect_type_params , return_annotation = str
88
88
)
@@ -96,18 +96,6 @@ def __init__(
96
96
# map of parameter name to value (or callable that produces that value)
97
97
self .__bound_parameters = bound_params
98
98
99
- def _create_docstring (self ) -> str :
100
- """Convert a tool schema into its function docstring"""
101
- docstring = self .__description
102
- if not self .__params :
103
- return docstring
104
- docstring += "\n \n Args:"
105
- for p in self .__params :
106
- docstring += (
107
- f"\n { p .name } ({ p .to_param ().annotation .__name__ } ): { p .description } "
108
- )
109
- return docstring
110
-
111
99
def __copy (
112
100
self ,
113
101
session : Optional [ClientSession ] = None ,
@@ -278,6 +266,17 @@ def bind_parameters(
278
266
bound_params = types .MappingProxyType (all_bound_params ),
279
267
)
280
268
269
+ def create_docstring (description : str , params : Sequence [ParameterSchema ]) -> str :
270
+ """Convert tool description and params into its function docstring"""
271
+ docstring = description
272
+ if not params :
273
+ return docstring
274
+ docstring += "\n \n Args:"
275
+ for p in params :
276
+ docstring += (
277
+ f"\n { p .name } ({ p .to_param ().annotation .__name__ } ): { p .description } "
278
+ )
279
+ return docstring
281
280
282
281
def identify_required_authn_params (
283
282
req_authn_params : Mapping [str , list [str ]], auth_service_names : Iterable [str ]
0 commit comments