Spaces:
Running
Running
fix 10
Browse files
app.py
CHANGED
|
@@ -8,19 +8,22 @@ import json
|
|
| 8 |
|
| 9 |
# Monkey-patch gradio_client bug before importing gradio
|
| 10 |
# Fix for: TypeError: argument of type 'bool' is not iterable
|
|
|
|
| 11 |
try:
|
| 12 |
import gradio_client.utils as client_utils
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
|
| 17 |
-
def
|
| 18 |
-
|
|
|
|
| 19 |
return "Any"
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
client_utils.get_type = _patched_get_type
|
| 24 |
except Exception as e:
|
| 25 |
print(f"Warning: Could not patch gradio_client: {e}")
|
| 26 |
|
|
|
|
| 8 |
|
| 9 |
# Monkey-patch gradio_client bug before importing gradio
|
| 10 |
# Fix for: TypeError: argument of type 'bool' is not iterable
|
| 11 |
+
# and APIInfoParseError: Cannot parse schema True
|
| 12 |
try:
|
| 13 |
import gradio_client.utils as client_utils
|
| 14 |
|
| 15 |
+
# Patch _json_schema_to_python_type to handle boolean schemas
|
| 16 |
+
_original_json_schema_to_python_type = client_utils._json_schema_to_python_type
|
| 17 |
|
| 18 |
+
def _patched_json_schema_to_python_type(schema, defs):
|
| 19 |
+
# Handle boolean schema (e.g., additionalProperties: true/false)
|
| 20 |
+
if schema is True:
|
| 21 |
return "Any"
|
| 22 |
+
if schema is False:
|
| 23 |
+
return "None"
|
| 24 |
+
return _original_json_schema_to_python_type(schema, defs)
|
| 25 |
|
| 26 |
+
client_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
|
|
|
|
| 27 |
except Exception as e:
|
| 28 |
print(f"Warning: Could not patch gradio_client: {e}")
|
| 29 |
|