-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (41 loc) · 1.19 KB
/
main.py
File metadata and controls
52 lines (41 loc) · 1.19 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
from contextlib import asynccontextmanager
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
from app.core import settings
from app.infrastructure.postgres import (
init_database_on_app,
shutdown_database_on_app,
)
from app.infrastructure.providers.gemini import (
init_gemini_text_extractor_on_app,
)
from app.infrastructure.qdrant import (
init_qdrant_on_app,
shutdown_qdrant_on_app,
)
from app.api import router as api_router
@asynccontextmanager
async def lifespan(app: FastAPI):
await init_database_on_app(app)
await init_gemini_text_extractor_on_app(app)
await init_qdrant_on_app(app)
yield
await shutdown_database_on_app(app)
await shutdown_qdrant_on_app(app)
app = FastAPI(
title=settings.PROJECT_NAME,
description="An API for managing documents and performing retrieval augmented generation tasks.",
version="0.1.0",
lifespan=lifespan,
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(api_router)
@app.get("/health/", tags=["Health"])
async def health_check():
return {"status": "healthy"}