Spaces:
Configuration error
Configuration error
Download src/rag_chatbot/shared/settings.py from nhabibi/HF-RAGChatbot-Streamlit: direct link, hf CLI and curl.
- Browser
- Download file 737 Bytes
-
https://huggingface.co/spaces/nhabibi/HF-RAGChatbot-Streamlit/resolve/main/src/rag_chatbot/shared/settings.py
- Command line
-
hf download hf://spaces/nhabibi/HF-RAGChatbot-Streamlit/src/rag_chatbot/shared/settings.py
-
curl -L -o settings.py https://huggingface.co/spaces/nhabibi/HF-RAGChatbot-Streamlit/resolve/main/src/rag_chatbot/shared/settings.py
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 "" | |