Spaces:
Paused
Paused
cstr commited on
Commit ·
ddfe9f6
1
Parent(s): d1b858f
fix: upgrade to Gradio 5.29.0 to resolve Starlette/Jinja2 compat breaks
Browse filesGradio 4.44.1 is broken with current HF Space deps:
- TemplateResponse(name, context) vs new (request, name, context) → TypeError: unhashable type: 'dict'
- gradio_client additionalProperties bool crash (also fixed natively in gradio-client 1.x)
Gradio 5.29.0 ships gradio-client 1.x which has both fixes built-in.
Monkey-patches are kept but made conditional (hasattr) so they are no-ops on 5.x.
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🎙️
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
python_version: 3.10.13
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.29.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
python_version: 3.10.13
|
app.py
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# gradio_client crashes when JSON Schema
|
| 4 |
-
# (a boolean
|
| 5 |
-
#
|
| 6 |
-
# 2. _json_schema_to_python_type() → APIInfoParseError("Cannot parse schema True")
|
| 7 |
-
# Patch both to treat non-dict schemas as "Any"/"unknown".
|
| 8 |
import gradio_client.utils as _gcu
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
import os
|
| 25 |
import time
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# gradio_client <1.x crashes when JSON Schema has `additionalProperties: true`
|
| 4 |
+
# (a boolean). Fixed in gradio-client 1.x (Gradio 5+), but patch defensively
|
| 5 |
+
# for older installs. Both code paths that hit the bug are guarded.
|
|
|
|
|
|
|
| 6 |
import gradio_client.utils as _gcu
|
| 7 |
|
| 8 |
+
if hasattr(_gcu, "get_type"):
|
| 9 |
+
_orig_get_type = _gcu.get_type
|
| 10 |
+
def _safe_get_type(schema):
|
| 11 |
+
if not isinstance(schema, dict):
|
| 12 |
+
return "unknown"
|
| 13 |
+
return _orig_get_type(schema)
|
| 14 |
+
_gcu.get_type = _safe_get_type
|
| 15 |
+
|
| 16 |
+
if hasattr(_gcu, "_json_schema_to_python_type"):
|
| 17 |
+
_orig_j2p = _gcu._json_schema_to_python_type
|
| 18 |
+
def _safe_j2p(schema, defs=None):
|
| 19 |
+
if not isinstance(schema, dict):
|
| 20 |
+
return "Any"
|
| 21 |
+
return _orig_j2p(schema, defs)
|
| 22 |
+
_gcu._json_schema_to_python_type = _safe_j2p
|
| 23 |
|
| 24 |
import os
|
| 25 |
import time
|