diff --git a/rag/settings.py b/rag/settings.py index d1c32e6bf..7fa497c16 100644 --- a/rag/settings.py +++ b/rag/settings.py @@ -21,12 +21,32 @@ from api.utils.file_utils import get_project_base_directory # Server RAG_CONF_PATH = os.path.join(get_project_base_directory(), "conf") -ES = get_base_config("es", {}) -INFINITY = get_base_config("infinity", {"uri": "infinity:23817"}) -AZURE = get_base_config("azure", {}) -S3 = get_base_config("s3", {}) -MINIO = decrypt_database_config(name="minio") -OSS = get_base_config("oss", {}) +# Get storage type and document engine from system environment variables +STORAGE_IMPL_TYPE = os.getenv('STORAGE_IMPL', 'MINIO') +DOC_ENGINE = os.getenv('DOC_ENGINE', 'elasticsearch') + +ES = {} +INFINITY = {} +AZURE = {} +S3 = {} +MINIO = {} +OSS = {} + +# Initialize the selected configuration data based on environment variables to solve the problem of initialization errors due to lack of configuration +if DOC_ENGINE == 'elasticsearch': + ES = get_base_config("es", {}) +elif DOC_ENGINE == 'infinity': + INFINITY = get_base_config("infinity", {"uri": "infinity:23817"}) + +if STORAGE_IMPL_TYPE in ['AZURE_SPN', 'AZURE_SAS']: + AZURE = get_base_config("azure", {}) +elif STORAGE_IMPL_TYPE == 'AWS_S3': + S3 = get_base_config("s3", {}) +elif STORAGE_IMPL_TYPE == 'MINIO': + MINIO = decrypt_database_config(name="minio") +elif STORAGE_IMPL_TYPE == 'OSS': + OSS = get_base_config("oss", {}) + try: REDIS = decrypt_database_config(name="redis") except Exception: