Source code for rag.core.strategy

"""RAG orchestration strategies (one persist dir per strategy)."""

from __future__ import annotations

from enum import StrEnum
from pathlib import Path
from typing import Final

[docs] RAG_STRATEGY_ENV: Final = "RAG_STRATEGY"
[docs] INDEXES_DIR_NAME: Final = "indexes"
[docs] INGEST_ALL: Final = "all"
[docs] class RagStrategy(StrEnum): """In-process orchestration library used to ingest and query the PDF corpus."""
[docs] LLAMAINDEX = "llamaindex"
[docs] LANGCHAIN = "langchain"
@classmethod
[docs] def ingestible(cls) -> tuple[RagStrategy, ...]: """Return strategies that write a local index via ``papers-ingest``. Returns ------- tuple of RagStrategy Every in-process backend (LlamaIndex and LangChain). """ return tuple(cls)
[docs] def index_dir_for(*, repo_root: Path, strategy: RagStrategy) -> Path: """Return the default persist directory for a strategy. Parameters ---------- repo_root : Path Monorepo root. strategy : RagStrategy Orchestration backend. Returns ------- Path ``{repo_root}/.data/indexes/{strategy}``. """ return (repo_root / ".data" / INDEXES_DIR_NAME / strategy.value).resolve()