diff --git a/swarms/models/supervision.py b/swarms/models/supervision.py deleted file mode 100644 index e69de29b..00000000 diff --git a/swarms/structs/concurrent_workflow.py b/swarms/structs/concurrent_workflow.py index e3f64c9a..31e1200d 100644 --- a/swarms/structs/concurrent_workflow.py +++ b/swarms/structs/concurrent_workflow.py @@ -43,7 +43,7 @@ class ConcurrentWorkflow(BaseStructure): return_results: bool = False use_processes: bool = False - def add(self, task: Task, tasks: List[Task] = None): + def add(self, task: Task = None): """Adds a task to the workflow. Args: @@ -51,11 +51,7 @@ class ConcurrentWorkflow(BaseStructure): tasks (List[Task]): _description_ """ try: - if tasks: - for task in tasks: - self.tasks.append(task) - else: - self.tasks.append(task) + self.tasks.append(task) except Exception as error: print(f"[ERROR][ConcurrentWorkflow] {error}") raise error diff --git a/swarms/structs/conversation.py b/swarms/structs/conversation.py index 8368cd52..71923cef 100644 --- a/swarms/structs/conversation.py +++ b/swarms/structs/conversation.py @@ -1,3 +1,4 @@ +import os import datetime import json @@ -70,8 +71,8 @@ class Conversation(BaseStructure): self, time_enabled: bool = False, database: AbstractDatabase = None, - autosave: bool = True, - save_filepath: str = "runs/conversation.json", + autosave: bool = None, + save_filepath: str = None, *args, **kwargs, ): @@ -228,6 +229,9 @@ class Conversation(BaseStructure): Args: filename (str): Save the conversation history as a JSON file """ + # Create the directory if it does not exist + os.makedirs(os.path.dirname(filename), exist_ok=True) + # Save the conversation history as a JSON file with open(filename, "w") as f: json.dump(self.conversation_history, f) diff --git a/swarms/structs/swarming_architectures.py b/swarms/structs/swarming_architectures.py index 0ea84fb4..a6ccdf9b 100644 --- a/swarms/structs/swarming_architectures.py +++ b/swarms/structs/swarming_architectures.py @@ -112,50 +112,50 @@ def power_swarm(agents: List[str], tasks: List[str]): def log_swarm(agents: List[Agent], tasks: List[str]): for i in range(len(agents)): - if 2 ** i < len(agents) and tasks: + if 2**i < len(agents) and tasks: task = tasks.pop(0) - agents[2 ** i].run(task) - + agents[2**i].run(task) + def exponential_swarm(agents: List[Agent], tasks: List[str]): for i in range(len(agents)): - index = min( - int(2 ** i), - len(agents)-1 - ) + index = min(int(2**i), len(agents) - 1) if tasks: task = tasks.pop(0) agents[index].run(task) - + + def geometric_swarm(agents, tasks): ratio = 2 for i in range(range(len(agents))): - index = min(int(ratio ** 2), len(agents)-1) + index = min(int(ratio**2), len(agents) - 1) if tasks: task = tasks.pop(0) agents[index].run(task) - - + + def harmonic_swarm(agents: List[Agent], tasks: List[str]): for i in range(1, len(agents) + 1): - index = min(int(len(agents)/i), len(agents) -1) + index = min(int(len(agents) / i), len(agents) - 1) if tasks: task = tasks.pop(0) agents[index].run(task) - + + def staircase_swarm(agents: List[Agent], task: str): step = len(agents) // 5 for i in range(len(agents)): index = (i // step) * step agents[index].run(task) - + def sigmoid_swarm(agents: List[Agent], task: str): for i in range(len(agents)): index = int(len(agents) / (1 + math.exp(-i))) agents[index].run(task) - + + def sinusoidal_swarm(agents: List[Agent], task: str): for i in range(len(agents)): index = int((math.sin(i) + 1) / 2 * len(agents)) - agents[index].run(task) \ No newline at end of file + agents[index].run(task)