clean up workflow

pull/55/head
Kye 1 year ago
parent 175923ec1a
commit ee82439d0e

@ -17,7 +17,7 @@ from swarms.tools.autogpt import ChatOpenAI
workflow = Workflow(ChatOpenAI) workflow = Workflow(ChatOpenAI)
workflow.add("What's the weather in miami") workflow.add("What's the weather in miami")
workflow.add("Provide detauls for {{ parent_output }}") workflow.add("Provide details for {{ parent_output }}")
workflow.add("Summarize the above information: {{ parent_output}}") workflow.add("Summarize the above information: {{ parent_output}}")
workflow.run() workflow.run()

@ -28,7 +28,7 @@ class BaseTask(ABC):
self.structure = None self.structure = None
@property @property
@abstractmethod # @abstractmethod
def input(self): def input(self):
pass pass
@ -125,7 +125,7 @@ class BaseTask(ABC):
self.output = None self.output = None
return self return self
@abstractmethod # @abstractmethod
def run(self): def run(self):
pass pass

@ -5,23 +5,21 @@ from typing import Any, Dict, List, Optional
from swarms.artifacts.error_artifact import ErrorArtifact from swarms.artifacts.error_artifact import ErrorArtifact
from swarms.structs.task import BaseTask from swarms.structs.task import BaseTask
from dataclasses import dataclass
@dataclass
class StringTask(BaseTask): class StringTask(BaseTask):
task: str def __init__(self, task):
super().__init__()
self.task = task
def execute(self) -> Any: def execute(self) -> Any:
prompt = self.task_string.replace( prompt = self.task.replace(
"{{ parent_input }}", self.parents[0].output if self.parents else "" "{{ parent_input }}", self.parents[0].output if self.parents else ""
) )
response = self.structure.llm.run(prompt) response = self.structure.llm(prompt)
self.output = response self.output = response
return response return response
class Workflow: class Workflow:
""" """
Workflows are ideal for prescriptive processes that need to be executed Workflows are ideal for prescriptive processes that need to be executed

Loading…
Cancel
Save