Nanny7 commited on
Commit
aecf51b
·
1 Parent(s): 7ebefed

Patch gradio schema handling

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -6,6 +6,25 @@ import urllib.request
6
 
7
  import chemiscope
8
  from ase import Atoms
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
 
11
  def parse_cube_file(cube_file):
 
6
 
7
  import chemiscope
8
  from ase import Atoms
9
+ from gradio_client import utils as gradio_client_utils
10
+
11
+
12
+ def _patch_gradio_bool_schema():
13
+ """Work around gradio_client expecting dict schemas by handling bools."""
14
+ original_get_type = getattr(gradio_client_utils, "get_type", None)
15
+ if original_get_type is None:
16
+ return
17
+
18
+ def safe_get_type(schema):
19
+ if isinstance(schema, bool):
20
+ # JSON Schema allows True/False to mean accept-all / accept-nothing.
21
+ return "boolean" if schema else {}
22
+ return original_get_type(schema)
23
+
24
+ gradio_client_utils.get_type = safe_get_type
25
+
26
+
27
+ _patch_gradio_bool_schema()
28
 
29
 
30
  def parse_cube_file(cube_file):