devmandan commited on
Commit
22bd9ab
·
1 Parent(s): f752558

added similar patch from private space

Browse files
Files changed (2) hide show
  1. app.py +32 -0
  2. requirements.txt +1 -1
app.py CHANGED
@@ -3,6 +3,38 @@ import gradio as gr
3
 
4
  print("Gradio version:", gr.__version__)
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  # -----------------------------------------------------------------------------
7
  # Authentication
8
  # -----------------------------------------------------------------------------
 
3
 
4
  print("Gradio version:", gr.__version__)
5
 
6
+ # Defensive patch for Gradio schema issue
7
+ def patch_gradio_schema():
8
+ try:
9
+ import gradio_client.utils as client_utils
10
+ original_get_type = client_utils.get_type
11
+ original_json_schema_to_python_type = client_utils._json_schema_to_python_type
12
+
13
+ def patched_get_type(schema):
14
+ # Handle case where schema is boolean instead of dict
15
+ if isinstance(schema, bool):
16
+ return str(schema)
17
+ return original_get_type(schema)
18
+
19
+ def patched_json_schema_to_python_type(schema, defs=None):
20
+ # Handle case where schema is boolean instead of dict
21
+ if isinstance(schema, bool):
22
+ return str(schema)
23
+ try:
24
+ return original_json_schema_to_python_type(schema, defs)
25
+ except Exception as e:
26
+ if "Cannot parse schema" in str(e) and isinstance(schema, bool):
27
+ return str(schema)
28
+ raise e
29
+
30
+ client_utils.get_type = patched_get_type
31
+ client_utils._json_schema_to_python_type = patched_json_schema_to_python_type
32
+ print("✅ Applied comprehensive Gradio schema patch")
33
+ except Exception as e:
34
+ print(f"⚠️ Could not apply Gradio schema patch: {e}")
35
+
36
+ patch_gradio_schema()
37
+
38
  # -----------------------------------------------------------------------------
39
  # Authentication
40
  # -----------------------------------------------------------------------------
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
  fastapi
2
  uvicorn[standard]
3
- gradio==5.8.0
4
  huggingface_hub==0.25.2
 
1
  fastapi
2
  uvicorn[standard]
3
+ gradio==5.4.0
4
  huggingface_hub==0.25.2