refactor: 移除 AI 词云、AI 时间轴和博客模块
暂停开发以下功能,将设计文档移至未完成计划文件夹: - AI 词云 (Keyword Cloud): 前端、API、数据库模型、n8n 工作流 - AI 时间轴 (AI Timeline): 前端、API、数据库模型 - 博客 (Blog): 导航链接占位 变更内容: - 删除词云和时间轴的前端页面及组件 - 删除 /api/keyword-cloud/* 和 /api/events/* API 端点 - 从 prisma/schema.prisma 移除 Keyword, Quarter, VisualStyleRule, KeywordCloudErrorLog, AIEvent 模型 - 从 validations.ts 移除相关 Zod Schema - 从国际化消息中移除 keywordCloud/timeline 命名空间 - 从导航菜单移除词云、时间轴、博客链接 - 更新 CLAUDE.md 移除词云系统文档 设计文档已移至 .omc/plans/postponed-features/ 供后续恢复开发参考
This commit is contained in:
@@ -1,121 +0,0 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const historicalEvents = [
|
||||
{
|
||||
title: 'Attention Is All You Need',
|
||||
titleEn: 'Attention Is All You Need',
|
||||
eventDate: new Date('2017-06-12T00:00:00Z'),
|
||||
description: 'Google 团队发表 Transformer 论文,提出自注意力机制,彻底改变 NLP 领域',
|
||||
descriptionEn: 'Google team publishes Transformer paper, proposing self-attention mechanism that revolutionizes NLP',
|
||||
imageUrl: 'https://images.unsplash.com/photo-1677442136019-21780ecad995?w=800',
|
||||
sourceUrl: 'https://arxiv.org/abs/1706.03762',
|
||||
},
|
||||
{
|
||||
title: 'GPT-1 发布',
|
||||
titleEn: 'GPT-1 Release',
|
||||
eventDate: new Date('2018-06-11T00:00:00Z'),
|
||||
description: 'OpenAI 发布第一代生成式预训练 Transformer 模型,展示无监督学习的潜力',
|
||||
descriptionEn: 'OpenAI releases first Generative Pre-trained Transformer model, demonstrating potential of unsupervised learning',
|
||||
imageUrl: 'https://images.unsplash.com/photo-1677442136019-21780ecad995?w=800',
|
||||
sourceUrl: 'https://s3-us-west-2.amazonaws.com/openai-assets/research-covers/language-unsupervised/language-understanding-paper.pdf',
|
||||
},
|
||||
{
|
||||
title: 'BERT 发布',
|
||||
titleEn: 'BERT Release',
|
||||
eventDate: new Date('2018-10-11T00:00:00Z'),
|
||||
description: 'Google 发布双向编码器表示 Transformer,在 11 项 NLP 任务中创 SOTA',
|
||||
descriptionEn: 'Google releases Bidirectional Encoder Representations from Transformers, achieving SOTA on 11 NLP tasks',
|
||||
imageUrl: 'https://images.unsplash.com/photo-1677442136019-21780ecad995?w=800',
|
||||
sourceUrl: 'https://arxiv.org/abs/1810.04805',
|
||||
},
|
||||
{
|
||||
title: 'GPT-2 发布',
|
||||
titleEn: 'GPT-2 Release',
|
||||
eventDate: new Date('2019-02-14T00:00:00Z'),
|
||||
description: 'OpenAI 发布 15 亿参数的 GPT-2,因"太危险"而不敢全部发布',
|
||||
descriptionEn: 'OpenAI releases 1.5B parameter GPT-2, initially withholding full release due to concerns about misuse',
|
||||
imageUrl: 'https://images.unsplash.com/photo-1677442136019-21780ecad995?w=800',
|
||||
sourceUrl: 'https://openai.com/research/better-language-models',
|
||||
},
|
||||
{
|
||||
title: 'GPT-3 发布',
|
||||
titleEn: 'GPT-3 Release',
|
||||
eventDate: new Date('2020-05-28T00:00:00Z'),
|
||||
description: 'OpenAI 发布 1750 亿参数的 GPT-3,展示 few-shot 学习的强大能力',
|
||||
descriptionEn: 'OpenAI releases 175B parameter GPT-3, demonstrating powerful few-shot learning capabilities',
|
||||
imageUrl: 'https://images.unsplash.com/photo-1677442136019-21780ecad995?w=800',
|
||||
sourceUrl: 'https://arxiv.org/abs/2005.14165',
|
||||
},
|
||||
{
|
||||
title: 'GitHub Copilot 发布',
|
||||
titleEn: 'GitHub Copilot Release',
|
||||
eventDate: new Date('2021-06-29T00:00:00Z'),
|
||||
description: 'GitHub 和 OpenAI 发布 AI 编程助手,基于 Codex 模型',
|
||||
descriptionEn: 'GitHub and OpenAI launch AI programming assistant powered by Codex model',
|
||||
imageUrl: 'https://images.unsplash.com/photo-1677442136019-21780ecad995?w=800',
|
||||
sourceUrl: 'https://github.blog/news-insights/company-news/github-copilot/',
|
||||
},
|
||||
{
|
||||
title: 'ChatGPT 发布',
|
||||
titleEn: 'ChatGPT Release',
|
||||
eventDate: new Date('2022-11-30T00:00:00Z'),
|
||||
description: 'OpenAI 发布对话式 AI 助手 ChatGPT,5 天用户突破 100 万',
|
||||
descriptionEn: 'OpenAI launches conversational AI assistant ChatGPT, reaching 1 million users in 5 days',
|
||||
imageUrl: 'https://images.unsplash.com/photo-1677442136019-21780ecad995?w=800',
|
||||
sourceUrl: 'https://openai.com/blog/chatgpt',
|
||||
},
|
||||
{
|
||||
title: 'GPT-4 发布',
|
||||
titleEn: 'GPT-4 Release',
|
||||
eventDate: new Date('2023-03-14T00:00:00Z'),
|
||||
description: 'OpenAI 发布多模态大语言模型 GPT-4,在各项基准测试中接近人类水平',
|
||||
descriptionEn: 'OpenAI releases multimodal LLM GPT-4, approaching human-level performance on various benchmarks',
|
||||
imageUrl: 'https://images.unsplash.com/photo-1677442136019-21780ecad995?w=800',
|
||||
sourceUrl: 'https://openai.com/research/gpt-4',
|
||||
},
|
||||
{
|
||||
title: 'Claude 发布',
|
||||
titleEn: 'Claude Release',
|
||||
eventDate: new Date('2023-03-16T00:00:00Z'),
|
||||
description: 'Anthropic 发布 AI 助手 Claude,强调安全性和有用性',
|
||||
descriptionEn: 'Anthropic launches AI assistant Claude, emphasizing safety and helpfulness',
|
||||
imageUrl: 'https://images.unsplash.com/photo-1677442136019-21780ecad995?w=800',
|
||||
sourceUrl: 'https://www.anthropic.com/index/claude-now-open',
|
||||
},
|
||||
];
|
||||
|
||||
async function main() {
|
||||
console.log('开始插入历史事件...');
|
||||
|
||||
let successCount = 0;
|
||||
let skipCount = 0;
|
||||
|
||||
for (const event of historicalEvents) {
|
||||
try {
|
||||
await prisma.aIEvent.create({
|
||||
data: event,
|
||||
});
|
||||
console.log(`✓ ${event.title} (${event.eventDate.getFullYear()})`);
|
||||
successCount++;
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
if (errorMessage.includes('Unique constraint')) {
|
||||
console.log(`⊘ ${event.title} 已存在,跳过`);
|
||||
skipCount++;
|
||||
} else {
|
||||
console.log(`✗ ${event.title} 插入失败: ${errorMessage}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\n历史事件插入完成!');
|
||||
console.log(`成功: ${successCount} 条`);
|
||||
console.log(`跳过: ${skipCount} 条`);
|
||||
console.log(`总计: ${historicalEvents.length} 条`);
|
||||
}
|
||||
|
||||
main()
|
||||
.catch(console.error)
|
||||
.finally(() => prisma.$disconnect());
|
||||
@@ -1,172 +0,0 @@
|
||||
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();
|
||||
});
|
||||
@@ -1,145 +0,0 @@
|
||||
/**
|
||||
* 测试关键词词云 API 端点
|
||||
* 模拟 n8n 工作流发送的请求
|
||||
*
|
||||
* 运行前请确保已设置环境变量:
|
||||
* export API_URL=http://localhost:3000
|
||||
* export WEBHOOK_API_KEY=your_api_key
|
||||
*/
|
||||
|
||||
const API_URL = process.env.API_URL || 'http://localhost:3000';
|
||||
const API_KEY = process.env.WEBHOOK_API_KEY || '';
|
||||
|
||||
async function testAPI() {
|
||||
console.log('🧪 测试关键词词云 API...\n');
|
||||
|
||||
// 测试 1: 获取季度列表
|
||||
console.log('1️⃣ 测试 GET /api/keyword-cloud/quarters');
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/api/keyword-cloud/quarters`);
|
||||
const data = await response.json();
|
||||
console.log('✅ 成功:', data.success);
|
||||
console.log(` 季度数量: ${data.quarters?.length || 0}`);
|
||||
if (data.quarters?.length > 0) {
|
||||
console.log(` 第一个季度: ${data.quarters[0].quarter} (${data.quarters[0].keywordCount} 个关键词)`);
|
||||
}
|
||||
} catch (err) {
|
||||
const error = err as Error;
|
||||
console.log('❌ 失败:', error.message);
|
||||
}
|
||||
console.log();
|
||||
|
||||
// 测试 2: 获取关键词
|
||||
console.log('2️⃣ 测试 GET /api/keyword-cloud/keywords/2023-Q1');
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/api/keyword-cloud/keywords/2023-Q1`);
|
||||
const data = await response.json();
|
||||
console.log('✅ 成功:', data.success);
|
||||
console.log(` 关键词数量: ${data.keywords?.length || 0}`);
|
||||
if (data.keywords?.length > 0) {
|
||||
console.log(` 最热词汇: ${data.keywords[0].word} (${data.keywords[0].trendScore}分)`);
|
||||
}
|
||||
} catch (err) {
|
||||
const error = err as Error;
|
||||
console.log('❌ 失败:', error.message);
|
||||
}
|
||||
console.log();
|
||||
|
||||
// 测试 3: 获取视觉规则
|
||||
console.log('3️⃣ 测试 GET /api/keyword-cloud/rules');
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/api/keyword-cloud/rules`);
|
||||
const data = await response.json();
|
||||
console.log('✅ 成功:', data.success);
|
||||
console.log(` 规则数量: ${data.rules?.length || 0}`);
|
||||
if (data.rules?.length > 0) {
|
||||
console.log(` 规则示例: ${data.rules[0].name} (${data.rules[0].minScore}-${data.rules[0].maxScore}分)`);
|
||||
}
|
||||
} catch (err) {
|
||||
const error = err as Error;
|
||||
console.log('❌ 失败:', error.message);
|
||||
}
|
||||
console.log();
|
||||
|
||||
// 测试 4: 批量写入关键词(模拟 n8n 工作流)
|
||||
console.log('4️⃣ 测试 POST /api/keyword-cloud/keywords (模拟 n8n 请求)');
|
||||
|
||||
const testPayload = {
|
||||
apiKey: API_KEY,
|
||||
quarter: '2024-Q1',
|
||||
keywords: [
|
||||
{
|
||||
word: 'Claude',
|
||||
trendScore: 95,
|
||||
description: 'Anthropic 开发的 AI 助手',
|
||||
descriptionEn: 'AI assistant developed by Anthropic',
|
||||
detailPoints: ['支持长上下文', '安全对齐', '多模态能力'],
|
||||
detailPointsEn: ['Long context', 'Safety alignment', 'Multimodal'],
|
||||
visualConfig: {
|
||||
color: 'primary',
|
||||
size: 'text-5xl',
|
||||
border: 'border-4',
|
||||
rotation: 'rotate-1',
|
||||
},
|
||||
},
|
||||
{
|
||||
word: 'Gemini',
|
||||
trendScore: 88,
|
||||
description: 'Google 的多模态 AI 模型',
|
||||
descriptionEn: 'Multimodal AI model by Google',
|
||||
detailPoints: ['原生多模态', '长上下文窗口', '推理能力'],
|
||||
detailPointsEn: ['Native multimodal', 'Long context', 'Reasoning'],
|
||||
visualConfig: {
|
||||
color: 'secondary',
|
||||
size: 'text-4xl',
|
||||
border: 'border-4',
|
||||
rotation: 'rotate-2',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/api/keyword-cloud/keywords`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(testPayload),
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
console.log('✅ 成功: 创建了', data.created, '个关键词');
|
||||
if (data.failed > 0) {
|
||||
console.log('⚠️ 失败:', data.failed, '个');
|
||||
data.errors?.forEach((err: any) => console.log(' -', err.word, ':', err.error));
|
||||
}
|
||||
} else {
|
||||
console.log('❌ 失败:', data.error);
|
||||
}
|
||||
} catch (err) {
|
||||
const error = err as Error;
|
||||
console.log('❌ 失败:', error.message);
|
||||
}
|
||||
console.log();
|
||||
|
||||
// 验证新创建的数据
|
||||
console.log('5️⃣ 验证新创建的数据 (2024-Q1)');
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/api/keyword-cloud/keywords/2024-Q1`);
|
||||
const data = await response.json();
|
||||
console.log('✅ 成功:', data.success);
|
||||
console.log(` 关键词数量: ${data.keywords?.length || 0}`);
|
||||
if (data.keywords?.length > 0) {
|
||||
console.log(` 关键词: ${data.keywords.map((k: any) => k.word).join(', ')}`);
|
||||
}
|
||||
} catch (err) {
|
||||
const error = err as Error;
|
||||
console.log('❌ 失败:', error.message);
|
||||
}
|
||||
console.log();
|
||||
|
||||
console.log('✨ 测试完成!');
|
||||
}
|
||||
|
||||
testAPI().catch(console.error);
|
||||
Reference in New Issue
Block a user