perceptron01 commited on
Commit
7ac0307
·
verified ·
1 Parent(s): 1746aae

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py CHANGED
@@ -10,6 +10,36 @@ in-memory) and is never written to the audit log.
10
  import json
11
  import tempfile
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  import gradio as gr
14
 
15
  from firewall import audit_log, round_trip, sanitize
 
10
  import json
11
  import tempfile
12
 
13
+ # --- Workaround for a Gradio 4.44 + Python 3.13 bug: building the API schema
14
+ # crashes with "argument of type 'bool' is not iterable" on boolean JSON-schema
15
+ # nodes (additionalProperties: true). Patch the schema walker to treat bool
16
+ # schemas as "Any". Cosmetic only — affects the /info type hints, nothing else.
17
+ try:
18
+ import gradio_client.utils as _gcu
19
+
20
+ if hasattr(_gcu, "_json_schema_to_python_type"):
21
+ _orig_json_schema = _gcu._json_schema_to_python_type
22
+
23
+ def _safe_json_schema(schema, defs=None):
24
+ if isinstance(schema, bool):
25
+ return "Any"
26
+ return _orig_json_schema(schema, defs)
27
+
28
+ _gcu._json_schema_to_python_type = _safe_json_schema
29
+
30
+ if hasattr(_gcu, "get_type"):
31
+ _orig_get_type = _gcu.get_type
32
+
33
+ def _safe_get_type(schema):
34
+ if not isinstance(schema, dict):
35
+ return "Any"
36
+ return _orig_get_type(schema)
37
+
38
+ _gcu.get_type = _safe_get_type
39
+ except Exception:
40
+ pass
41
+ # --- end workaround ---
42
+
43
  import gradio as gr
44
 
45
  from firewall import audit_log, round_trip, sanitize