[BUFG][[BUG] FileNotFoundError: [Errno 2] No such file or directory: 'runs/conversation.json' #350]

pull/352/head
Kye 1 year ago
parent b48b405f28
commit 4abf987929

@ -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

@ -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)

@ -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)

Loading…
Cancel
Save