Spaces:
Sleeping
Sleeping
File size: 2,211 Bytes
402298d 24e6b59 0c65cd5 402298d e87fd2c ade7925 402298d e87fd2c 402298d 24e6b59 08d20f8 e91b1d8 08d20f8 402298d 0c65cd5 402298d 0c65cd5 402298d b0319bf 8c90c5a 402298d 8c90c5a |
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
"""Main FastAPI application entry point"""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.config import settings
from app.routes import ingest_routes, ask_routes, metrics_routes, debug_routes
from app.services.vector_store import vector_store
from app.utils.logger import setup_logger
logger = setup_logger(__name__)
app = FastAPI(
title="WorkWise Backend GPU",
description="RAG-powered Jira analytics application !!",
version="1.0.0"
)
# CORS Middleware
app.add_middleware(
CORSMiddleware,
allow_origins=settings.ALLOWED_ORIGINS if hasattr(settings, "ALLOWED_ORIGINS") else ["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(ingest_routes.router, prefix="/api", tags=["Ingestion"])
app.include_router(ask_routes.router, prefix="/api", tags=["Query"])
app.include_router(metrics_routes.router, prefix="/api", tags=["Metrics"])
app.include_router(debug_routes.router, prefix="/api", tags=["Debug"])
logger.info("✅ Routers initialized ::")
for route in app.routes:
logger.info(f" - {route.path}")
@app.get("/")
async def root():
"""Health check endpoint"""
return {
"status": "online",
"service": "WorkWise API",
"version": "1.0.0"
}
@app.get("/health")
async def health_check():
"""Detailed health check"""
try:
info = vector_store.get_collection_info()
return {
"status": "healthy",
"index_path": settings.FAISS_INDEX_PATH,
"payloads_path": settings.FAISS_PAYLOADS_PATH,
"vectors_count": info.get("vectors_count", 0)
#"qdrant_url": settings.QDRANT_URL,
#"collection": settings.QDRANT_COLLECTION_NAME
}
except Exception as e:
logger.error(f"Health check failed: {e}")
return {"status": "error", "message": str(e)}
# This is needed only when this was a Docker Space. Remove for Gradio
'''
if __name__ == "__main__":
import uvicorn
uvicorn.run(
"app.main:app",
host=settings.HOST,
port=settings.PORT,
reload=True,
log_level=settings.LOG_LEVEL
)
''' |