Files
ai-portal/prisma/seed.ts
T

315 lines
12 KiB
TypeScript
Raw Normal View History

2026-05-06 17:22:50 +08:00
import { PrismaClient } from "@prisma/client"
import bcrypt from "bcryptjs"
const prisma = new PrismaClient()
async function main() {
// 创建管理员用户
const hashedPassword = await bcrypt.hash("admin123", 10)
const admin = await prisma.user.upsert({
where: { username: "admin" },
update: {},
create: {
email: "admin@nextapp.com",
username: "admin",
password: hashedPassword,
name: "管理员",
role: "admin",
},
})
console.log("Created admin user:", admin.username)
// 创建分类
const categories = await Promise.all([
prisma.category.upsert({
where: { name: "客服" },
update: {},
create: {
name: "客服",
icon: "🤖",
description: "适用于企业客服、在线问答、售后支持等场景,7×24小时在线服务。",
},
}),
prisma.category.upsert({
where: { name: "写作" },
update: {},
create: {
name: "写作",
icon: "✍️",
description: "适用于营销文案、博客文章、邮件草稿等场景,快速生成高质量内容。",
},
}),
prisma.category.upsert({
where: { name: "数据分析" },
update: {},
create: {
name: "数据分析",
icon: "📊",
description: "适用于数据清洗、分析、可视化等场景,自动生成结构化分析报告。",
},
}),
prisma.category.upsert({
where: { name: "编程" },
update: {},
create: {
name: "编程",
icon: "💻",
description: "适用于代码审查、SQL生成等场景,提高开发效率,减少bug。",
},
}),
prisma.category.upsert({
where: { name: "生活娱乐" },
update: {},
create: {
name: "生活娱乐",
icon: "✈️",
description: "适用于旅行规划、菜谱推荐等场景,让生活更加便捷智能。",
},
}),
prisma.category.upsert({
where: { name: "数字人" },
update: {},
create: {
name: "数字人",
icon: "🧑‍💼",
description: "适用于虚拟主播、数字客服、形象代言等场景,提供逼真的数字人交互体验。",
},
}),
prisma.category.upsert({
where: { name: "企业服务" },
update: {},
create: {
name: "企业服务",
icon: "🏢",
description: "适用于企业专属AI助手、行业解决方案等场景,提供定制化智能服务。",
},
}),
2026-05-06 17:22:50 +08:00
])
console.log("Created categories:", categories.map(c => c.name).join(", "))
// 创建智能体
const agents = await Promise.all([
prisma.agent.upsert({
where: { slug: "smart-customer-service" },
update: {},
create: {
name: "智能客服助手",
slug: "smart-customer-service",
description: "7×24 小时在线,精准理解用户意图,自动处理常见咨询,支持多轮对话。",
icon: "🤖",
categoryId: categories[0].id,
features: "智能问答, 知识库查询, 工单提交",
hotQuestions: JSON.stringify([
"养老政策有哪些最新变化?",
"如何申请养老服务补贴?",
"老年人健康管理需要注意什么?",
"养老机构如何选择?",
]),
quickQuestions: JSON.stringify([
"养老政策咨询",
"养老机构推荐",
"养老服务申请",
]),
2026-05-06 17:22:50 +08:00
usageCount: 1000,
status: "active",
isFeatured: true,
featuredOrder: 1,
difyApiUrl: "http://host.docker.internal/v1",
difyApiKey: "app-lbe2lglt7taGtZk0dG7pAhbx",
2026-05-06 17:22:50 +08:00
},
}),
prisma.agent.upsert({
where: { slug: "huaiqi-secretary" },
2026-05-06 17:22:50 +08:00
update: {},
create: {
name: "淮企小秘书",
slug: "huaiqi-secretary",
description: "专为淮安企业打造的智能秘书,提供政策解读、企业办事指南、惠企政策查询等一站式服务,助力企业高效运营。",
icon: "🏢",
categoryId: categories[6].id,
features: "政策解读, 企业办事指南, 惠企政策, 智能问答",
hotQuestions: JSON.stringify([
"到淮安这边投资,项目审批快吗?",
"目前淮安对绿色工厂有哪些支持政策?",
"请问企业实施技术改造项目,淮安市有哪些支持政策?",
"淮安有哪些产业配套服务?",
]),
quickQuestions: JSON.stringify([
"惠企政策查询",
"企业办事指南",
"政策解读",
]),
2026-05-06 17:22:50 +08:00
usageCount: 850,
status: "active",
isFeatured: true,
featuredOrder: 2,
2026-05-06 17:22:50 +08:00
},
}),
prisma.agent.upsert({
where: { slug: "data-analysis-master" },
update: {},
create: {
name: "数据分析大师",
slug: "data-analysis-master",
description: "上传 CSV/Excel,自动清洗、分析、可视化,输出结构化分析报告。",
icon: "📊",
categoryId: categories[2].id,
features: "数据清洗, 数据可视化, 分析报告",
usageCount: 620,
status: "active",
isFeatured: true,
featuredOrder: 3,
2026-05-06 17:22:50 +08:00
},
}),
prisma.agent.upsert({
where: { slug: "digital-human-assistant" },
update: {},
create: {
name: "数字人助手",
slug: "digital-human-assistant",
description: "超写实数字人,支持语音交互、表情动画、多场景应用,适用于虚拟主播、智能客服、形象代言等场景。",
icon: "🧑‍💼",
categoryId: categories[5].id,
features: "语音交互, 表情动画, 虚拟主播, 智能客服",
usageCount: 380,
status: "active",
},
}),
prisma.agent.upsert({
where: { slug: "jiaotou-ai-assistant" },
update: {},
create: {
name: "交投集团AI助手",
slug: "jiaotou-ai-assistant",
description: "专为交投集团打造的智能助手,提供交通投资政策解读、项目分析、数据分析等专业化服务,助力企业决策。",
icon: "🚇",
categoryId: categories[6].id,
features: "政策解读, 项目分析, 数据分析, 决策支持",
usageCount: 120,
status: "active",
},
}),
prisma.agent.upsert({
where: { slug: "promotion-content-ai" },
update: {},
create: {
name: "宣传文稿AI助手",
slug: "promotion-content-ai",
description: "智能生成各类宣传文稿,包括新闻稿、活动文案、品牌宣传、海报文案等,快速产出高质量宣传内容。",
icon: "📝",
categoryId: categories[1].id,
features: "新闻稿, 活动文案, 品牌宣传, 海报文案",
usageCount: 95,
status: "active",
},
}),
prisma.agent.upsert({
where: { slug: "group-policy-ai-assistant" },
update: {},
create: {
name: "集团制度AI助手",
slug: "group-policy-ai-assistant",
description: "专注于集团规章制度解读与咨询,快速查询、解读各类制度文件,助力合规管理与制度落地。",
icon: "📋",
categoryId: categories[6].id,
features: "制度解读, 合规咨询, 文件查询, 制度培训",
usageCount: 50,
status: "active",
},
}),
prisma.agent.upsert({
where: { slug: "talent-service" },
update: {},
create: {
name: "人才服务智能体",
slug: "talent-service",
description: "提供人才政策查询、招聘信息匹配、职业规划咨询、人才补贴申请等一站式人才服务。",
icon: "👥",
categoryId: categories[6].id,
features: "人才政策查询, 招聘信息匹配, 职业规划, 人才补贴申请",
hotQuestions: JSON.stringify([
"淮安市有哪些人才引进政策?",
"如何申请人才补贴?",
"高层次人才认定标准是什么?",
"人才公寓如何申请?",
]),
quickQuestions: JSON.stringify([
"人才政策查询",
"人才补贴申请",
"招聘信息",
]),
usageCount: 200,
status: "active",
isFeatured: true,
featuredOrder: 4,
},
}),
2026-05-06 17:22:50 +08:00
])
console.log("Created agents:", agents.map(a => a.name).join(", "))
// 创建新闻
const news = await Promise.all([
prisma.news.create({
data: {
title: "腾讯云升级全栈企业级 Agent 能力,发布 ClawPro 等多款产品",
content: "在 2026 腾讯云城市峰会上,腾讯云全面升级企业级 Agent 产品矩阵,首发 ClawPro 专有云版、ADP 智能工作台、Agent Memory、Agent Storage 等多款产品。企业可用自然语言搭建工作流,打通内部 Agent 孤岛,实现统一调度与安全管控。",
2026-05-06 17:22:50 +08:00
type: "news",
published: true,
},
}),
prisma.news.create({
data: {
title: "阿里发布企业级 Agent 平台「悟空」,面向办公协同场景",
content: "阿里巴巴发布企业级 AI 工作平台「悟空」,已启动邀测并内置于钉钉。悟空可接入企业账号体系与权限系统,支持在组织内部调用多种 AI 能力与业务系统,同步上线 AI 能力市场,首批覆盖电商、跨境电商、知识内容等十大行业场景。",
type: "news",
published: true,
},
}),
prisma.news.create({
data: {
title: "科大讯飞发布玲珑 Agent OS,企业级 AI 迈进操作系统时代",
content: "科大讯飞在第九届数字中国建设峰会上正式发布玲珑 Agent OS,专为企业打造的 AI 原生工作台。内置超级智能体引擎,支持多智能体并行协作,跨系统自动完成任务。沉淀 300 多个开箱即用智能体,覆盖软件开发、贸易服务、数字创意等核心场景。",
type: "news",
published: true,
},
}),
prisma.news.create({
data: {
title: "高德发布汽车出行 AI Agent,车载导航进入主动服务时代",
content: "高德发布汽车出行 AI Agent,采用「语言大脑+空间大脑」双引擎设计,支持模糊语义搜索、复杂行程一句话串联、动态路线推理及多轮对话编辑。系统可根据充电桩状态与用餐偏好自动优化长途出行方案,标志着车载导航从被动执行走向主动服务。",
2026-05-06 17:22:50 +08:00
type: "industry",
published: true,
},
}),
prisma.news.create({
data: {
title: "Google Cloud 发布 Gemini Enterprise Agent Platform",
content: "Google Cloud 宣布推出 Gemini Enterprise Agent Platform,提供从构建到治理的全栈企业级 Agent 能力。包含 Agent Studio 低代码构建工具、支持多天任务的 Agent Runtime、Agent Registry 统一目录与 Agent Gateway 安全网关,助力企业规模化部署可信 AI 智能体。",
type: "industry",
published: true,
},
}),
prisma.news.create({
data: {
title: "OpenAI 推出 Frontier 企业 AI Agent 平台",
content: "OpenAI 发布 Frontier 企业平台,帮助企业构建、部署和管理 AI Agent。HP、Intuit、Oracle、Uber 等为首批客户。Frontier 支持 AI 同事拥有独立身份与权限,具备跨会话记忆与自主执行能力,已与多家头部 ISV 建立生态合作,推动企业 AI 从工具向协作者演进。",
2026-05-06 17:22:50 +08:00
type: "cooperation",
published: true,
},
}),
])
console.log("Created news:", news.map(n => n.title).join(", "))
console.log("Seed data created successfully!")
}
main()
.catch((e) => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})