| | |
| | | from typing import Dict, List, Tuple |
| | | |
| | | from sqlalchemy import create_engine, Column, String, Integer |
| | | from sqlalchemy.dialects.postgresql import array |
| | | from sqlalchemy.exc import IntegrityError |
| | | from sqlalchemy.orm import sessionmaker |
| | | |
| | | from app.config.config import settings |
| | | from app.models.agent_model import AgentModel |
| | | from app.models.base_model import SessionLocal, Base |
| | | from app.service.v2.initialize_data import dialog_menu_sync, default_group_sync, default_role_sync |
| | | |
| | | # 创建数据库引擎和会话工厂 |
| | | engine_bisheng = create_engine(settings.sgb_db_url) |
| | |
| | | try: |
| | | count = db.query(AgentModel).count() |
| | | if count > 0: |
| | | return |
| | | result = db.query(AgentModel).delete() |
| | | db.commit() # 提交事务 |
| | | initial_agents = [ |
| | | ('80ee430a-e396-48c4-a12c-7c7cdf5eda51', 1, '报告生成', 'BISHENG', 'report'), |
| | | ('basic_excel_merge', 2, '报表合并', 'BASIC', 'excelMerge'), |
| | |
| | | ('da3451da89d911efb9490242ac190006', 3, '知识问答', 'RAGFLOW', 'knowledgeQA'), |
| | | ('e96eb7a589db11ef87d20242ac190006', 5, '智能问答', 'RAGFLOW', 'chat'), |
| | | ('basic_excel_talk', 6, '智能数据', 'BASIC', 'excelTalk'), |
| | | ('basic_question_talk', 7, '文档出卷', 'BASIC', 'questionTalk'), |
| | | ('9d75142a-66eb-4e23-b7d4-03efe4584915', 8, '小数绘图', 'DIFY', 'imageTalk') |
| | | ('basic_question_talk', 7, '出题组卷', 'BASIC', 'questionTalk'), |
| | | ('9d75142a-66eb-4e23-b7d4-03efe4584915', 8, '小数绘图', 'DIFY', 'imageTalk'), |
| | | ('basic_paper_talk', 8, '文档出卷', 'BASIC', 'paperTalk'), |
| | | ('basic_report_clean', 10, '文档报告', 'DIFY', 'reportWorkflow') |
| | | ] |
| | | |
| | | for agent in initial_agents: |
| | |
| | | print("Agents synchronized successfully") |
| | | except Exception as e: |
| | | print(f"Failed to sync agents: {str(e)}") |
| | | |
| | | |
| | | async def sync_web_menu(): |
| | | db = SessionLocal() |
| | | await dialog_menu_sync(db) |
| | | |
| | | |
| | | async def sync_default_data(): |
| | | db = SessionLocal() |
| | | await default_group_sync(db) |
| | | await default_role_sync(db) |
| | | |