| """ | |
| Entry point for Hugging Face Spaces deployment. | |
| This file is required by Hugging Face Spaces to run the FastAPI application. | |
| It imports and runs the FastAPI app from 2_backend_llm/app/api. | |
| Hugging Face Spaces will automatically detect this file and run it. | |
| The app will be available on port 7860 (HF Spaces default). | |
| """ | |
| from __future__ import annotations | |
| import os | |
| import sys | |
| from pathlib import Path | |
| # Add 2_backend_llm to Python path so we can import from app package | |
| backend_path = Path(__file__).parent / "2_backend_llm" | |
| if str(backend_path) not in sys.path: | |
| sys.path.insert(0, str(backend_path)) | |
| import uvicorn | |
| # Import the FastAPI app from the app package | |
| from app.api import app | |
| # Hugging Face Spaces will call this file directly | |
| # The app is already defined in app.api, so we just need to run it | |
| if __name__ == "__main__": | |
| # Get port from environment variable (HF Spaces sets this) or default to 7860 | |
| port = int(os.environ.get("PORT", 7860)) | |
| # Run on all interfaces (0.0.0.0) - required for HF Spaces | |
| uvicorn.run(app, host="0.0.0.0", port=port) | |