mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-10-23 11:53:08 -05:00
24 lines
700 B
Python
24 lines
700 B
Python
from typing import cast
|
|
|
|
from danswer.dynamic_configs.factory import get_dynamic_config_store
|
|
from danswer.dynamic_configs.interface import ConfigNotFoundError
|
|
from danswer.server.settings.models import Settings
|
|
|
|
|
|
_SETTINGS_KEY = "danswer_settings"
|
|
|
|
|
|
def load_settings() -> Settings:
|
|
dynamic_config_store = get_dynamic_config_store()
|
|
try:
|
|
settings = Settings(**cast(dict, dynamic_config_store.load(_SETTINGS_KEY)))
|
|
except ConfigNotFoundError:
|
|
settings = Settings()
|
|
dynamic_config_store.store(_SETTINGS_KEY, settings.dict())
|
|
|
|
return settings
|
|
|
|
|
|
def store_settings(settings: Settings) -> None:
|
|
get_dynamic_config_store().store(_SETTINGS_KEY, settings.dict())
|