Spaces:
Sleeping
Sleeping
Download chatbot/app.py from PradeepVerma23/PolicyAI: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/spaces/PradeepVerma23/PolicyAI/resolve/main/chatbot/app.py
- Command line
-
hf download hf://spaces/PradeepVerma23/PolicyAI/chatbot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/PradeepVerma23/PolicyAI/resolve/main/chatbot/app.py
1.72 kB
| """ | |
| 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, | |
| ) | |