mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 22:18:09 +01:00
31 lines
854 B
Python
31 lines
854 B
Python
import asyncio
|
|
import sys
|
|
|
|
from temporalio.client import Client
|
|
from workflows import OllamaParams, EntityOllamaWorkflow
|
|
|
|
|
|
async def main(prompt):
|
|
# Create client connected to server at the given address
|
|
client = await Client.connect("localhost:7233")
|
|
|
|
workflow_id = "entity-ollama-workflow"
|
|
|
|
# Sends a signal to the workflow (and starts it if needed)
|
|
await client.start_workflow(
|
|
EntityOllamaWorkflow.run,
|
|
OllamaParams(None, None),
|
|
id=workflow_id,
|
|
task_queue="ollama-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]))
|