55 lines
1.8 KiB
PowerShell
55 lines
1.8 KiB
PowerShell
param(
|
|
[string]$BaseUrl = "http://localhost:9900",
|
|
[string]$SessionId = "mvp-demo-payment-timeout-001",
|
|
[string]$RequestFile = "$PSScriptRoot/../requests/payment-timeout-chat.json",
|
|
[string]$OutputDir = "$PSScriptRoot/../output"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null
|
|
|
|
$request = Get-Content -Raw -Encoding UTF8 -Path $RequestFile | ConvertFrom-Json
|
|
$request.Id = $SessionId
|
|
$body = $request | ConvertTo-Json -Depth 8
|
|
|
|
Write-Host "正在运行支付超时 Chat 诊断 Demo..."
|
|
Write-Host "BaseUrl: $BaseUrl"
|
|
Write-Host "SessionId: $SessionId"
|
|
|
|
$chat = Invoke-RestMethod `
|
|
-Method Post `
|
|
-Uri "$BaseUrl/api/chat" `
|
|
-ContentType "application/json; charset=utf-8" `
|
|
-Body $body
|
|
|
|
$chat | ConvertTo-Json -Depth 20 | Set-Content -Encoding UTF8 -Path "$OutputDir/chat-response.json"
|
|
Write-Host "已保存 Chat 响应: $OutputDir/chat-response.json"
|
|
|
|
$trace = Invoke-RestMethod `
|
|
-Method Get `
|
|
-Uri "$BaseUrl/api/diagnosis/$SessionId/trace"
|
|
|
|
$trace | ConvertTo-Json -Depth 50 | Set-Content -Encoding UTF8 -Path "$OutputDir/trace-response.json"
|
|
Write-Host "已保存 Trace 响应: $OutputDir/trace-response.json"
|
|
|
|
$feedbackBody = @{
|
|
sessionId = $SessionId
|
|
feedback = "useful"
|
|
} | ConvertTo-Json
|
|
|
|
$feedback = Invoke-RestMethod `
|
|
-Method Post `
|
|
-Uri "$BaseUrl/api/feedback" `
|
|
-ContentType "application/json; charset=utf-8" `
|
|
-Body $feedbackBody
|
|
|
|
$feedback | ConvertTo-Json -Depth 20 | Set-Content -Encoding UTF8 -Path "$OutputDir/feedback-response.json"
|
|
Write-Host "已保存反馈响应: $OutputDir/feedback-response.json"
|
|
|
|
Write-Host ""
|
|
Write-Host "Demo 已完成,请检查:"
|
|
Write-Host "- mvp/demo/output/chat-response.json"
|
|
Write-Host "- mvp/demo/output/trace-response.json"
|
|
Write-Host "- mvp/demo/output/feedback-response.json"
|