Skip to content

Commit 5e29aa4

Browse files
committed
Add haiku_judge sample
1 parent 10cda63 commit 5e29aa4

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

samples-v2/openai_agents/function_app.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,32 @@ def basic_hello_world_orchestrator(context):
2727

2828
@app.orchestration_trigger(context_name="context")
2929
@durable_openai_agent_orchestrator
30-
def basic_hello_world_orchestrator_inline(context):
30+
def haiku(context):
3131
agent = Agent(
3232
name="Assistant",
3333
instructions="You only respond in haikus.",
3434
)
3535

3636
result = Runner.run_sync(agent, "Tell me about recursion in programming.")
3737
return result.final_output
38+
39+
40+
@app.orchestration_trigger(context_name="context")
41+
@durable_openai_agent_orchestrator
42+
def haiku_judge(context):
43+
writer = Agent(
44+
name="Writer",
45+
instructions="You only respond in haikus.",
46+
)
47+
48+
haiku = Runner.run_sync(writer, "Tell me about recursion in programming.")
49+
50+
judge = Agent(
51+
name="Judge",
52+
instructions="You judge haikus.",
53+
)
54+
55+
evaluation = Runner.run_sync(judge, f"Is this a good haiku? {haiku.final_output}")
56+
57+
return [haiku.final_output, "\n\n" + evaluation.final_output]
58+

0 commit comments

Comments
 (0)