Skip to content

Commit c7333ae

Browse files
committed
human_in_the_loop sample
1 parent f8fd081 commit c7333ae

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

samples-v2/openai_agents/function_app.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,25 @@ async def hello(name: str):
8888
@app.orchestration_trigger(context_name="context")
8989
@durable_openai_agent_orchestrator
9090
def human_in_the_loop(context):
91-
context.set_custom_status("Waiting for approval...")
91+
writer = Agent(
92+
name="Writer",
93+
instructions="You only respond in haikus.",
94+
)
95+
96+
haiku = Runner.run_sync(writer, "Tell me about recursion in programming.")
97+
98+
judge = Agent(
99+
name="Judge",
100+
instructions="You judge haikus.",
101+
)
102+
103+
evaluation = Runner.run_sync(judge, f"Is this a good haiku? {haiku.final_output}")
104+
105+
context.set_custom_status(f"Haiku:\n{haiku.final_output}\n\nEvaluation:\n{evaluation.final_output}\n\nWaiting for approval...")
92106
event_data = yield context.wait_for_external_event("Approve")
93107
context.set_custom_status("")
94-
return event_data
108+
109+
reaction = Runner.run_sync(writer, f"Your haiku is considered {event_data}. React emotionally.")
110+
111+
return reaction.final_output
112+

0 commit comments

Comments
 (0)