nhabibi's picture
Streamlit Space
4a14841
Raw History Blame Contribute Delete
737 Bytes
"""Tunable settings from config.toml at the repository root.
from rag_chatbot.shared.settings import settings
settings.rag.context_models
"""
import os
import tomllib
from types import SimpleNamespace
from rag_chatbot.shared.paths import PROJECT_ROOT
CONFIG_PATH = PROJECT_ROOT / "config.toml"
def _namespace(value):
if isinstance(value, dict):
return SimpleNamespace(**{key: _namespace(item) for key, item in value.items()})
return value
with CONFIG_PATH.open("rb") as file:
settings = _namespace(tomllib.load(file))
def secret(name: str) -> str:
"""A secret from the environment, else from config.toml [secrets]."""
return os.environ.get(name) or getattr(settings.secrets, name, "") or ""