Download client/utils/tool_schema_parser.py from jackkuo/ADMP-LS: direct link, hf CLI and curl.
- Browser
- Download file 815 Bytes
-
https://huggingface.co/spaces/jackkuo/ADMP-LS/resolve/main/client/utils/tool_schema_parser.py
- Command line
-
hf download hf://spaces/jackkuo/ADMP-LS/client/utils/tool_schema_parser.py
-
curl -L -o tool_schema_parser.py https://huggingface.co/spaces/jackkuo/ADMP-LS/resolve/main/client/utils/tool_schema_parser.py
815 Bytes
| def extract_tool_parameters(tool): | |
| parameters = [] | |
| if not hasattr(tool, 'args_schema'): | |
| return parameters | |
| schema = tool.args_schema | |
| if isinstance(schema, dict): | |
| schema_dict = schema | |
| else: | |
| schema_dict = schema.schema() | |
| properties = schema_dict.get('properties', {}) | |
| required = schema_dict.get('required', []) | |
| for name, info in properties.items(): | |
| param_type = info.get('type', 'string') | |
| title = info.get('title', name) | |
| default = info.get('default', None) | |
| is_required = name in required | |
| desc = f"{title} ({param_type})" | |
| desc += " - required" if is_required else " - optional" | |
| if default is not None: | |
| desc += f" [default: {default}]" | |
| parameters.append(desc) | |
| return parameters |