"""LlamaIndex backend package for ``ketju.rag``."""

from __future__ import annotations

from typing import Any, TYPE_CHECKING

from ketju.rag.base import BaseRAG

if TYPE_CHECKING:  # pragma: no cover
    from .variants.simple import LlamaIndexRag, SimplePdfRag, create_simple_llama_index_pdf_rag
    from .variants.simple_docling import SimpleDoclingRag
    from .variants.simple_docling_full_ctx import SimpleDoclingFullCtxRag
    from .variants.full_doc_in_ctx import FullDocInCtxRag
    from .storage.local import LocalStorageBackend
    from .storage.pgvector import PgVectorStorageBackend
    from .variants.pgvector import PgVectorRag, build_pgvector_rag


__all__ = [
    "BaseRAG",
    "LlamaIndexRag",
    "create_simple_llama_index_pdf_rag",
    "LocalStorageBackend",
    "SimplePdfRag",
    "SimpleDoclingRag",
    "SimpleDoclingFullCtxRag",
    "FullDocInCtxRag",
    "PgVectorRag",
    "PgVectorStorageBackend",
    "build_pgvector_rag",
]


def __getattr__(name: str) -> Any:  # pragma: no cover
    if name == "LlamaIndexRag":
        from .variants.simple import LlamaIndexRag as _LlamaIndexRag

        return _LlamaIndexRag
    if name == "create_simple_llama_index_pdf_rag":
        from .variants.simple import create_simple_llama_index_pdf_rag as _create_simple_llama_index_pdf_rag

        return _create_simple_llama_index_pdf_rag
    if name == "LocalStorageBackend":
        from .storage.local import LocalStorageBackend as _LocalStorageBackend

        return _LocalStorageBackend
    if name == "SimplePdfRag":
        from .variants.simple import SimplePdfRag as _SimplePdfRag

        return _SimplePdfRag
    if name == "SimpleDoclingRag":
        from .variants.simple_docling import SimpleDoclingRag as _SimpleDoclingRag

        return _SimpleDoclingRag
    if name == "SimpleDoclingFullCtxRag":
        from .variants.simple_docling_full_ctx import (
            SimpleDoclingFullCtxRag as _SimpleDoclingFullCtxRag,
        )

        return _SimpleDoclingFullCtxRag
    if name == "FullDocInCtxRag":
        from .variants.full_doc_in_ctx import FullDocInCtxRag as _FullDocInCtxRag

        return _FullDocInCtxRag
    if name == "PgVectorRag":
        from .variants.pgvector import PgVectorRag as _PgVectorRag

        return _PgVectorRag
    if name == "PgVectorStorageBackend":
        from .storage.pgvector import PgVectorStorageBackend as _PgVectorStorageBackend

        return _PgVectorStorageBackend
    if name == "build_pgvector_rag":
        from .variants.pgvector import build_pgvector_rag as _build_pgvector_rag

        return _build_pgvector_rag
    raise AttributeError(name)