isaachwf commited on
Commit
a009142
·
1 Parent(s): c6c1a1c
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -8,19 +8,22 @@ import json
8
 
9
  # Monkey-patch gradio_client bug before importing gradio
10
  # Fix for: TypeError: argument of type 'bool' is not iterable
 
11
  try:
12
  import gradio_client.utils as client_utils
13
 
14
- # Store reference to original function
15
- _original_get_type = client_utils.get_type
16
 
17
- def _patched_get_type(schema):
18
- if schema is True or schema is False:
 
19
  return "Any"
20
- return _original_get_type(schema)
 
 
21
 
22
- # Replace the function in the module
23
- client_utils.get_type = _patched_get_type
24
  except Exception as e:
25
  print(f"Warning: Could not patch gradio_client: {e}")
26
 
 
8
 
9
  # Monkey-patch gradio_client bug before importing gradio
10
  # Fix for: TypeError: argument of type 'bool' is not iterable
11
+ # and APIInfoParseError: Cannot parse schema True
12
  try:
13
  import gradio_client.utils as client_utils
14
 
15
+ # Patch _json_schema_to_python_type to handle boolean schemas
16
+ _original_json_schema_to_python_type = client_utils._json_schema_to_python_type
17
 
18
+ def _patched_json_schema_to_python_type(schema, defs):
19
+ # Handle boolean schema (e.g., additionalProperties: true/false)
20
+ if schema is True:
21
  return "Any"
22
+ if schema is False:
23
+ return "None"
24
+ return _original_json_schema_to_python_type(schema, defs)
25
 
26
+ client_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
 
27
  except Exception as e:
28
  print(f"Warning: Could not patch gradio_client: {e}")
29