Spaces:
Runtime error
Runtime error
File size: 805 Bytes
1914b78 | 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 |
from src.utils.logging import add_logger
# from src.pipeline.gen_query import generate_query
from src.service.routes import router
from fastapi import FastAPI
from src.pipeline.load_model import load_llm_model
from src.utils import config
from fastapi.middleware.cors import CORSMiddleware
from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(app: FastAPI):
print("🚀 Loading model at startup...")
from src.utils.config import get_model
get_model() # loads and caches
print("✅ Model ready!")
yield
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # allow all (for dev)
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
add_logger()
#
app.include_router(router)
|