-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (42 loc) · 1.45 KB
/
main.py
File metadata and controls
59 lines (42 loc) · 1.45 KB
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
"""
Pulse FastAPI application — main entry point.
The AIRouter is initialized at startup and stored on app.state so every
route handler can access it via request.app.state.ai_router.
"""
from __future__ import annotations
import logging
from contextlib import asynccontextmanager
from fastapi import FastAPI
from integrations.ai.router import AIRouter
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s — %(message)s",
)
logger = logging.getLogger(__name__)
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Startup / shutdown lifecycle for the Pulse app."""
# --- Startup ---
logger.info("Initializing AI router …")
ai_router = AIRouter()
app.state.ai_router = ai_router
health = await ai_router.health()
for model, status in health.items():
logger.info(" %s: %s", model, status)
yield
# --- Shutdown ---
logger.info("Pulse shutting down.")
app = FastAPI(
title="Pulse",
description="AIOS/Pulse — organizational AI backend for CHCA District 1199NE",
version="0.1.0",
lifespan=lifespan,
)
# --- Route imports -----------------------------------------------------------
from api.v1.ai_routes import router as ai_api_router # noqa: E402
from api.v1.capture import router as capture_router # noqa: E402
app.include_router(ai_api_router)
app.include_router(capture_router)
@app.get("/health")
async def health_check():
return {"status": "ok"}