File tree Expand file tree Collapse file tree 2 files changed +47
-34
lines changed
samples-v2/openai_agents/customer_service Expand file tree Collapse file tree 2 files changed +47
-34
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import argparse
2
+ import requests
3
+ import time
4
+ import sys
5
+
6
+
7
+ def main ():
8
+ parser = argparse .ArgumentParser (description = 'Customer Service Orchestration Client' )
9
+ parser .add_argument (
10
+ '--start-url' ,
11
+ default = 'http://localhost:7071/api/orchestrators/customer_service' ,
12
+ help = 'The orchestrator start URL'
13
+ )
14
+ args = parser .parse_args ()
15
+
16
+ # Start the orchestration
17
+ orchestration = requests .post (args .start_url ).json ()
18
+
19
+ while True :
20
+ # Wait for a prompt in the custom status
21
+ while True :
22
+ status = requests .get (orchestration ['statusQueryGetUri' ]).json ()
23
+
24
+ if status ['runtimeStatus' ] == 'Completed' :
25
+ print (f"Orchestration completed with result: { status ['output' ]} " )
26
+ sys .exit (0 )
27
+
28
+ if status ['runtimeStatus' ] not in ['Pending' , 'Running' ]:
29
+ raise Exception (f"Unexpected orchestration status: { status ['runtimeStatus' ]} " )
30
+
31
+ if status .get ('customStatus' ) and status ['customStatus' ] != 'Thinking...' :
32
+ break
33
+
34
+ time .sleep (1 )
35
+
36
+ # Prompt the user for input interactively
37
+ user_input = input (status ['customStatus' ] + ' ' )
38
+
39
+ # Send the user input to the orchestration as an external event
40
+ event_url = orchestration ['sendEventPostUri' ].replace ('{eventName}' , 'UserInput' )
41
+ requests .post (event_url , json = user_input )
42
+
43
+ time .sleep (2 )
44
+
45
+
46
+ if __name__ == '__main__' :
47
+ main ()
You can’t perform that action at this time.
0 commit comments