mineeuk Claude Opus 4.6 (1M context) commited on
Commit
649dc86
·
1 Parent(s): f61390f

fix: monkey-patch gradio_client bool schema bug

Browse files

gradio_client.utils._json_schema_to_python_type crashes with
TypeError when schema is a bool (valid JSON Schema). Patch handles
bool schemas by returning "Any" before gradio processes components.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -1,4 +1,17 @@
1
  import spaces
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import gradio as gr
3
  import torch
4
  import librosa
 
1
  import spaces
2
+
3
+ # Monkey-patch gradio_client bug: bool schema not iterable
4
+ import gradio_client.utils as _gc_utils
5
+
6
+ _original_json_schema_to_python_type = _gc_utils._json_schema_to_python_type
7
+
8
+ def _patched_json_schema_to_python_type(schema, defs=None):
9
+ if isinstance(schema, bool):
10
+ return "Any"
11
+ return _original_json_schema_to_python_type(schema, defs)
12
+
13
+ _gc_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
14
+
15
  import gradio as gr
16
  import torch
17
  import librosa