mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-16 06:28:08 +01:00
initial working with ollama
This commit is contained in:
30
send_message.py
Normal file
30
send_message.py
Normal file
@@ -0,0 +1,30 @@
|
||||
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]))
|
||||
Reference in New Issue
Block a user