mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 22:18:09 +01:00
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
import asyncio
|
|
import concurrent.futures
|
|
import logging
|
|
|
|
from temporalio.client import Client
|
|
from temporalio.worker import Worker
|
|
|
|
from activities.tool_activities import ToolActivities
|
|
from workflows.tool_workflow import ToolWorkflow
|
|
from workflows.parent_workflow import ParentWorkflow
|
|
|
|
|
|
async def main():
|
|
# Create client connected to server at the given address
|
|
client = await Client.connect("localhost:7233")
|
|
activities = ToolActivities()
|
|
|
|
# Run the worker
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=100) as activity_executor:
|
|
worker = Worker(
|
|
client,
|
|
task_queue="ollama-task-queue",
|
|
workflows=[ToolWorkflow, ParentWorkflow],
|
|
activities=[activities.prompt_llm, activities.parse_tool_data],
|
|
activity_executor=activity_executor,
|
|
)
|
|
await worker.run()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print("Starting worker")
|
|
print("Then run 'python send_message.py \"<prompt>\"'")
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
asyncio.run(main())
|