matrix-terminal-posthog-cv/app/main.py
Kyle Stevenson c0d41413a6 backend core
2026-08-11 14:20:56 +01:00

34 lines
879 B
Python

from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from .config import WEB_DIR
from .llm_client import warm_up
from .persona import load_system_prompt
from .routes import chat, pages
@asynccontextmanager
async def lifespan(_: FastAPI):
"""
By the time we get here, docker-compose has already waited for llama-cpp's
health check, so this hits a server that's loaded and ready — no retry loop needed.
"""
system_prompt = load_system_prompt()
if system_prompt:
await warm_up(system_prompt)
yield
app = FastAPI(
title="Oracle Terminal",
docs_url="/api/docs",
openapi_url="/api/openapi.json",
lifespan=lifespan,
)
app.mount("/static", StaticFiles(directory=WEB_DIR / "static"), name="static")
app.include_router(pages.router)
app.include_router(chat.router)