@@ -81,7 +81,7 @@ def __init__(
81
81
self .__url = f"{ base_url } /api/tool/{ name } /invoke"
82
82
self .__description = description
83
83
self .__params = params
84
- self .__pydantic_model = self ._to_pydantic_model ( )
84
+ self .__pydantic_model = to_pydantic_model ( self .__params )
85
85
86
86
inspect_type_params = [param .to_param () for param in self .__params ]
87
87
@@ -102,19 +102,6 @@ def __init__(
102
102
# map of parameter name to value (or callable that produces that value)
103
103
self .__bound_parameters = bound_params
104
104
105
- def _to_pydantic_model (self ) -> Type [BaseModel ]:
106
- """Converts the given manifest schema to a Pydantic BaseModel class."""
107
- field_definitions = {}
108
- for field in self .__params :
109
- field_definitions [field .name ] = cast (
110
- Any ,
111
- (
112
- field .to_param ().annotation ,
113
- Field (description = field .description ),
114
- ),
115
- )
116
- return create_model ("tool_model" , ** field_definitions )
117
-
118
105
def __copy (
119
106
self ,
120
107
session : Optional [ClientSession ] = None ,
@@ -327,3 +314,16 @@ def identify_required_authn_params(
327
314
if required :
328
315
required_params [param ] = services
329
316
return required_params
317
+
318
+ def to_pydantic_model (params : Sequence [ParameterSchema ]) -> Type [BaseModel ]:
319
+ """Converts the given parameters to a Pydantic BaseModel class."""
320
+ field_definitions = {}
321
+ for field in params :
322
+ field_definitions [field .name ] = cast (
323
+ Any ,
324
+ (
325
+ field .to_param ().annotation ,
326
+ Field (description = field .description ),
327
+ ),
328
+ )
329
+ return create_model ("tool_model" , ** field_definitions )
0 commit comments