From bd0a89705f4bb726dc369d6001aa154387173fc5 Mon Sep 17 00:00:00 2001 From: Occupying-Mars Date: Sun, 10 Nov 2024 21:40:12 +0530 Subject: [PATCH] async_workkflow --- tests/structs/test_async_workflow.py | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/structs/test_async_workflow.py diff --git a/tests/structs/test_async_workflow.py b/tests/structs/test_async_workflow.py new file mode 100644 index 00000000..512fd0eb --- /dev/null +++ b/tests/structs/test_async_workflow.py @@ -0,0 +1,35 @@ +import pytest +import asyncio +from swarms import Agent, AsyncWorkflow +from swarm_models import OpenAIChat # or any other model you prefer + +@pytest.mark.asyncio +async def test_async_workflow(): + # Create test agents + model = OpenAIChat() # Initialize with appropriate parameters + agents = [ + Agent( + agent_name=f"Test-Agent-{i}", + llm=model, + max_loops=1, + dashboard=False, + verbose=True, + ) + for i in range(3) + ] + + # Initialize workflow + workflow = AsyncWorkflow( + name="Test-Async-Workflow", + agents=agents, + max_workers=3, + verbose=True + ) + + # Run test task + test_task = "What is 2+2?" + results = await workflow.run(test_task) + + # Assertions + assert len(results) == len(agents) + assert all(isinstance(result, str) for result in results)