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)
