fix: append new tasks to the end of the list (#2737)

fix: append new tasks to the end of the list
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-07-16 16:12:22 -03:00 committed by GitHub
commit e5856b3036
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,7 +54,7 @@ class SequentialTaskComponent(Component):
]
def build_task(self) -> list[SequentialTask]:
tasks = []
tasks: list[SequentialTask] = []
task = SequentialTask(
description=self.task_description,
expected_output=self.expected_output,
@ -65,8 +65,8 @@ class SequentialTaskComponent(Component):
tasks.append(task)
self.status = task
if self.task:
if isinstance(self.task, list):
tasks.extend(self.task)
else:
tasks.append(self.task)
if isinstance(self.task, list) and all(isinstance(task, SequentialTask) for task in self.task):
tasks = self.task + tasks
elif isinstance(self.task, SequentialTask):
tasks = [self.task] + tasks
return tasks