|
10 | 10 | create_invoke_model_activity(app) # TODO: Can we hide this line?
|
11 | 11 |
|
12 | 12 |
|
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 |
| - |
19 | 13 | @app.route(route="orchestrators/{functionName}")
|
20 | 14 | @app.durable_client_input(client_name="client")
|
21 | 15 | async def orchestration_starter(req: func.HttpRequest, client):
|
@@ -53,21 +47,38 @@ def haiku_judge(context):
|
53 | 47 |
|
54 | 48 | haiku = Runner.run_sync(writer, "Tell me about recursion in programming.")
|
55 | 49 |
|
56 |
| - response = yield context.call_activity_yieldable("hello", "World") |
57 |
| - |
58 | 50 | judge = Agent(
|
59 | 51 | name="Judge",
|
60 | 52 | instructions="You judge haikus.",
|
61 | 53 | )
|
62 | 54 |
|
63 | 55 | evaluation = Runner.run_sync(judge, f"Is this a good haiku? {haiku.final_output}")
|
64 | 56 |
|
65 |
| - return [haiku.final_output, "\n\n" + evaluation.final_output, response] |
| 57 | + return [haiku.final_output, "\n\n" + evaluation.final_output] |
66 | 58 |
|
67 | 59 |
|
68 | 60 | @app.orchestration_trigger(context_name="context")
|
69 | 61 | @durable_openai_agent_orchestrator
|
70 | 62 | 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