Spaces:
Runtime error
Runtime error
feat: synchronize text-to-sql-bot codebase with Hugging Face Space repository, including Docker build configurations
6086e71 | import sys | |
| import os | |
| import traceback | |
| import json | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from app.config import get_settings | |
| from app.db.connection import DatabasePool | |
| from app.llm.router import ModelRouter | |
| from app.rag.retriever import HybridRetriever | |
| from app.agents.orchestrator import AgentOrchestrator | |
| try: | |
| settings = get_settings() | |
| db_pool = DatabasePool( | |
| settings.DB_URI, | |
| query_timeout=settings.DB_QUERY_TIMEOUT, | |
| pool_size=settings.DB_POOL_SIZE, | |
| max_overflow=settings.DB_MAX_OVERFLOW, | |
| pool_timeout=settings.DB_POOL_TIMEOUT, | |
| ) | |
| llm_config = { | |
| "default_provider": settings.DEFAULT_LLM_PROVIDER, | |
| "groq_api_key": settings.GROQ_API_KEY, | |
| "groq_model_primary": settings.GROQ_MODEL_PRIMARY, | |
| "groq_model_fast": settings.GROQ_MODEL_FAST, | |
| "groq_base_url": settings.GROQ_BASE_URL, | |
| "huggingface_token": settings.HUGGINGFACEHUB_API_TOKEN, | |
| "huggingface_model": settings.DEFAULT_MODEL, | |
| "openai_api_key": settings.OPENAI_API_KEY, | |
| "anthropic_api_key": settings.ANTHROPIC_API_KEY, | |
| "ollama_base_url": settings.OLLAMA_BASE_URL, | |
| } | |
| llm_router = ModelRouter(llm_config) | |
| # Bypass loading models in semantic cache by patching it | |
| # to speed up execution | |
| AgentOrchestrator._init_semantic_cache = staticmethod(lambda: None) | |
| # Disable vector rag to speed up execution | |
| os.environ["DISABLE_VECTOR_RAG"] = "true" | |
| os.environ["DISABLE_ML_INTENT"] = "true" | |
| rag_retriever = HybridRetriever(db_pool, chroma_persist_dir=settings.CHROMA_PERSIST_DIR) | |
| orchestrator = AgentOrchestrator(llm_router, rag_retriever, db_pool) | |
| initial_state = { | |
| "user_query": "show me top 5 employees", | |
| "conversation_history": [], | |
| "tenant_id": "default", | |
| "user_role": "analyst", | |
| "trace_id": "debug", | |
| } | |
| res = orchestrator.graph.invoke(initial_state, config={"recursion_limit": 50}) | |
| # Write output as JSON with UTF-8 encoding | |
| with open("debug_output.json", "w", encoding="utf-8") as f: | |
| json.dump(dict(res), f, ensure_ascii=False, indent=2, default=str) | |
| print("Execution completed successfully. Output written to debug_output.json") | |
| except Exception: | |
| print("--- RAW TRACEBACK ---") | |
| traceback.print_exc() | |