pull/343/head
Kye 1 year ago
parent bfed7a45f6
commit 311d47ef4d

@ -128,24 +128,26 @@ for task in workflow.tasks:
### `ConcurrentWorkflow`
- Run all the tasks all at the same time
```python
import os
from dotenv import load_dotenv
from swarms.models import OpenAIChat, Task, ConcurrentWorkflow
from swarms import OpenAIChat, Task, ConcurrentWorkflow, Agent
# Load environment variables from .env file
load_dotenv()
# Load environment variables
llm = OpenAIChat(openai_api_key=os.getenv("OPENAI_API_KEY"))
agent = Agent(llm=llm, max_loops=1)
# Create a workflow
workflow = ConcurrentWorkflow(max_workers=5)
# Create tasks
task1 = Task(llm, "What's the weather in miami")
task2 = Task(llm, "What's the weather in new york")
task3 = Task(llm, "What's the weather in london")
task1 = Task(agent, "What's the weather in miami")
task2 = Task(agent, "What's the weather in new york")
task3 = Task(agent, "What's the weather in london")
# Add tasks to the workflow
workflow.add(task1)
@ -157,6 +159,40 @@ workflow.run()
```
### `RecursiveWorkflow`
- Recursively iterate on a workflow until a specific token is detected.
```python
import os
from dotenv import load_dotenv
from swarms import OpenAIChat, Task, RecursiveWorkflow, Agent
# Load environment variables from .env file
load_dotenv()
# Load environment variables
llm = OpenAIChat(openai_api_key=os.getenv("OPENAI_API_KEY"))
agent = Agent(llm=llm, max_loops=1)
# Create a workflow
workflow = RecursiveWorkflow(stop_token="<DONE>")
# Create tasks
task1 = Task(agent, "What's the weather in miami")
task2 = Task(agent, "What's the weather in new york")
task3 = Task(agent, "What's the weather in london")
# Add tasks to the workflow
workflow.add(task1)
workflow.add(task2)
workflow.add(task3)
# Run the workflow
workflow.run()
```
### `ModelParallelizer`

@ -1,20 +1,21 @@
import os
from dotenv import load_dotenv
from swarms.models import OpenAIChat, Task, ConcurrentWorkflow
from swarms import OpenAIChat, Task, ConcurrentWorkflow, Agent
# Load environment variables from .env file
load_dotenv()
# Load environment variables
llm = OpenAIChat(openai_api_key=os.getenv("OPENAI_API_KEY"))
agent = Agent(llm=llm, max_loops=1)
# Create a workflow
workflow = ConcurrentWorkflow(max_workers=5)
# Create tasks
task1 = Task(llm, "What's the weather in miami")
task2 = Task(llm, "What's the weather in new york")
task3 = Task(llm, "What's the weather in london")
task1 = Task(agent, "What's the weather in miami")
task2 = Task(agent, "What's the weather in new york")
task3 = Task(agent, "What's the weather in london")
# Add tasks to the workflow
workflow.add(task1)

@ -0,0 +1,26 @@
import os
from dotenv import load_dotenv
from swarms import OpenAIChat, Task, RecursiveWorkflow, Agent
# Load environment variables from .env file
load_dotenv()
# Load environment variables
llm = OpenAIChat(openai_api_key=os.getenv("OPENAI_API_KEY"))
agent = Agent(llm=llm, max_loops=1)
# Create a workflow
workflow = RecursiveWorkflow(stop_token="<DONE>")
# Create tasks
task1 = Task(agent, "What's the weather in miami")
task2 = Task(agent, "What's the weather in new york")
task3 = Task(agent, "What's the weather in london")
# Add tasks to the workflow
workflow.add(task1)
workflow.add(task2)
workflow.add(task3)
# Run the workflow
workflow.run()
Loading…
Cancel
Save