Skip to content

Commit 14bc832

Browse files
committed
Rename call_activity_yieldable to call_activity
1 parent ffbabca commit 14bc832

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

samples-v2/openai_agents/durable_ai_agent_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_activity_call_result(self, activity_name, input: str):
2626
result = json.loads(result_json)
2727
return result
2828

29-
def call_activity_yieldable(self, activity_name, input: str):
29+
def call_activity(self, activity_name, input: str):
3030
task = self.context.call_activity(activity_name, input)
3131
self.activities_called += 1
3232
return task

samples-v2/openai_agents/function_app.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
create_invoke_model_activity(app) # TODO: Can we hide this line?
1111

1212

13-
@app.activity_trigger(input_name="name")
14-
async def hello(name: str):
15-
"""A simple durable activity that returns a greeting message."""
16-
return f"Hello {name}!"
17-
18-
1913
@app.route(route="orchestrators/{functionName}")
2014
@app.durable_client_input(client_name="client")
2115
async def orchestration_starter(req: func.HttpRequest, client):
@@ -53,21 +47,38 @@ def haiku_judge(context):
5347

5448
haiku = Runner.run_sync(writer, "Tell me about recursion in programming.")
5549

56-
response = yield context.call_activity_yieldable("hello", "World")
57-
5850
judge = Agent(
5951
name="Judge",
6052
instructions="You judge haikus.",
6153
)
6254

6355
evaluation = Runner.run_sync(judge, f"Is this a good haiku? {haiku.final_output}")
6456

65-
return [haiku.final_output, "\n\n" + evaluation.final_output, response]
57+
return [haiku.final_output, "\n\n" + evaluation.final_output]
6658

6759

6860
@app.orchestration_trigger(context_name="context")
6961
@durable_openai_agent_orchestrator
7062
def hello_cities(context):
71-
task = context.call_activity_yieldable("hello", "Seattle")
72-
result = yield task
73-
return result
63+
writer = Agent(
64+
name="Writer",
65+
instructions="You only respond in haikus.",
66+
)
67+
68+
topic = yield context.call_activity("hello", "Seattle")
69+
70+
haiku = Runner.run_sync(writer, f"Tell me about '{topic}'")
71+
72+
judge = Agent(
73+
name="Judge",
74+
instructions="You judge haikus.",
75+
)
76+
77+
evaluation = Runner.run_sync(judge, f"Is this a good haiku? {haiku.final_output}")
78+
79+
return [haiku.final_output, "\n\n" + evaluation.final_output]
80+
81+
82+
@app.activity_trigger(input_name="name")
83+
async def hello(name: str):
84+
return f"Hello {name}!"

0 commit comments

Comments
 (0)