File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -138,20 +138,18 @@ async def on_seat_booking_handoff(context: RunContextWrapper[AirlineAgentContext
138
138
### RUN
139
139
140
140
141
- async def main ():
141
+ def main (context ):
142
142
current_agent : Agent [AirlineAgentContext ] = triage_agent
143
143
input_items : list [TResponseInputItem ] = []
144
144
context = AirlineAgentContext ()
145
145
146
- # Normally, each input from the user would be an API request to your app, and you can wrap the request in a trace()
147
- # Here, we'll just use a random UUID for the conversation ID
148
- conversation_id = uuid .uuid4 ().hex [:16 ]
146
+ conversation_id = context .instance_id
149
147
150
148
while True :
151
- user_input = input ( "Enter your message: " )
149
+ user_input = context . wait_for_external_event ( "UserInput " )
152
150
with trace ("Customer service" , group_id = conversation_id ):
153
151
input_items .append ({"content" : user_input , "role" : "user" })
154
- result = await Runner .run (current_agent , input_items , context = context )
152
+ result = Runner .run_sync (current_agent , input_items , context = context )
155
153
156
154
for new_item in result .new_items :
157
155
agent_name = new_item .agent .name
Original file line number Diff line number Diff line change @@ -120,4 +120,4 @@ def message_filter(context):
120
120
@app .durable_openai_agent_orchestrator
121
121
def customer_service (context ):
122
122
import customer_service .customer_service
123
- return customer_service .customer_service .main ()
123
+ return customer_service .customer_service .main (context )
You can’t perform that action at this time.
0 commit comments