Skip to content

Commit 1fe7f00

Browse files
committed
Make main orchestrator-compliant
1 parent ff6243e commit 1fe7f00

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

samples-v2/openai_agents/customer_service/customer_service.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,18 @@ async def on_seat_booking_handoff(context: RunContextWrapper[AirlineAgentContext
138138
### RUN
139139

140140

141-
async def main():
141+
def main(context):
142142
current_agent: Agent[AirlineAgentContext] = triage_agent
143143
input_items: list[TResponseInputItem] = []
144144
context = AirlineAgentContext()
145145

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
149147

150148
while True:
151-
user_input = input("Enter your message: ")
149+
user_input = context.wait_for_external_event("UserInput")
152150
with trace("Customer service", group_id=conversation_id):
153151
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)
155153

156154
for new_item in result.new_items:
157155
agent_name = new_item.agent.name

samples-v2/openai_agents/function_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,4 @@ def message_filter(context):
120120
@app.durable_openai_agent_orchestrator
121121
def customer_service(context):
122122
import customer_service.customer_service
123-
return customer_service.customer_service.main()
123+
return customer_service.customer_service.main(context)

0 commit comments

Comments
 (0)