-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathsend_message.py
More file actions
33 lines (26 loc) · 1008 Bytes
/
send_message.py
File metadata and controls
33 lines (26 loc) · 1008 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
import asyncio
import sys
from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from workflows import BedrockParams, EntityBedrockWorkflow
async def main(prompt):
# 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)
workflow_id = "entity-bedrock-workflow"
# Sends a signal to the workflow (and starts it if needed)
await client.start_workflow(
EntityBedrockWorkflow.run,
BedrockParams(None, None),
id=workflow_id,
task_queue="bedrock-task-queue",
start_signal="user_prompt",
start_signal_args=[prompt],
)
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:
asyncio.run(main(sys.argv[1]))