# Patch for Gradio's 'bool' is not iterable error | |
import sys | |
def patch_gradio(): | |
try: | |
import gradio_client.utils | |
# Store the original get_type function | |
original_get_type = gradio_client.utils.get_type | |
# Create a fixed version that handles booleans | |
def patched_get_type(schema): | |
if isinstance(schema, bool): | |
return "bool" | |
return original_get_type(schema) | |
# Replace the original function with our patched version | |
gradio_client.utils.get_type = patched_get_type | |
print("β 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() |