import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); async function main() { console.log('开始初始化关键词词云数据...'); // 1. 创建视觉样式规则 const rules = [ { name: '热门大词-金色', minScore: 90, maxScore: 100, color: 'primary', size: 'text-5xl', border: 'border-4', rotation: 'rotate-1', priority: 0, enabled: true, }, { name: '中等词汇-蓝色', minScore: 70, maxScore: 89, color: 'secondary', size: 'text-3xl', border: 'border-4', rotation: 'rotate-2', priority: 1, enabled: true, }, { name: '小词汇-紫色', minScore: 50, maxScore: 69, color: 'accent', size: 'text-xl', border: 'border-2', rotation: '-rotate-1', priority: 2, enabled: true, }, { name: '长尾词-灰色', minScore: 0, maxScore: 49, color: 'gray', size: 'text-base', border: 'border-2', rotation: null, priority: 3, enabled: true, }, ]; for (const rule of rules) { await prisma.visualStyleRule.upsert({ where: { name: rule.name }, update: rule, create: rule, }); console.log(`✓ 创建规则: ${rule.name}`); } // 2. 创建示例季度(2023-Q1) const quarter = await prisma.quarter.upsert({ where: { quarter: '2023-Q1' }, update: {}, create: { quarter: '2023-Q1', title: '2023年第一季度', titleEn: 'Q1 2023', subtitle: '聊天界面的黎明', subtitleEn: 'The dawn of chat interface', displayOrder: 0, isActive: true, }, }); console.log(`✓ 创建季度: ${quarter.quarter}`); // 3. 创建示例关键词 const sampleKeywords = [ { word: 'ChatGPT', trendScore: 98, description: 'OpenAI 开发的对话式人工智能助手,支持多轮对话', detailPoints: ['基于 GPT-3.5 架构', '2023年用户突破1亿', '引领对话式AI热潮'], visualConfig: { color: 'secondary', size: 'text-5xl', border: 'border-4', rotation: 'rotate-1', }, }, { word: 'GPT-4', trendScore: 92, description: 'OpenAI 发布的多模态大型语言模型', detailPoints: ['支持图像输入', '推理能力显著提升', '上下文窗口扩大'], visualConfig: { color: 'primary', size: 'text-4xl', border: 'border-4', rotation: 'rotate-2', }, }, { word: 'LLM', trendScore: 88, description: 'Large Language Model,大型语言模型', detailPoints: ['基于Transformer架构', '参数规模达十亿级', '涌现能力'], visualConfig: { color: 'secondary', size: 'text-3xl', border: 'border-4', rotation: '-rotate-1', }, }, { word: 'Prompt Engineering', trendScore: 85, description: '提示词工程,优化AI模型输入的技术', detailPoints: ['Few-shot prompting', '思维链提示', '迭代优化'], visualConfig: { color: 'accent', size: 'text-3xl', border: 'border-2', rotation: 'rotate-1', }, }, { word: 'Transformer', trendScore: 75, description: '基于自注意力机制的神经网络架构', detailPoints: ['并行计算能力强', '成为LLM基础架构', '2017年Google提出'], visualConfig: { color: 'secondary', size: 'text-2xl', border: 'border-2', rotation: null, }, }, ]; // 先删除已存在的关键词 await prisma.keyword.deleteMany({ where: { quarterId: quarter.id }, }); for (const kw of sampleKeywords) { await prisma.keyword.create({ data: { quarterId: quarter.id, ...kw, detailPoints: kw.detailPoints as any, visualConfig: kw.visualConfig as any, }, }); console.log(`✓ 创建关键词: ${kw.word}`); } console.log('\n初始化完成!'); } main() .catch((e) => { console.error('错误:', e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });