|
|
""" |
|
|
Hugging Face Spaces entrypoint for the DRIVE/RLDT Gradio interface. |
|
|
|
|
|
The script keeps dependencies lightweight and reuses the existing |
|
|
``create_gradio_interface`` factory so Spaces can discover the app without |
|
|
command-line flags. Environment variable support mirrors the CLI path in |
|
|
``RL0910/enhanced_chat_ui.py``. |
|
|
""" |
|
|
try: |
|
|
import gradio_client.utils as gcu |
|
|
|
|
|
_orig = gcu._json_schema_to_python_type |
|
|
|
|
|
def _patched_json_schema_to_python_type(schema, defs=None): |
|
|
|
|
|
if schema is True: |
|
|
return "Any" |
|
|
if schema is False or schema is None: |
|
|
return "Any" |
|
|
|
|
|
|
|
|
if isinstance(schema, dict): |
|
|
ap = schema.get("additionalProperties", None) |
|
|
if isinstance(ap, bool): |
|
|
schema = dict(schema) |
|
|
schema["additionalProperties"] = {} |
|
|
|
|
|
try: |
|
|
return _orig(schema, defs) |
|
|
except Exception: |
|
|
|
|
|
return "Any" |
|
|
|
|
|
gcu._json_schema_to_python_type = _patched_json_schema_to_python_type |
|
|
|
|
|
except Exception: |
|
|
|
|
|
pass |
|
|
import os |
|
|
|
|
|
|
|
|
os.environ.setdefault("PANDAS_USE_PYARROW_BACKEND", "0") |
|
|
os.environ.setdefault("PANDAS_USE_PYARROW_EXTENSION_ARRAY", "0") |
|
|
|
|
|
from RL0910.enhanced_chat_ui import create_gradio_interface |
|
|
try: |
|
|
import gradio_client.utils as _gcu |
|
|
|
|
|
if not getattr(_gcu, "_BOOL_SCHEMA_PATCHED", False): |
|
|
_orig_get_type = _gcu.get_type |
|
|
|
|
|
def _patched_get_type(schema): |
|
|
|
|
|
if isinstance(schema, bool): |
|
|
|
|
|
return "Any" |
|
|
return _orig_get_type(schema) |
|
|
|
|
|
_gcu.get_type = _patched_get_type |
|
|
_gcu._BOOL_SCHEMA_PATCHED = True |
|
|
except Exception: |
|
|
|
|
|
pass |
|
|
|
|
|
demo = create_gradio_interface() |
|
|
|
|
|
|
|
|
def main() -> None: |
|
|
"""Launch the Gradio demo on the port provided by Hugging Face Spaces.""" |
|
|
port = int(os.getenv("PORT", "7860")) |
|
|
demo.launch(server_name="0.0.0.0", server_port=port, share=False) |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
|