Spaces:
Sleeping
Sleeping
| """Patch gradio_client JSON-schema helpers (bool additionalProperties with pydantic v2).""" | |
| from __future__ import annotations | |
| def apply() -> None: | |
| try: | |
| import gradio_client.utils as gc_utils | |
| except ImportError: | |
| return | |
| if getattr(gc_utils, "_refdiffnet_patched", False): | |
| return | |
| _orig_get_type = gc_utils.get_type | |
| def get_type(schema): # type: ignore[no-untyped-def] | |
| if not isinstance(schema, dict): | |
| return "Any" | |
| return _orig_get_type(schema) | |
| gc_utils.get_type = get_type # type: ignore[assignment] | |
| _orig_json = gc_utils._json_schema_to_python_type | |
| def _json_schema_to_python_type(schema, defs): # type: ignore[no-untyped-def] | |
| if not isinstance(schema, dict): | |
| return "Any" | |
| return _orig_json(schema, defs) | |
| gc_utils._json_schema_to_python_type = _json_schema_to_python_type # type: ignore[assignment] | |
| gc_utils._refdiffnet_patched = True # type: ignore[attr-defined] | |