from __future__ import annotations from functools import lru_cache from fastapi import FastAPI from app.config import get_settings from app.schemas import QueryRequest, QueryResponse from app.service import AgenticRAGService app = FastAPI( title="Agentic RAG Course Project", version="1.0.0", ) @lru_cache(maxsize=1) def get_service() -> AgenticRAGService: return AgenticRAGService(get_settings()) @app.get("/health") def health() -> dict[str, str]: return {"status": "ok"} @app.post("/query", response_model=QueryResponse) def query(request: QueryRequest) -> QueryResponse: return get_service().invoke(request)