| | |
| | | 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) |
| | | # 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: |
| | |
| | | |
| | | |
| | | # 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 |
| | |
| | | DOCUMENT_TO_REPORT = "document_to_report" |
| | | IMAGE_TO_TEXT = "image_and_text_conversion" |
| | | DOCUMENT_IA_QUESTIONS = "document_ia_questions" |
| | | |
| | | ENV_CONF_PATH = "app/config/env_conf" |
| | | |
| | | ### -----------app register -------------- |
| | | RAGFLOW = "ragflow_app" |
File was renamed from app/config/config.yaml |
| | |
| | | dify_workflow_clean: app-OpF0drPu0XcgqcekQpT4FA8a |
| | | dify_workflow_report: app-0MAkdFWqh9zxwmU69O0BFU1s |
| | | dify_database_url: postgresql+psycopg2://postgres:difyai123456@192.168.20.116:15432/dify |
| | | |
| | | |
| | |
| | | |
| | | from app.config.config import settings |
| | | |
| | | DATABASE_URL = os.getenv('DATABASE_URL') or settings.database_url |
| | | |
| | | DATABASE_URL = settings.database_url |
| | | engine = create_engine(DATABASE_URL, pool_size=20, max_overflow=50) |
| | | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) |
| | | |
| | |
| | | import time |
| | | import os |
| | | from Log import logger |
| | | from app.config.const import DIFY |
| | | from app.config.const import DIFY, ENV_CONF_PATH |
| | | from app.models import MenuCapacityModel, WebMenuModel, GroupModel, RoleModel, DialogModel, UserModel, UserAppModel, \ |
| | | cipher_suite |
| | | from app.service.auth import UserAppDao |
| | |
| | | |
| | | async def dialog_menu_sync(db): |
| | | menu_list = [] |
| | | with open("env_conf/menu_conf.json", 'r', encoding='utf-8') as file: |
| | | with open(os.path.join(ENV_CONF_PATH, "menu_conf.json") , 'r', encoding='utf-8') as file: |
| | | # 加载JSON数据 |
| | | data = json.load(file) |
| | | menu_list = data.get("data", []) |
| | |
| | | |
| | | |
| | | async def create_menu_sync(db): |
| | | json_file_path = "env_conf/menu_conf.json.template" |
| | | # json_file_path = "env_conf/menu_conf.json.template" |
| | | json_file_path = os.path.join(ENV_CONF_PATH, "menu_conf.json.template") |
| | | with open(json_file_path, 'r', encoding='utf-8') as file: |
| | | json_data = json.load(file).get("data", []) |
| | | # for menu in json_data: |
| | |
| | | |
| | | async def app_register_sync(db): |
| | | app_dict = {} |
| | | with open("env_conf/app_register_conf.json", 'r', encoding='utf-8') as file: |
| | | with open(os.path.join(ENV_CONF_PATH, "app_register_conf.json"), 'r', encoding='utf-8') as file: |
| | | # 加载JSON数据 |
| | | app_dict = json.load(file) |
| | | try: |
| | |
| | | |
| | | async def basic_agent_sync(db): |
| | | agent_list = [] |
| | | with open("env_conf/default_agent_conf.json", 'r', encoding='utf-8') as file: |
| | | with open(os.path.join(ENV_CONF_PATH, "default_agent_conf.json"), 'r', encoding='utf-8') as file: |
| | | # 加载JSON数据 |
| | | agent_dict = json.load(file) |
| | | agent_list = agent_dict.get("basic", []) |
| | |
| | | from app.api.user import user_router |
| | | from app.api.group import group_router |
| | | from app.api.role import role_router |
| | | from app.models.base_model import init_db |
| | | # from app.models.base_model import init_db |
| | | from app.task.fetch_agent import sync_agents, initialize_agents, sync_agents_v2, sync_knowledge |
| | | from app.init_config.init_run_data import sync_default_data |
| | | |
| | | |
| | | init_db() |
| | | # 使用 Lifespan 事件处理程序 |
| | | @asynccontextmanager |
| | | async def lifespan(app: FastAPI): |
| | | # 初始化代理 |
| | | initialize_agents() |
| | | # 在应用启动时同步代理 |
| | | sync_agents() |
| | | # initialize_agents() |
| | | # # 在应用启动时同步代理 |
| | | # sync_agents() |
| | | await sync_default_data() |
| | | |
| | | sync_agents_v2() |
| | |
| | | # 在应用关闭时执行清理操作(如果需要) |
| | | pass |
| | | |
| | | # init_db() |
| | | |
| | | app = FastAPI( |
| | | title="basic_rag_gateway", |
| | | version="0.1", |