feat: introduce pydantic-settings for config definition and validation (#5202)

Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
Bowen Liang
2024-06-19 13:41:12 +08:00
committed by GitHub
parent d160d1ed02
commit 3cc6093e4b
21 changed files with 772 additions and 227 deletions

View File

@@ -1,5 +1,7 @@
import os
from configs.app_configs import DifyConfigs
if not os.environ.get("DEBUG") or os.environ.get("DEBUG").lower() != 'true':
from gevent import monkey
@@ -74,10 +76,19 @@ config_type = os.getenv('EDITION', default='SELF_HOSTED') # ce edition first
# Application Factory Function
# ----------------------------
def create_flask_app_with_configs() -> Flask:
"""
create a raw flask app
with configs loaded from .env file
"""
dify_app = DifyApp(__name__)
dify_app.config.from_object(Config())
dify_app.config.from_mapping(DifyConfigs().model_dump())
return dify_app
def create_app() -> Flask:
app = DifyApp(__name__)
app.config.from_object(Config())
app = create_flask_app_with_configs()
app.secret_key = app.config['SECRET_KEY']