import gradio_client.utils # Store the original function to maintain its behavior original_json_schema_to_python_type = gradio_client.utils._json_schema_to_python_type # Define the patched function def patched_json_schema_to_python_type(schema, defs=None): try: # Check if schema is a boolean - handle this special case if isinstance(schema, bool): return "any" # Return a sensible default type for boolean schemas # Continue with original function for non-boolean schemas return original_json_schema_to_python_type(schema, defs) except Exception as e: print(f"Error parsing schema: {schema}, Error: {e}") return "any" # Return a default type for invalid schemas # Apply the patch gradio_client.utils._json_schema_to_python_type = patched_json_schema_to_python_type # Also patch the wrapper function that calls the internal function def patched_json_schema_to_python_type_wrapper(schema, defs=None): try: return patched_json_schema_to_python_type(schema, schema.get("$defs")) except Exception as e: print(f"Error in wrapper: {e}") return "any" # Apply the wrapper patch gradio_client.utils.json_schema_to_python_type = patched_json_schema_to_python_type_wrapper