Spaces:
Sleeping
Sleeping
File size: 1,717 Bytes
12bb39f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | """
app.py β PolicyAI Chatbot entry point
Responsibilities (and ONLY these)
-----------------------------------
1. Bootstrap the Python path so sibling modules can import from langchain_rag/.
2. Import the pre-built Gradio demo from ui.py.
3. Call demo.launch() with server settings and the CSS theme.
Run locally
-----------
cd D:\\...\\PolicyAI
python chatbot\\app.py
Hugging Face Spaces
-------------------
Set GROQ_API_KEY as a Space secret.
README.md frontmatter: app_file: chatbot/app.py
"""
import os
import sys
from pathlib import Path
# ββ Path bootstrap (must happen before any project imports) βββββββββββββββββββ
# ROOT = PolicyAI/ (one level above chatbot/)
ROOT = Path(__file__).parent.parent
# Anchor relative paths (./qdrant_data, ./data/) to the project root
os.chdir(ROOT)
# Allow `from config import ...` and `import 02_query` to resolve from langchain_rag/
sys.path.insert(0, str(ROOT / "langchain_rag"))
# ββ Application imports (after path bootstrap) ββββββββββββββββββββββββββββββββ
from ui import demo # builds the Gradio layout + wires events
from styles import CSS # dark-theme stylesheet
# ββ Launch ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
if __name__ == "__main__":
demo.launch(
server_name="0.0.0.0", # bind all interfaces (required for HF Spaces)
server_port=7860, # HF Spaces default port
share=False,
css=CSS,
)
|