feat: complete Day 21-24 knowledge base features
- Day 21-22: fix CORS and file upload issues - Day 23-24: implement @knowledge base search and conversation integration - Backend: integrate Dify RAG into conversation system - Frontend: load knowledge base list and @ reference feature
This commit is contained in:
64
backend/check-documents.js
Normal file
64
backend/check-documents.js
Normal file
@@ -0,0 +1,64 @@
|
||||
// 查询文档状态脚本
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function checkDocuments() {
|
||||
try {
|
||||
console.log('\n📋 查询最近上传的文档...\n');
|
||||
|
||||
const docs = await prisma.document.findMany({
|
||||
orderBy: { uploadedAt: 'desc' },
|
||||
take: 10,
|
||||
include: {
|
||||
knowledgeBase: {
|
||||
select: {
|
||||
name: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (docs.length === 0) {
|
||||
console.log('❌ 没有找到任何文档');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`找到 ${docs.length} 个文档:\n`);
|
||||
|
||||
docs.forEach((doc, index) => {
|
||||
const statusEmoji = {
|
||||
'uploading': '📤',
|
||||
'parsing': '🔄',
|
||||
'indexing': '⚙️',
|
||||
'completed': '✅',
|
||||
'error': '❌'
|
||||
}[doc.status] || '❓';
|
||||
|
||||
console.log(`${index + 1}. ${statusEmoji} ${doc.filename}`);
|
||||
console.log(` 知识库: ${doc.knowledgeBase.name}`);
|
||||
console.log(` 状态: ${doc.status}`);
|
||||
console.log(` 大小: ${(doc.fileSizeBytes / 1024).toFixed(2)} KB`);
|
||||
console.log(` 上传时间: ${doc.uploadedAt}`);
|
||||
|
||||
if (doc.status === 'completed') {
|
||||
console.log(` ✓ 段落数: ${doc.segmentsCount || 0}`);
|
||||
console.log(` ✓ Token数: ${doc.tokensCount || 0}`);
|
||||
}
|
||||
|
||||
if (doc.status === 'error' && doc.errorMessage) {
|
||||
console.log(` ✗ 错误: ${doc.errorMessage}`);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 查询失败:', error.message);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
checkDocuments();
|
||||
|
||||
Reference in New Issue
Block a user