Skip to content

Commit a0ea09f

Browse files
committed
Add customer_service_client.ps1
1 parent f5b1084 commit a0ea09f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
$ErrorActionPreference = 'Stop'
2+
3+
$orchestration = Invoke-RestMethod 'http://localhost:7071/api/orchestrators/customer_service'
4+
5+
6+
while ($true) {
7+
# Wait for a prompt in the custom status
8+
while ($true) {
9+
$status = Invoke-RestMethod $orchestration.statusQueryGetUri
10+
if ($status.runtimeStatus -eq "Completed") {
11+
Write-Host "Orchestration completed with result: $($status.output)"
12+
exit 0
13+
}
14+
if ($status.runtimeStatus -ne "Pending" -and $status.runtimeStatus -ne "Running") {
15+
throw "Unexpected orchestration status: $($status.runtimeStatus)"
16+
}
17+
if ($status.customStatus -and $status.customStatus -ne "Thinking...") {
18+
break
19+
}
20+
Start-Sleep -Seconds 1
21+
}
22+
23+
# Prompt the user for input interactively
24+
$userInput = Read-Host $status.customStatus
25+
26+
# Send the user input to the orchestration as an external event
27+
$eventUrl = $orchestration.SendEventPostUri.Replace('{eventName}', 'UserInput')
28+
Invoke-RestMethod $eventUrl -Method Post -ContentType 'application/json' -Body ($userInput | ConvertTo-Json)
29+
30+
Start-Sleep -Seconds 2
31+
}

0 commit comments

Comments
 (0)