Update gui.py
Browse files
gui.py
CHANGED
|
@@ -15,14 +15,14 @@ from processing import process_audio, auto_ensemble_process, ensemble_audio_fn,
|
|
| 15 |
from assets.i18n.i18n import I18nAuto
|
| 16 |
from config_manager import load_config, save_config, update_favorites, save_preset, delete_preset
|
| 17 |
import logging
|
| 18 |
-
from
|
| 19 |
|
| 20 |
# Set up logging for the patch
|
| 21 |
logging.basicConfig(filename='gradio_schema.log', level=logging.DEBUG)
|
| 22 |
logger = logging.getLogger('gradio_schema')
|
| 23 |
|
| 24 |
# Patch gradio_client.utils._json_schema_to_python_type
|
| 25 |
-
original_json_schema_to_python_type =
|
| 26 |
|
| 27 |
def patched_json_schema_to_python_type(schema: any, defs: dict | None = None) -> str:
|
| 28 |
logger.debug(f"Parsing schema: {schema}")
|
|
@@ -37,11 +37,11 @@ def patched_json_schema_to_python_type(schema: any, defs: dict | None = None) ->
|
|
| 37 |
return f"Literal[{', '.join(repr(e) for e in schema['enum'])}]"
|
| 38 |
try:
|
| 39 |
return original_json_schema_to_python_type(schema, defs)
|
| 40 |
-
except
|
| 41 |
logger.error(f"Failed to parse schema {schema}: {e}")
|
| 42 |
return "str"
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
# General logging setup
|
| 47 |
logging.basicConfig(filename='sesa_gui.log', level=logging.DEBUG)
|
|
|
|
| 15 |
from assets.i18n.i18n import I18nAuto
|
| 16 |
from config_manager import load_config, save_config, update_favorites, save_preset, delete_preset
|
| 17 |
import logging
|
| 18 |
+
from gradio_client import utils # Updated import
|
| 19 |
|
| 20 |
# Set up logging for the patch
|
| 21 |
logging.basicConfig(filename='gradio_schema.log', level=logging.DEBUG)
|
| 22 |
logger = logging.getLogger('gradio_schema')
|
| 23 |
|
| 24 |
# Patch gradio_client.utils._json_schema_to_python_type
|
| 25 |
+
original_json_schema_to_python_type = utils._json_schema_to_python_type
|
| 26 |
|
| 27 |
def patched_json_schema_to_python_type(schema: any, defs: dict | None = None) -> str:
|
| 28 |
logger.debug(f"Parsing schema: {schema}")
|
|
|
|
| 37 |
return f"Literal[{', '.join(repr(e) for e in schema['enum'])}]"
|
| 38 |
try:
|
| 39 |
return original_json_schema_to_python_type(schema, defs)
|
| 40 |
+
except utils.APIInfoParseError as e:
|
| 41 |
logger.error(f"Failed to parse schema {schema}: {e}")
|
| 42 |
return "str"
|
| 43 |
|
| 44 |
+
utils._json_schema_to_python_type = patched_json_schema_to_python_type
|
| 45 |
|
| 46 |
# General logging setup
|
| 47 |
logging.basicConfig(filename='sesa_gui.log', level=logging.DEBUG)
|