Spaces:
Runtime error
Runtime error
Download main.py from Nikpatil/chatbot_theme_identifier: direct link, hf CLI and curl.
- Browser
- Download file 2.72 kB
-
https://huggingface.co/spaces/Nikpatil/chatbot_theme_identifier/resolve/main/main.py
- Command line
-
hf download hf://spaces/Nikpatil/chatbot_theme_identifier/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Nikpatil/chatbot_theme_identifier/resolve/main/main.py
2.72 kB
| # #!/usr/bin/env python3 | |
| # """ | |
| # Startup script for the Document Research & Theme Identification API | |
| # """ | |
| # import os | |
| # import sys | |
| # from pathlib import Path | |
| # def check_environment(): | |
| # """Check if all required environment variables and files exist""" | |
| # print("π Checking environment...") | |
| # # Check for .env file | |
| # if not Path(".env").exists(): | |
| # print("β οΈ .env file not found. Please create one based on .env.template") | |
| # print(" You can copy: cp .env.template .env") | |
| # return False | |
| # # Check for Groq API key | |
| # from dotenv import load_dotenv | |
| # load_dotenv() | |
| # if not os.getenv("GROQ_API_KEY"): | |
| # print("β οΈ GROQ_API_KEY not found in environment variables") | |
| # print(" Theme synthesis will not be available") | |
| # print(" Get your API key from: https://console.groq.com/") | |
| # return False | |
| # print("β Environment check passed!") | |
| # return True | |
| # def install_dependencies(): | |
| # """Install required dependencies""" | |
| # print("π¦ Installing dependencies...") | |
| # os.system("pip install -r requirements.txt") | |
| # print("β Dependencies installed!") | |
| # def create_directories(): | |
| # """Create necessary directories""" | |
| # print("π Creating directories...") | |
| # directories = ["./data", "./data/chroma_db", "./data/uploads"] | |
| # for directory in directories: | |
| # Path(directory).mkdir(parents=True, exist_ok=True) | |
| # print("β Directories created!") | |
| # def main(): | |
| # """Main startup function""" | |
| # print("π Starting Document Research & Theme Identification API...") | |
| # print("=" * 60) | |
| # # Create directories | |
| # create_directories() | |
| # # Install dependencies | |
| # if "--install" in sys.argv: | |
| # install_dependencies() | |
| # # Check environment | |
| # env_ok = check_environment() | |
| # print("=" * 60) | |
| # if env_ok: | |
| # print("π Setup complete! Starting the API server...") | |
| # print("π API will be available at: http://localhost:8000") | |
| # print("π API documentation at: http://localhost:8000/docs") | |
| # print() | |
| # # Start the API | |
| # if "--dev" in sys.argv: | |
| # os.system("uvicorn api:app --host 0.0.0.0 --port 8000 --reload") | |
| # else: | |
| # os.system("uvicorn api:app --host 0.0.0.0 --port 8000") | |
| # else: | |
| # print("β Setup incomplete. Please fix the issues above and try again.") | |
| # sys.exit(1) | |
| # if __name__ == "__main__": | |
| # import uvicorn | |
| # uvicorn.run("api:app", host="0.0.0.0", port=8000, reload=True) |