dongyuxuan Claude Opus 4.6 commited on
Commit
afc39e6
·
1 Parent(s): 9cbfc9e

Fix gradio_client bool schema crash on HF Spaces

Browse files

gradio_client._json_schema_to_python_type crashes when
additionalProperties is a boolean instead of a dict schema.
Patch it before importing gradio to handle this case.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -11,6 +11,17 @@ import pandas as pd
11
  import matplotlib
12
  matplotlib.use('Agg')
13
  import matplotlib.pyplot as plt
 
 
 
 
 
 
 
 
 
 
 
14
  import gradio as gr
15
 
16
  # Ensure local modules are importable
 
11
  import matplotlib
12
  matplotlib.use('Agg')
13
  import matplotlib.pyplot as plt
14
+ import gradio_client.utils as _gc_utils
15
+
16
+ _orig_json_schema_to_python_type = _gc_utils._json_schema_to_python_type
17
+
18
+ def _patched_json_schema_to_python_type(schema, defs):
19
+ if isinstance(schema, bool):
20
+ return "Any" if schema else "None"
21
+ return _orig_json_schema_to_python_type(schema, defs)
22
+
23
+ _gc_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
24
+
25
  import gradio as gr
26
 
27
  # Ensure local modules are importable