# app/api/dependencies.py from fastapi import Depends, HTTPException, status from typing import List from sqlalchemy.orm import Session from app.db.session import SessionLocal from app.core.retrievers import Retriever from app.core.services.document import DocumentService from app.core.services.rag import RAGService from app.core.vector_store.faiss_store import FaissVectorStore # This is a dependency def get_db(): db = SessionLocal() try: yield db finally: db.close() # This is another common dependency async def get_current_user(token: str): # In a real app, you would decode the token and fetch the user if not token: raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED) return {"email": "user@example.com", "id": 1} # Dummy user class ServiceContainer: def __init__(self, vector_store: FaissVectorStore, retrievers: List[Retriever]): # Initialize all services within the container self.document_service = DocumentService(vector_store=vector_store) self.rag_service = RAGService( retrievers=retrievers )