Create tables and seed initial data.
()
| 27 | |
| 28 | |
| 29 | async def seed(): |
| 30 | """Create tables and seed initial data.""" |
| 31 | settings = get_settings() |
| 32 | |
| 33 | # Create all tables |
| 34 | async with engine.begin() as conn: |
| 35 | await conn.run_sync(Base.metadata.create_all) |
| 36 | print("✅ Database tables created") |
| 37 | |
| 38 | async with async_session() as db: |
| 39 | # Note: No default admin user is seeded. |
| 40 | # The first user to register via the UI becomes platform_admin automatically. |
| 41 | from sqlalchemy import select, func |
| 42 | |
| 43 | # 1. Default company (tenant) |
| 44 | existing_tenant = await db.execute(select(Tenant).where(Tenant.slug == "default")) |
| 45 | if not existing_tenant.scalar_one_or_none(): |
| 46 | db.add(Tenant(name="Default", slug="default", im_provider="web_only")) |
| 47 | print("✅ Default company created") |
| 48 | |
| 49 | # 2. Built-in templates |
| 50 | templates = [ |
| 51 | { |
| 52 | "name": "研究助手", |
| 53 | "description": "专注于信息搜集、竞品分析、行业研究的数字员工", |
| 54 | "icon": "🔬", |
| 55 | "category": "research", |
| 56 | "soul_template": "## Identity\n你是一名专业的研究助手,擅长信息搜集和分析。\n\n## Personality\n- 严谨细致\n- 数据驱动\n- 客观中立\n\n## Boundaries\n- 引用来源须标注\n- 不做主观判断", |
| 57 | "is_builtin": True, |
| 58 | }, |
| 59 | { |
| 60 | "name": "项目管理助手", |
| 61 | "description": "负责项目进度跟踪、任务分配、督办提醒的数字员工", |
| 62 | "icon": "📋", |
| 63 | "category": "management", |
| 64 | "soul_template": "## Identity\n你是一名高效的项目管理助手。\n\n## Personality\n- 条理清晰\n- 主动跟进\n- 注重截止日期\n\n## Boundaries\n- 不擅自修改项目计划\n- 重大决策需确认", |
| 65 | "is_builtin": True, |
| 66 | }, |
| 67 | { |
| 68 | "name": "客户服务助手", |
| 69 | "description": "处理客户咨询、FAQ 回答、工单管理的数字员工", |
| 70 | "icon": "💬", |
| 71 | "category": "support", |
| 72 | "soul_template": "## Identity\n你是一名热情专业的客户服务助手。\n\n## Personality\n- 友好热情\n- 耐心细致\n- 解决导向\n\n## Boundaries\n- 不承诺超出权限的内容\n- 敏感问题转人工", |
| 73 | "is_builtin": True, |
| 74 | }, |
| 75 | { |
| 76 | "name": "数据分析师", |
| 77 | "description": "数据查询、报表生成、趋势分析的数字员工", |
| 78 | "icon": "📊", |
| 79 | "category": "analytics", |
| 80 | "soul_template": "## Identity\n你是一名数据分析专家。\n\n## Personality\n- 精确严谨\n- 善于可视化\n- 洞察力强\n\n## Boundaries\n- 数据安全第一\n- 不泄露原始数据", |
| 81 | "is_builtin": True, |
| 82 | }, |
| 83 | { |
| 84 | "name": "内容创作助手", |
| 85 | "description": "文案撰写、内容审核、社交媒体管理的数字员工", |
| 86 | "icon": "✍️", |
no test coverage detected