rag.core.config¶

Configuration for the papers RAG pipeline.

Attributes¶

Classes¶

RagConfig

Runtime settings for ingest + query.

Functions¶

find_repo_root(→ pathlib.Path)

Walk parents until the monorepo root (contains libs/rag-core) is found.

load_repo_dotenv(→ None)

Load .env from cwd and the monorepo root.

Module Contents¶

rag.core.config.PAPERS_DIR_ENV: Final = 'PAPERS_DIR'[source]¶
rag.core.config.CHROMA_DIR_ENV: Final = 'CHROMA_DIR'[source]¶
rag.core.config.CHROMA_COLLECTION_ENV: Final = 'CHROMA_COLLECTION'[source]¶
rag.core.config.EMBED_MODEL_ENV: Final = 'EMBED_MODEL'[source]¶
rag.core.config.OPENAI_API_KEY_ENV: Final = 'OPENAI_API_KEY'[source]¶
rag.core.config.OPENAI_MODEL_ENV: Final = 'OPENAI_MODEL'[source]¶
rag.core.config.CHUNK_SIZE_ENV: Final = 'CHUNK_SIZE'[source]¶
rag.core.config.CHUNK_OVERLAP_ENV: Final = 'CHUNK_OVERLAP'[source]¶
rag.core.config.SIMILARITY_TOP_K_ENV: Final = 'SIMILARITY_TOP_K'[source]¶
rag.core.config.DEFAULT_COLLECTION_NAME: Final = 'papers'[source]¶
rag.core.config.DEFAULT_EMBED_MODEL: Final = 'BAAI/bge-small-en-v1.5'[source]¶
rag.core.config.DEFAULT_LLM_MODEL: Final = 'gpt-4o-mini'[source]¶
rag.core.config.DEFAULT_CHUNK_SIZE: Final = 1024[source]¶
rag.core.config.DEFAULT_CHUNK_OVERLAP: Final = 128[source]¶
rag.core.config.DEFAULT_SIMILARITY_TOP_K: Final = 5[source]¶
rag.core.config.find_repo_root(*, start: pathlib.Path | None = None) pathlib.Path[source]¶

Walk parents until the monorepo root (contains libs/rag-core) is found.

Parameters:

start (Path or None) – Directory to start from. Defaults to this file’s location.

Returns:

Absolute path to the monorepo root.

Return type:

Path

Raises:

FileNotFoundError – If no ancestor contains libs/rag-core.

rag.core.config.load_repo_dotenv() None[source]¶

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().

class rag.core.config.RagConfig[source]¶

Runtime settings for ingest + query.

Variables:
  • papers_dir (Path) – Directory of PDF papers to ingest.

  • chroma_dir (Path) – Persistent Chroma directory (created if missing).

  • collection_name (str) – Chroma collection name.

  • embed_model_name (str) – HuggingFace embedding model id (local).

  • llm_model_name (str) – OpenAI chat model id.

  • chunk_size (int) – SentenceSplitter chunk size.

  • chunk_overlap (int) – SentenceSplitter overlap.

  • similarity_top_k (int) – Retrieval top-k for the query engine.

  • strategy (RagStrategy) – In-process orchestration backend (LlamaIndex or LangChain).

papers_dir: pathlib.Path[source]¶
chroma_dir: pathlib.Path[source]¶
collection_name: str = 'papers'[source]¶
embed_model_name: str = 'BAAI/bge-small-en-v1.5'[source]¶
llm_model_name: str = 'gpt-4o-mini'[source]¶
chunk_size: int = 1024[source]¶
chunk_overlap: int = 128[source]¶
similarity_top_k: int = 5[source]¶
strategy: rag.core.strategy.RagStrategy[source]¶
classmethod from_env(*, repo_root: pathlib.Path | None = None, strategy: rag.core.strategy.RagStrategy | None = None) RagConfig[source]¶

Build config from environment variables with repo-relative defaults.

Parameters:
  • repo_root (Path or None) – Monorepo root. Discovered automatically when omitted.

  • strategy (RagStrategy or None) – Orchestration backend. Defaults to RAG_STRATEGY or LlamaIndex.

Returns:

Resolved configuration.

Return type:

RagConfig

ensure_dirs() None[source]¶

Create the Chroma persistence directory if needed.