|
15 | 15 |
|
16 | 16 |
|
17 | 17 | def _type_to_schema(type_hint): |
18 | | - if isinstance(type_hint, int): |
| 18 | + if type_hint is int: |
19 | 19 | return "number" |
20 | | - if isinstance(type_hint, float): |
| 20 | + if type_hint is float: |
21 | 21 | return "number" |
22 | | - if isinstance(type_hint, bool): |
| 22 | + if type_hint is bool: |
23 | 23 | return "boolean" |
24 | | - if isinstance(type_hint, str): |
| 24 | + if type_hint is str: |
25 | 25 | return "string" |
26 | | - if isinstance(type_hint, dict): |
| 26 | + if type_hint is dict: |
27 | 27 | return "object" |
28 | 28 | raise ValueError(f"Unsupported type hint: {type_hint}") |
29 | 29 |
|
@@ -87,19 +87,21 @@ def _parse_tool_parameters_schema(func) -> dict[str, dict]: |
87 | 87 | inspect.Parameter.VAR_KEYWORD, |
88 | 88 | ): |
89 | 89 | raise ValueError("Varargs and kwargs are not supported") |
90 | | - if isinstance(origin := typing.get_origin(parameter.annotation), dict): |
| 90 | + origin = typing.get_origin(parameter.annotation) |
| 91 | + print("HEY", origin, parameter.annotation, origin is None) |
| 92 | + if origin is Union: |
| 93 | + param_schema = _handle_union_annotation(parameter) |
| 94 | + elif origin is None: |
| 95 | + param_schema = _handle_simple_type(parameter) |
| 96 | + required.append(parameter.name) |
| 97 | + elif isinstance(origin, dict): |
91 | 98 | param_schema = _handle_dict_annotation(parameter) |
92 | 99 | parameters_schema["required"].append(parameter.name) |
93 | 100 | required.append(parameter.name) |
94 | 101 | elif isinstance(origin, list): |
95 | 102 | param_schema = _handle_list_annotation(parameter) |
96 | 103 | parameters_schema["required"].append(parameter.name) |
97 | 104 | required.append(parameter.name) |
98 | | - elif isinstance(origin, Union): |
99 | | - param_schema = _handle_union_annotation(parameter) |
100 | | - elif origin is None: |
101 | | - param_schema = _handle_simple_type(parameter) |
102 | | - required.append(parameter.name) |
103 | 105 | else: |
104 | 106 | raise ValueError("Unsupported type hint ", parameter) |
105 | 107 | parameters_schema["properties"][parameter.name] = param_schema |
|
0 commit comments