-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathsend_message.py
More file actions
32 lines (26 loc) · 963 Bytes
/
send_message.py
File metadata and controls
32 lines (26 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
import asyncio
import sys
from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from workflows import BasicBedrockWorkflow
async def main(prompt: str) -> str:
# Create client connected to server at the given address
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)
# Start the workflow
workflow_id = "basic-bedrock-workflow"
handle = await client.start_workflow(
BasicBedrockWorkflow.run,
prompt, # Initial prompt
id=workflow_id,
task_queue="bedrock-task-queue",
)
return await handle.result()
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python send_message.py '<prompt>'")
print("Example: python send_message.py 'What animals are marsupials?'")
else:
result = asyncio.run(main(sys.argv[1]))
print(result)