File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
samples-v2/openai_agents/customer_service Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments