Skip to content

Commit

Permalink
[BUFG][[BUG] FileNotFoundError: [Errno 2] No such file or directory: …
Browse files Browse the repository at this point in the history
…'runs/conversation.json' #350]
  • Loading branch information
Kye committed Jan 11, 2024
1 parent b48b405 commit 4abf987
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
Empty file removed swarms/models/supervision.py
Empty file.
8 changes: 2 additions & 6 deletions swarms/structs/concurrent_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,15 @@ 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:
task (Task): _description_
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
Expand Down
8 changes: 6 additions & 2 deletions swarms/structs/conversation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import datetime
import json

Expand Down Expand Up @@ -70,8 +71,8 @@ def __init__(
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,
):
Expand Down Expand Up @@ -228,6 +229,9 @@ def save_as_json(self, filename: str):
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)
Expand Down
32 changes: 16 additions & 16 deletions swarms/structs/swarming_architectures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
agents[index].run(task)

0 comments on commit 4abf987

Please sign in to comment.