-实现了用于启动内存图可视化工具的PowerShell脚本(visualizer.ps1)。 -开发了一个完整的服务器(visualizer_server.py),为可视化内存图数据提供了web API。 -创建了一个简单的独立版本(visualizer_simple.py),可以直接从存储的数据文件生成可视化。 -添加了用于获取完整图形数据、内存详细信息、搜索内存和检索统计信息的端点。 -包括列出可用数据文件和选择特定文件进行可视化的功能。 -在整个服务器和简单的可视化脚本中增强错误处理和日志记录。
66 lines
2.1 KiB
PowerShell
66 lines
2.1 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
# 记忆图可视化工具启动脚本 - PowerShell版本
|
|
|
|
Write-Host "=" -NoNewline -ForegroundColor Cyan
|
|
Write-Host ("=" * 69) -ForegroundColor Cyan
|
|
Write-Host "🦊 MoFox Bot - 记忆图可视化工具" -ForegroundColor Yellow
|
|
Write-Host "=" -NoNewline -ForegroundColor Cyan
|
|
Write-Host ("=" * 69) -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# 检查虚拟环境
|
|
$venvPath = ".venv\Scripts\python.exe"
|
|
if (-not (Test-Path $venvPath)) {
|
|
Write-Host "❌ 未找到虚拟环境: $venvPath" -ForegroundColor Red
|
|
Write-Host ""
|
|
Write-Host "请先创建虚拟环境:" -ForegroundColor Yellow
|
|
Write-Host " python -m venv .venv" -ForegroundColor Cyan
|
|
Write-Host " .\.venv\Scripts\Activate.ps1" -ForegroundColor Cyan
|
|
Write-Host " pip install -r requirements.txt" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "✅ 使用虚拟环境: $venvPath" -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# 检查依赖
|
|
Write-Host "🔍 检查依赖..." -ForegroundColor Cyan
|
|
& $venvPath -c "import flask; import flask_cors" 2>$null
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "⚠️ 缺少依赖,正在安装..." -ForegroundColor Yellow
|
|
& $venvPath -m pip install flask flask-cors --quiet
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "❌ 安装依赖失败" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
Write-Host "✅ 依赖安装完成" -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host "✅ 依赖检查完成" -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# 显示信息
|
|
Write-Host "📊 启动可视化服务器..." -ForegroundColor Cyan
|
|
Write-Host "🌐 访问地址: " -NoNewline -ForegroundColor White
|
|
Write-Host "http://127.0.0.1:5001" -ForegroundColor Blue
|
|
Write-Host "⏹️ 按 Ctrl+C 停止服务器" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host "=" -NoNewline -ForegroundColor Cyan
|
|
Write-Host ("=" * 69) -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# 启动服务器
|
|
try {
|
|
& $venvPath "tools\memory_visualizer\visualizer_simple.py"
|
|
}
|
|
catch {
|
|
Write-Host ""
|
|
Write-Host "❌ 启动失败: $_" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
finally {
|
|
Write-Host ""
|
|
Write-Host "👋 服务器已停止" -ForegroundColor Yellow
|
|
}
|