aivre / app /dependencies.py
Vedang Barhate
chore: copied from assist repo
cfc8e23
raw
history blame
583 Bytes
from typing import Annotated
from fastapi import Depends
from app.services.rag_service import RAGService
_rag_service_instance = None
def set_rag_service(service: RAGService):
"""Set the global RAG service instance"""
global _rag_service_instance
_rag_service_instance = service
def get_rag_service() -> RAGService:
"""Dependency to get the RAG service instance"""
if _rag_service_instance is None:
raise RuntimeError("RAG service not initialized")
return _rag_service_instance
RAGServiceDep = Annotated[RAGService, Depends(get_rag_service)]