xuyonghao
2025-01-22 9be4808a8d7038e9af6de826f573c66ca38194db
app/config/config.py
@@ -1,3 +1,4 @@
import os
from pathlib import Path
import yaml
@@ -22,7 +23,18 @@
    dify_workflow_clean: str = ''
    dify_workflow_report: str = ''
    postgresql_database_url: str = ''
    dify_database_url: str = ''
    def __init__(self, **kwargs):
        # 替换配置中的IP地址
        # host_ip = os.getenv('HOST_IP', '127.0.0.1')
        # kwargs['sgb_base_url'] = kwargs.get('sgb_base_url', '').replace('127.0.0.1', host_ip)
        # kwargs['sgb_websocket_url'] = kwargs.get('sgb_websocket_url', '').replace('127.0.0.1', host_ip)
        # kwargs['fwr_base_url'] = kwargs.get('fwr_base_url', '').replace('127.0.0.1', host_ip)
        # kwargs['sgb_db_url'] = kwargs.get('sgb_db_url', '').replace('127.0.0.1', host_ip)
        # kwargs['fwr_db_url'] = kwargs.get('fwr_db_url', '').replace('127.0.0.1', host_ip)
        # kwargs['dify_base_url'] = kwargs.get('dify_base_url', '').replace('127.0.0.1', host_ip)
        # kwargs['basic_base_url'] = kwargs.get('basic_base_url', '').replace('127.0.0.1', host_ip)
        # kwargs['dify_database_url'] = kwargs.get('dify_database_url', '').replace('127.0.0.1', host_ip)
        # Check if all required fields are provided and set them
        for field in self.__annotations__.keys():
            if field not in kwargs:
@@ -49,7 +61,9 @@
# Use pathlib to handle file paths
config_yaml_path = Path(__file__).parent / 'config.yaml'
# config_yaml_path = os.path.join(os.path.join(Path(__file__).parent, "env_conf"), "config.yaml")
config_yaml_path = Path(__file__).parent.joinpath("env_conf") / 'config.yaml'
print(config_yaml_path)
settings_data = load_yaml(config_yaml_path)
# Initialize settings object