Spaces:
Running
Running
| """ | |
| Hugging Face Spaces entry point for DemoPrep. | |
| Secrets to set in HF Spaces β Settings β Repository Secrets: | |
| SUPABASE_URL Supabase project URL | |
| SUPABASE_ANON_KEY Supabase anonymous key | |
| OPENAI_API_KEY OpenAI API key (primary LLM) | |
| GOOGLE_API_KEY Google API key (optional, for Gemini models) | |
| All other credentials (Snowflake, ThoughtSpot) are stored in Supabase | |
| admin settings and loaded at runtime β no extra HF secrets needed. | |
| """ | |
| import os | |
| import sys | |
| from pathlib import Path | |
| # Ensure repo root is on the path | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| # Patch gradio_client bug: schema traversal crashes when schema is a bool | |
| # (happens when a component has additionalProperties: true in its JSON schema). | |
| # Both get_type() and _json_schema_to_python_type() must guard against non-dict input. | |
| import gradio_client.utils as _gcu | |
| _orig_get_type = _gcu.get_type | |
| _gcu.get_type = lambda schema: _orig_get_type(schema) if isinstance(schema, dict) else "any" | |
| _orig_j2p = _gcu._json_schema_to_python_type | |
| _gcu._json_schema_to_python_type = lambda schema, defs=None: "any" if not isinstance(schema, dict) else _orig_j2p(schema, defs) | |
| os.makedirs("results", exist_ok=True) | |
| os.makedirs("demo_logs", exist_ok=True) | |
| from chat_interface import create_chat_interface, authenticate_user | |
| app = create_chat_interface() | |
| app.queue( | |
| default_concurrency_limit=10, | |
| api_open=False, | |
| ) | |
| # Bypass Gradio localhost accessibility check (httpx 0.28 compatibility) | |
| import gradio.networking as _gn | |
| _gn.url_ok = lambda url: True | |
| app.launch( | |
| server_name="0.0.0.0", | |
| server_port=7860, | |
| share=False, | |
| inbrowser=False, | |
| auth=authenticate_user, | |
| show_api=False, | |
| ) | |