Source code for autorag.config

"""Process-wide settings loaded from environment variables and ``.env``.

Every field is prefixed with ``AUTORAG_`` in the environment — e.g.
``AUTORAG_TOP_K=8`` overrides :attr:`Settings.top_k`. Unrecognized
variables are ignored so callers can share an environment with other
tools.
"""

from __future__ import annotations

from pathlib import Path

from pydantic_settings import BaseSettings, SettingsConfigDict


[docs] class Settings(BaseSettings): """Default knobs for the RAG pipeline.""" model_config = SettingsConfigDict(env_prefix="AUTORAG_", env_file=".env", extra="ignore") chunk_size: int = 1000 """Target character count for each chunk.""" chunk_overlap: int = 200 """Character overlap between adjacent chunks.""" top_k: int = 5 """Default number of chunks to retrieve per query.""" model: str = "claude-sonnet-4-6" """Default LLM model name for generation.""" db_path: Path = Path("~/.autorag/autorag.db") """Location of the SQLite clip database.""" broker_url: str = "amqp://localhost:5672" """RabbitMQ URL for the async pipeline (``autorag.services``). Only consulted by the ``[broker]`` async path (workers + ``/jobs/*`` endpoints); every synchronous endpoint and CLI command ignores it. """ otel_enabled: bool = False """Master switch for OpenTelemetry traces + metrics. When ``False`` (the default), :func:`autorag.otel.initialize_otel` is a no-op and no ``opentelemetry.*`` modules are imported.""" otel_service_name: str = "autorag" """Base ``service.name`` resource attribute. Each long-running process (``autorag-api`` / ``autorag-gpu-worker`` / ``autorag-io-worker`` / ``autorag-cli``) overrides it via the explicit ``initialize_otel`` argument, so this only matters if a caller drops that argument.""" otel_exporter_endpoint: str = "http://localhost:4317" """OTLP/gRPC endpoint for the span + metric exporters. Defaults to the host-side collector port; the compose workers override it to ``http://otel-collector:4317`` over ``autorag-net``.""" otel_metric_export_interval_ms: int = 15000 """Periodic-metric-reader export interval. Matches the Prometheus 15-second scrape, so a metric is at most one interval stale.""" otel_environment: str = "dev" """Value of the ``deployment.environment`` resource attribute.""" otel_resource_attributes: str = "" """Additional resource attributes as ``key=val,key2=val2``. Parsed at initialisation time and merged onto the built-in resource. Empty by default — callers usually rely on the explicit fields above."""
[docs] def get_settings() -> Settings: """Build a :class:`Settings` instance from the current environment.""" return Settings()