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:
70
backend/check-docs-api.ps1
Normal file
70
backend/check-docs-api.ps1
Normal file
@@ -0,0 +1,70 @@
|
||||
# 通过API查询文档状态
|
||||
Write-Host "`n📋 查询知识库和文档状态...`n" -ForegroundColor Green
|
||||
|
||||
# 获取知识库列表
|
||||
try {
|
||||
$response = Invoke-RestMethod -Uri "http://localhost:3001/api/v1/knowledge-bases" -Method GET
|
||||
|
||||
if ($response.data.Count -eq 0) {
|
||||
Write-Host "❌ 没有找到任何知识库" -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
|
||||
Write-Host "找到 $($response.data.Count) 个知识库:`n" -ForegroundColor Cyan
|
||||
|
||||
foreach ($kb in $response.data) {
|
||||
Write-Host "📚 知识库: $($kb.name)" -ForegroundColor Yellow
|
||||
Write-Host " ID: $($kb.id)"
|
||||
Write-Host " 描述: $($kb.description)"
|
||||
Write-Host " 文件数: $($kb.fileCount)"
|
||||
Write-Host " 创建时间: $($kb.createdAt)"
|
||||
|
||||
# 获取该知识库的文档列表
|
||||
try {
|
||||
$docsResponse = Invoke-RestMethod -Uri "http://localhost:3001/api/v1/knowledge-bases/$($kb.id)/documents" -Method GET
|
||||
|
||||
if ($docsResponse.data.Count -gt 0) {
|
||||
Write-Host "`n 📄 文档列表:" -ForegroundColor Cyan
|
||||
|
||||
foreach ($doc in $docsResponse.data) {
|
||||
$statusEmoji = switch ($doc.status) {
|
||||
"uploading" { "📤" }
|
||||
"parsing" { "🔄" }
|
||||
"indexing" { "⚙️" }
|
||||
"completed" { "✅" }
|
||||
"error" { "❌" }
|
||||
default { "❓" }
|
||||
}
|
||||
|
||||
Write-Host " $statusEmoji $($doc.filename)" -ForegroundColor White
|
||||
Write-Host " 状态: $($doc.status)"
|
||||
Write-Host " 大小: $([math]::Round($doc.fileSizeBytes / 1024, 2)) KB"
|
||||
Write-Host " 上传时间: $($doc.uploadedAt)"
|
||||
|
||||
if ($doc.status -eq "completed") {
|
||||
Write-Host " ✓ 段落数: $($doc.segmentsCount)" -ForegroundColor Green
|
||||
Write-Host " ✓ Token数: $($doc.tokensCount)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
if ($doc.status -eq "error" -and $doc.errorMessage) {
|
||||
Write-Host " ✗ 错误: $($doc.errorMessage)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
}
|
||||
} else {
|
||||
Write-Host " (该知识库暂无文档)`n"
|
||||
}
|
||||
|
||||
} catch {
|
||||
Write-Host " ❌ 获取文档列表失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-Host ("-" * 60)
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
} catch {
|
||||
Write-Host "❌ 查询失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user