diff --git a/example.py b/example.py index 81427a8f..0f82b7d5 100644 --- a/example.py +++ b/example.py @@ -1,11 +1,23 @@ -from swarms import Worker +# from swarms import Worker -node = Worker( - openai_api_key="", - ai_name="Optimus Prime", +# node = Worker( +# openai_api_key="", +# ai_name="Optimus Prime", -) +# ) -task = "What were the winning boston marathon times for the past 5 years (ending in 2022)? Generate a table of the year, name, country of origin, and times." -response = node.run(task) -print(response) \ No newline at end of file +# task = "What were the winning boston marathon times for the past 5 years (ending in 2022)? Generate a table of the year, name, country of origin, and times." +# response = node.run(task) +# print(response) + + +from swarms import Workflow +from swarms.tools.autogpt import ChatOpenAI + +workflow = Workflow(ChatOpenAI) + +workflow.add("What's the weather in miami") +workflow.add("Provide detauls for {{ parent_output }}") +workflow.add("Summarize the above information: {{ parent_output}}") + +workflow.run() diff --git a/swarms/structs/workflow.py b/swarms/structs/workflow.py index 8a8fde1a..d718123f 100644 --- a/swarms/structs/workflow.py +++ b/swarms/structs/workflow.py @@ -1,21 +1,21 @@ from __future__ import annotations -from typing import Any, Dict, List, Optional, Union +import concurrent.futures +from typing import Any, Dict, List, Optional -from swarms.artifacts.error_artifacts import ErrorArtifact +from swarms.artifacts.error_artifact import ErrorArtifact from swarms.structs.task import BaseTask -import concurrent.futures +from dataclasses import dataclass +@dataclass class StringTask(BaseTask): - def __init__( - self, - task - ): - super().__init__() - self.task = task + task: str def execute(self) -> Any: - prompt = self.task_string.replace("{{ parent_input }}", self.parents[0].output if self.parents else "") + prompt = self.task_string.replace( + "{{ parent_input }}", self.parents[0].output if self.parents else "" + ) + response = self.structure.llm.run(prompt) self.output = response return response @@ -24,7 +24,8 @@ class StringTask(BaseTask): class Workflow: """ - Workflows are ideal for prescriptive processes that need to be executed sequentially. + Workflows are ideal for prescriptive processes that need to be executed + sequentially. They string together multiple tasks of varying types, and can use Short-Term Memory or pass specific arguments downstream.