2024-09-23 10:12:35 -04:00
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
|
2024-09-06 11:07:45 -04:00
|
|
|
from fastapi import FastAPI
|
2024-09-23 10:12:35 -04:00
|
|
|
from fastapi.responses import JSONResponse
|
2024-09-06 11:07:45 -04:00
|
|
|
|
2024-09-23 10:12:35 -04:00
|
|
|
from graph_service.config import get_settings
|
2024-09-06 11:07:45 -04:00
|
|
|
from graph_service.routers import ingest, retrieve
|
2024-09-23 10:12:35 -04:00
|
|
|
from graph_service.zep_graphiti import initialize_graphiti
|
|
|
|
|
|
|
|
|
|
|
|
@asynccontextmanager
|
|
|
|
async def lifespan(_: FastAPI):
|
|
|
|
settings = get_settings()
|
|
|
|
await initialize_graphiti(settings)
|
|
|
|
yield
|
|
|
|
# Shutdown
|
|
|
|
# No need to close Graphiti here, as it's handled per-request
|
|
|
|
|
2024-09-06 11:07:45 -04:00
|
|
|
|
2024-09-23 10:12:35 -04:00
|
|
|
app = FastAPI(lifespan=lifespan)
|
2024-09-06 11:07:45 -04:00
|
|
|
|
|
|
|
|
|
|
|
app.include_router(retrieve.router)
|
|
|
|
app.include_router(ingest.router)
|
|
|
|
|
|
|
|
|
2024-09-23 10:12:35 -04:00
|
|
|
@app.get('/healthcheck')
|
|
|
|
async def healthcheck():
|
|
|
|
return JSONResponse(content={'status': 'healthy'}, status_code=200)
|