|
|
""" |
|
|
Main FastAPI application |
|
|
""" |
|
|
from fastapi import FastAPI |
|
|
from fastapi.middleware.cors import CORSMiddleware |
|
|
from fastapi.staticfiles import StaticFiles |
|
|
from .api.routes import router |
|
|
from .config import CORS_ORIGINS, ASSETS_DIR, FRONTEND_DIST_DIR |
|
|
|
|
|
|
|
|
def create_app() -> FastAPI: |
|
|
"""Create and configure the FastAPI application""" |
|
|
app = FastAPI(title="Edge LLM API") |
|
|
|
|
|
|
|
|
app.add_middleware( |
|
|
CORSMiddleware, |
|
|
allow_origins=CORS_ORIGINS, |
|
|
allow_credentials=True, |
|
|
allow_methods=["*"], |
|
|
allow_headers=["*"], |
|
|
) |
|
|
|
|
|
|
|
|
app.mount("/assets", StaticFiles(directory=ASSETS_DIR), name="assets") |
|
|
|
|
|
|
|
|
app.include_router(router) |
|
|
|
|
|
@app.on_event("startup") |
|
|
async def startup_event(): |
|
|
"""Startup event - don't load models by default""" |
|
|
print("π Edge LLM API is starting up...") |
|
|
print("π‘ Models will be loaded on demand") |
|
|
|
|
|
return app |
|
|
|
|
|
|
|
|
|
|
|
app = create_app() |
|
|
|