rag.core.config =============== .. py:module:: rag.core.config .. autoapi-nested-parse:: Configuration for the papers RAG pipeline. Attributes ---------- .. autoapisummary:: rag.core.config.PAPERS_DIR_ENV rag.core.config.CHROMA_DIR_ENV rag.core.config.CHROMA_COLLECTION_ENV rag.core.config.EMBED_MODEL_ENV rag.core.config.OPENAI_API_KEY_ENV rag.core.config.OPENAI_MODEL_ENV rag.core.config.CHUNK_SIZE_ENV rag.core.config.CHUNK_OVERLAP_ENV rag.core.config.SIMILARITY_TOP_K_ENV rag.core.config.DEFAULT_COLLECTION_NAME rag.core.config.DEFAULT_EMBED_MODEL rag.core.config.DEFAULT_LLM_MODEL rag.core.config.DEFAULT_CHUNK_SIZE rag.core.config.DEFAULT_CHUNK_OVERLAP rag.core.config.DEFAULT_SIMILARITY_TOP_K Classes ------- .. autoapisummary:: rag.core.config.RagConfig Functions --------- .. autoapisummary:: rag.core.config.find_repo_root rag.core.config.load_repo_dotenv Module Contents --------------- .. py:data:: PAPERS_DIR_ENV :type: Final :value: 'PAPERS_DIR' .. py:data:: CHROMA_DIR_ENV :type: Final :value: 'CHROMA_DIR' .. py:data:: CHROMA_COLLECTION_ENV :type: Final :value: 'CHROMA_COLLECTION' .. py:data:: EMBED_MODEL_ENV :type: Final :value: 'EMBED_MODEL' .. py:data:: OPENAI_API_KEY_ENV :type: Final :value: 'OPENAI_API_KEY' .. py:data:: OPENAI_MODEL_ENV :type: Final :value: 'OPENAI_MODEL' .. py:data:: CHUNK_SIZE_ENV :type: Final :value: 'CHUNK_SIZE' .. py:data:: CHUNK_OVERLAP_ENV :type: Final :value: 'CHUNK_OVERLAP' .. py:data:: SIMILARITY_TOP_K_ENV :type: Final :value: 'SIMILARITY_TOP_K' .. py:data:: DEFAULT_COLLECTION_NAME :type: Final :value: 'papers' .. py:data:: DEFAULT_EMBED_MODEL :type: Final :value: 'BAAI/bge-small-en-v1.5' .. py:data:: DEFAULT_LLM_MODEL :type: Final :value: 'gpt-4o-mini' .. py:data:: DEFAULT_CHUNK_SIZE :type: Final :value: 1024 .. py:data:: DEFAULT_CHUNK_OVERLAP :type: Final :value: 128 .. py:data:: DEFAULT_SIMILARITY_TOP_K :type: Final :value: 5 .. py:function:: find_repo_root(*, start: pathlib.Path | None = None) -> pathlib.Path Walk parents until the monorepo root (contains ``libs/rag-core``) is found. :param start: Directory to start from. Defaults to this file's location. :type start: Path or None :returns: Absolute path to the monorepo root. :rtype: Path :raises FileNotFoundError: If no ancestor contains ``libs/rag-core``. .. py:function:: load_repo_dotenv() -> None Load ``.env`` from cwd and the monorepo root. Existing process environment wins (``override=False``). Streamlit sets cwd to the script directory, so a repo-root ``.env`` is missed by a bare ``load_dotenv()``. .. py:class:: RagConfig Runtime settings for ingest + query. :ivar papers_dir: Directory of PDF papers to ingest. :vartype papers_dir: Path :ivar chroma_dir: Persistent Chroma directory (created if missing). :vartype chroma_dir: Path :ivar collection_name: Chroma collection name. :vartype collection_name: str :ivar embed_model_name: HuggingFace embedding model id (local). :vartype embed_model_name: str :ivar llm_model_name: OpenAI chat model id. :vartype llm_model_name: str :ivar chunk_size: SentenceSplitter chunk size. :vartype chunk_size: int :ivar chunk_overlap: SentenceSplitter overlap. :vartype chunk_overlap: int :ivar similarity_top_k: Retrieval top-k for the query engine. :vartype similarity_top_k: int :ivar strategy: In-process orchestration backend (LlamaIndex or LangChain). :vartype strategy: RagStrategy .. py:attribute:: papers_dir :type: pathlib.Path .. py:attribute:: chroma_dir :type: pathlib.Path .. py:attribute:: collection_name :type: str :value: 'papers' .. py:attribute:: embed_model_name :type: str :value: 'BAAI/bge-small-en-v1.5' .. py:attribute:: llm_model_name :type: str :value: 'gpt-4o-mini' .. py:attribute:: chunk_size :type: int :value: 1024 .. py:attribute:: chunk_overlap :type: int :value: 128 .. py:attribute:: similarity_top_k :type: int :value: 5 .. py:attribute:: strategy :type: rag.core.strategy.RagStrategy .. py:method:: from_env(*, repo_root: pathlib.Path | None = None, strategy: rag.core.strategy.RagStrategy | None = None) -> RagConfig :classmethod: Build config from environment variables with repo-relative defaults. :param repo_root: Monorepo root. Discovered automatically when omitted. :type repo_root: Path or None :param strategy: Orchestration backend. Defaults to ``RAG_STRATEGY`` or LlamaIndex. :type strategy: RagStrategy or None :returns: Resolved configuration. :rtype: RagConfig .. py:method:: ensure_dirs() -> None Create the Chroma persistence directory if needed.