mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 14:08:08 +01:00
refactor, date context
This commit is contained in:
36
scripts/run_worker.py
Normal file
36
scripts/run_worker.py
Normal file
@@ -0,0 +1,36 @@
|
||||
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())
|
||||
Reference in New Issue
Block a user