File size: 1,464 Bytes
f61fc62 493d9a8 f61fc62 493d9a8 f61fc62 493d9a8 f61fc62 493d9a8 f61fc62 493d9a8 f61fc62 493d9a8 f61fc62 493d9a8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# Comprehensive patch for Gradio's boolean schema handling issues
import sys
def patch_gradio():
try:
import gradio_client.utils
# Store the original functions
original_get_type = gradio_client.utils.get_type
original_json_schema_to_python_type = gradio_client.utils._json_schema_to_python_type
# Create a fixed version of get_type that handles booleans
def patched_get_type(schema):
if isinstance(schema, bool):
return "bool"
return original_get_type(schema)
# Create a fixed version of _json_schema_to_python_type that handles booleans
def patched_json_schema_to_python_type(schema, defs=None):
if isinstance(schema, bool):
return "bool"
return original_json_schema_to_python_type(schema, defs)
# Replace the original functions with our patched versions
gradio_client.utils.get_type = patched_get_type
gradio_client.utils._json_schema_to_python_type = patched_json_schema_to_python_type
print("✅ Enhanced Gradio patch applied successfully")
except ImportError:
print("❌ Could not import gradio_client.utils to apply patch")
except Exception as e:
print(f"❌ Failed to apply Gradio patch: {str(e)}")
# Apply the patch immediately when this module is imported
patch_gradio() |