-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathrun_workflow.py
More file actions
38 lines (28 loc) · 963 Bytes
/
Copy pathrun_workflow.py
File metadata and controls
38 lines (28 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Start the chat workflow, send a few turns, then end it."""
import asyncio
import os
from temporalio.client import Client
from temporalio.contrib.strands import StrandsPlugin
from strands_plugin.continue_as_new.workflow import ChatInput, ChatWorkflow
async def main() -> None:
client = await Client.connect(
os.environ.get("TEMPORAL_ADDRESS", "localhost:7233"),
plugins=[StrandsPlugin()],
)
handle = await client.start_workflow(
ChatWorkflow.run,
ChatInput(),
id="strands-chat",
task_queue="strands-chat",
)
for prompt in [
"Hi! What is durable execution?",
"Give me a one-sentence summary.",
]:
reply = await handle.execute_update(ChatWorkflow.turn, prompt)
print(f"user: {prompt}")
print(f"assistant: {reply}\n")
await handle.signal(ChatWorkflow.end_chat)
await handle.result()
if __name__ == "__main__":
asyncio.run(main())