mckell commited on
Commit
3a1d1d4
·
verified ·
1 Parent(s): f208a6d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -15,19 +15,23 @@ from pathlib import Path
15
 
16
  # Monkey-patch gradio_client to handle additionalProperties: true
17
  # This fixes a bug where dict-typed State components cause schema errors
 
 
18
  def _patch_gradio_client():
19
  try:
20
  import gradio_client.utils as client_utils
21
- original_get_type = client_utils.get_type
22
 
23
- def patched_get_type(schema):
 
 
 
24
  # Handle case where schema is a boolean (additionalProperties: true)
25
  if isinstance(schema, bool):
26
  return "Any"
27
- return original_get_type(schema)
28
 
29
- client_utils.get_type = patched_get_type
30
- print("[Patch] Applied gradio_client schema fix")
31
  except Exception as e:
32
  print(f"[Patch] Could not patch gradio_client: {e}")
33
 
 
15
 
16
  # Monkey-patch gradio_client to handle additionalProperties: true
17
  # This fixes a bug where dict-typed State components cause schema errors
18
+ # The bug is in _json_schema_to_python_type which recursively calls itself
19
+ # with schema['additionalProperties'] which can be True (boolean)
20
  def _patch_gradio_client():
21
  try:
22
  import gradio_client.utils as client_utils
 
23
 
24
+ # Get the original function
25
+ original_func = client_utils._json_schema_to_python_type
26
+
27
+ def patched_json_schema_to_python_type(schema, defs=None):
28
  # Handle case where schema is a boolean (additionalProperties: true)
29
  if isinstance(schema, bool):
30
  return "Any"
31
+ return original_func(schema, defs)
32
 
33
+ client_utils._json_schema_to_python_type = patched_json_schema_to_python_type
34
+ print("[Patch] Applied gradio_client _json_schema_to_python_type fix")
35
  except Exception as e:
36
  print(f"[Patch] Could not patch gradio_client: {e}")
37