legco_ai_assistant/backend/app/core/dependencies.py

31 lines
845 B
Python

from __future__ import annotations
from functools import lru_cache
from app.core.config import Settings, get_settings
@lru_cache()
def get_settings_cached() -> Settings:
return get_settings()
# Placeholder for future DI wiring. Tests patch classes directly, so we keep
# a minimal API here to avoid import-time side effects.
def get_llm_client():
settings = get_settings_cached()
from app.services.llm_client import LLMClient
return LLMClient(settings)
def get_rag_service():
# Import lazily to avoid circular imports in tests
from app.services.rag import RAGService
llm = get_llm_client()
return RAGService(llm_client=llm)
def get_prompt_service():
from app.services.prompt_service import PromptService
settings = get_settings_cached()
return PromptService(db_path=settings.prompts_db_path)