- 新增用户服务,支持多用户数据隔离与认证 - 新增关系历史查询接口,支持按冲突、积极、时间线等类型过滤 - 新增恋爱决策建议接口,基于图谱分析生成关系健康报告 - 优化前端图谱可视化,增加节点详情面板、图例和边标签显示 - 改进文本分析逻辑,支持实体去重和情感标注 - 新增完整流程测试脚本,验证分析、入库、查询全链路
72 lines
3.3 KiB
PowerShell
72 lines
3.3 KiB
PowerShell
# 测试 RAG 检索和恋爱决策建议功能
|
|
|
|
Write-Host "=== 测试 RAG 检索功能 ===" -ForegroundColor Cyan
|
|
|
|
$userId = "test_user_" + (Get-Random)
|
|
Write-Host "用户 ID: $userId`n" -ForegroundColor Yellow
|
|
|
|
# 1. 逐步输入对话,构建图谱
|
|
$messages = @(
|
|
"我和女朋友小红在一起两年了,她对我很好",
|
|
"上周我和小红吵架了,因为她闺蜜丽丽说我对小红不够关心",
|
|
"小红生日我给她准备了惊喜,她很开心",
|
|
"小红的妈妈对我们关系有些意见,觉得我工作不够稳定"
|
|
)
|
|
|
|
Write-Host "[1/2] 逐步构建知识图谱..." -ForegroundColor Yellow
|
|
foreach ($msg in $messages) {
|
|
Write-Host " 输入:$msg"
|
|
$body = @{ text = $msg; userId = $userId } | ConvertTo-Json
|
|
$result = Invoke-RestMethod -Uri "http://localhost:3000/analyze" -Method Post -ContentType "application/json" -Body $body
|
|
Write-Host " 结果:新增 $($result.stats.created.persons) 人,$($result.stats.created.events) 事件`n"
|
|
}
|
|
|
|
# 2. 查询关系历史
|
|
Write-Host "[2/4] 查询关系历史..." -ForegroundColor Yellow
|
|
$body = @{ userId = $userId; queryType = "all" } | ConvertTo-Json
|
|
$history = Invoke-RestMethod -Uri "http://localhost:3000/query/history" -Method Post -ContentType "application/json" -Body $body
|
|
Write-Host " 事件总数:$($history.total)"
|
|
foreach ($event in $history.events) {
|
|
Write-Host " - [$($event.emotional_tone)] $($event.summary)"
|
|
}
|
|
Write-Host ""
|
|
|
|
# 3. 查询冲突事件
|
|
Write-Host "[3/4] 查询冲突事件..." -ForegroundColor Yellow
|
|
$body = @{ userId = $userId; queryType = "conflicts" } | ConvertTo-Json
|
|
$conflicts = Invoke-RestMethod -Uri "http://localhost:3000/query/history" -Method Post -ContentType "application/json" -Body $body
|
|
Write-Host " 冲突数:$($conflicts.total)"
|
|
foreach ($event in $conflicts.events) {
|
|
Write-Host " - $($event.summary)"
|
|
}
|
|
Write-Host ""
|
|
|
|
# 4. 获取恋爱建议
|
|
Write-Host "[4/4] 获取恋爱决策建议..." -ForegroundColor Yellow
|
|
$body = @{ userId = $userId } | ConvertTo-Json
|
|
$advice = Invoke-RestMethod -Uri "http://localhost:3000/query/advice" -Method Post -ContentType "application/json" -Body $body
|
|
|
|
Write-Host "`n=== 恋爱关系分析报告 ===" -ForegroundColor Cyan
|
|
Write-Host "关系健康状况:$($advice.analysis.relationship_health)" -ForegroundColor $(
|
|
if ($advice.analysis.relationship_health -eq 'healthy') { 'Green' }
|
|
elseif ($advice.analysis.relationship_health -eq 'concerning') { 'Red' }
|
|
else { 'Yellow' }
|
|
)
|
|
Write-Host "`n总结:$($advice.analysis.summary)"
|
|
Write-Host "`n识别的模式:"
|
|
foreach ($pattern in $advice.analysis.patterns) {
|
|
Write-Host " - $($pattern.pattern)" -ForegroundColor Yellow
|
|
Write-Host " 证据:$($pattern.evidence)"
|
|
Write-Host " 建议:$($pattern.suggestion)`n"
|
|
}
|
|
Write-Host "第三方影响:$($advice.analysis.third_party_influence)"
|
|
Write-Host "`n行动建议:"
|
|
for ($i = 0; $i -lt $advice.analysis.action_items.Count; $i++) {
|
|
Write-Host " $($i + 1). $($advice.analysis.action_items[$i])" -ForegroundColor Green
|
|
}
|
|
Write-Host "`n积极方面:$($advice.analysis.positive_notes)" -ForegroundColor Green
|
|
Write-Host "`n统计数据:"
|
|
Write-Host " 总事件数:$($advice.statistics.total_events)"
|
|
Write-Host " 积极事件:$($advice.statistics.positive_events)"
|
|
Write-Host " 消极事件:$($advice.statistics.negative_events)"
|