Kashish commited on
Commit ·
f9ad9a3
1
Parent(s): 83604ad
serve swagger ui at root
Browse files12 unmodified lines131415161718192021221 unmodified line24252627282930313233343536373839404142434445464748495051525312 unmodified lines@asynccontextmanagerasync def lifespan(app: FastAPI):"""Lifespan handler — retriever initialises lazily on the first request."""logger.info("=== FAQ RAG Chatbot starting up ===")yieldlogger.info("=== FAQ RAG Chatbot shutting down ===")app = FastAPI(1 unmodified lineversion="1.0.0",description="RAG-based chatbot for samagama internship portal - CSFAQ Project",openapi_url="/openapi.json",lifespan=lifespan,)class ChatRequest(BaseModel):question: str = Field(..., min_length=1, description="User question to answer from FAQ context")class ChatResponse(BaseModel):question: stranswer: strsources: list[str] = Field(default_factory=list)@app.get("/health")async def health() -> dict[str, str]:return {"status": "ok"}@app.get("/", include_in_schema=False)async def root() -> dict[str, str]:return {"status": "ready", "message": "FAQ RAG Chatbot is running"}@app.post("/chat", response_model=ChatResponse)async def chat(payload: ChatRequest) -> ChatResponse:question = payload.question.strip()12 unmodified lines1314151617181920211 unmodified line23242526272829303132333435363738394041424344454612 unmodified lines@asynccontextmanagerasync def lifespan(app: FastAPI):logger.info("FAQ RAG Chatbot starting up")yieldlogger.info("FAQ RAG Chatbot shutting down")app = FastAPI(1 unmodified lineversion="1.0.0",description="RAG-based chatbot for samagama internship portal - CSFAQ Project",openapi_url="/openapi.json",docs_url="/",lifespan=lifespan,)class ChatRequest(BaseModel):question: str = Field(..., min_length=1, description="User Query..")class ChatResponse(BaseModel):question: stranswer: strsources: list[str] = Field(default_factory=list)@app.get("/health")async def health() -> dict[str, str]:return {"status": "ok"}@app.post("/chat", response_model=ChatResponse)async def chat(payload: ChatRequest) -> ChatResponse:question = payload.question.strip()
app.py+4-11