Upload folder using huggingface_hub
Browse files- gradio_patch.py +13 -5
- requirements.txt +5 -6
gradio_patch.py
CHANGED
@@ -1,23 +1,31 @@
|
|
1 |
-
#
|
2 |
import sys
|
3 |
|
4 |
def patch_gradio():
|
5 |
try:
|
6 |
import gradio_client.utils
|
7 |
|
8 |
-
# Store the original
|
9 |
original_get_type = gradio_client.utils.get_type
|
|
|
10 |
|
11 |
-
# Create a fixed version that handles booleans
|
12 |
def patched_get_type(schema):
|
13 |
if isinstance(schema, bool):
|
14 |
return "bool"
|
15 |
return original_get_type(schema)
|
16 |
|
17 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
gradio_client.utils.get_type = patched_get_type
|
|
|
19 |
|
20 |
-
print("✅ Gradio patch applied successfully")
|
21 |
except ImportError:
|
22 |
print("❌ Could not import gradio_client.utils to apply patch")
|
23 |
except Exception as e:
|
|
|
1 |
+
# Comprehensive patch for Gradio's boolean schema handling issues
|
2 |
import sys
|
3 |
|
4 |
def patch_gradio():
|
5 |
try:
|
6 |
import gradio_client.utils
|
7 |
|
8 |
+
# Store the original functions
|
9 |
original_get_type = gradio_client.utils.get_type
|
10 |
+
original_json_schema_to_python_type = gradio_client.utils._json_schema_to_python_type
|
11 |
|
12 |
+
# Create a fixed version of get_type that handles booleans
|
13 |
def patched_get_type(schema):
|
14 |
if isinstance(schema, bool):
|
15 |
return "bool"
|
16 |
return original_get_type(schema)
|
17 |
|
18 |
+
# Create a fixed version of _json_schema_to_python_type that handles booleans
|
19 |
+
def patched_json_schema_to_python_type(schema, defs=None):
|
20 |
+
if isinstance(schema, bool):
|
21 |
+
return "bool"
|
22 |
+
return original_json_schema_to_python_type(schema, defs)
|
23 |
+
|
24 |
+
# Replace the original functions with our patched versions
|
25 |
gradio_client.utils.get_type = patched_get_type
|
26 |
+
gradio_client.utils._json_schema_to_python_type = patched_json_schema_to_python_type
|
27 |
|
28 |
+
print("✅ Enhanced Gradio patch applied successfully")
|
29 |
except ImportError:
|
30 |
print("❌ Could not import gradio_client.utils to apply patch")
|
31 |
except Exception as e:
|
requirements.txt
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
-
gradio
|
2 |
-
fastapi
|
3 |
-
uvicorn
|
4 |
-
gtts
|
5 |
-
openai
|
6 |
-
# Add any other dependencies your app needs
|
|
|
1 |
+
gradio==3.34.0
|
2 |
+
fastapi==0.95.2
|
3 |
+
uvicorn==0.22.0
|
4 |
+
gtts==2.3.2
|
5 |
+
openai==1.6.1
|
|