probe-simulate-dialogue.ps1 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Probe POST /workflow/simulate and print diagnosis fields.
  2. # Usage:
  3. # .\probe-simulate-dialogue.ps1 -Token "Bearer xxx" -TemplateId 123
  4. # .\probe-simulate-dialogue.ps1 -BaseUrl "http://127.0.0.1:8004" -Token "Bearer xxx" -TemplateId 123
  5. param(
  6. [string]$BaseUrl = "http://127.0.0.1:8004",
  7. [Parameter(Mandatory = $true)][string]$Token,
  8. [Parameter(Mandatory = $true)][long]$TemplateId,
  9. [string]$Content = "你好,芹菜能治疗糖尿病吗?对糖尿病有好处么?"
  10. )
  11. $uri = "$BaseUrl/workflow/simulate"
  12. $body = @{
  13. templateId = $TemplateId
  14. content = $Content
  15. } | ConvertTo-Json -Compress
  16. $headers = @{
  17. Authorization = $Token
  18. "Content-Type" = "application/json"
  19. }
  20. Write-Host "POST $uri"
  21. Write-Host "Body: $body"
  22. Write-Host ""
  23. try {
  24. $resp = Invoke-RestMethod -Uri $uri -Method Post -Headers $headers -Body $body -TimeoutSec 120
  25. } catch {
  26. Write-Host "HTTP ERROR: $($_.Exception.Message)" -ForegroundColor Red
  27. if ($_.ErrorDetails.Message) { Write-Host $_.ErrorDetails.Message }
  28. exit 1
  29. }
  30. Write-Host "=== RAW RESPONSE ===" -ForegroundColor Cyan
  31. $resp | ConvertTo-Json -Depth 6
  32. $data = $resp.data
  33. if ($null -eq $data) {
  34. Write-Host "`n[WARN] response.data is empty" -ForegroundColor Yellow
  35. exit 2
  36. }
  37. Write-Host "`n=== DIAGNOSIS ===" -ForegroundColor Cyan
  38. $mode = $data.mode
  39. Write-Host ("mode : {0}" -f $mode)
  40. Write-Host ("intent : {0}" -f $data.intent)
  41. Write-Host ("surfaceQuestionType: {0}" -f $data.surfaceQuestionType)
  42. Write-Host ("shouldProbe : {0}" -f $data.shouldProbe)
  43. Write-Host ("probeQuestion : {0}" -f $data.probeQuestion)
  44. Write-Host ("uddUsed : {0}" -f $data.uddUsed)
  45. Write-Host ("instanceId : {0}" -f $data.instanceId)
  46. Write-Host ("nodeCode : {0}" -f $data.nodeCode)
  47. Write-Host ("reply (first 200) : {0}" -f ($(if ($data.reply) { $data.reply.Substring(0, [Math]::Min(200, $data.reply.Length)) } else { "" })))
  48. if ($mode -eq "legacy") {
  49. Write-Host "`n[ROOT CAUSE] Still legacy FastGPT path -> no intent/UDD probe." -ForegroundColor Red
  50. Write-Host "engineHint: $($data.engineHint)"
  51. exit 3
  52. }
  53. if (-not $data.intent) {
  54. Write-Host "`n[WARN] engine mode but intent is null -> check DynamicNodeAdjuster/semantic." -ForegroundColor Yellow
  55. }
  56. if ($data.shouldProbe -ne $true) {
  57. Write-Host "`n[WARN] shouldProbe=false -> UDD plan did not enable follow-up." -ForegroundColor Yellow
  58. } elseif ($data.reply -and $data.probeQuestion -and ($data.reply -notlike "*$($data.probeQuestion.Substring(0, [Math]::Min(8, $data.probeQuestion.Length)))*")) {
  59. Write-Host "`n[WARN] probe planned but reply missing probe text -> check quality regen strip." -ForegroundColor Yellow
  60. } else {
  61. Write-Host "`n[OK] Engine path with follow-up probe." -ForegroundColor Green
  62. }
  63. exit 0