Skip to content

Commit

Permalink
Fix output issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed Apr 23, 2023
1 parent 58afa2c commit 7c667d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion AgentLLM.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get_status(self):
def initialize_task_list(self):
self.task_list = deque([])

def update_output_list(self, task_id, output):
def update_output_list(self, output, task_id=None):
self.CFG.save_task_output(self.agent_name, task_id, output)

def display_objective_and_initial_task(self):
Expand Down
10 changes: 8 additions & 2 deletions Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import importlib
import yaml
import uuid
from pathlib import Path
from dotenv import load_dotenv
from inspect import signature, Parameter
Expand Down Expand Up @@ -279,7 +280,10 @@ def update_agent_config(self, agent_name, config):
with open(os.path.join("agents", agent_name, "config.json"), "w") as agent_config:
json.dump(config, agent_config)

def get_task_output(self, agent_name, task_id):
def get_task_output(self, agent_name, task_id=None):
if task_id is None:
# Get the latest task
task_id = sorted(os.listdir(os.path.join("agents", agent_name, "tasks")))[-1].replace(".txt", "")
task_output_file = os.path.join("agents", agent_name, "tasks", f"{task_id}.txt")
if os.path.exists(task_output_file):
with open(task_output_file, "r") as f:
Expand All @@ -288,7 +292,9 @@ def get_task_output(self, agent_name, task_id):
task_output = ""
return task_output

def save_task_output(self, agent_name, task_id, task_output):
def save_task_output(self, agent_name, task_output, task_id=None):
if task_id is None:
task_id = str(uuid.uuid4())
if not os.path.exists(os.path.join("agents", agent_name, "tasks")):
os.makedirs(os.path.join("agents", agent_name, "tasks"))
task_output_file = os.path.join("agents", agent_name, "tasks", f"{task_id}.txt")
Expand Down

0 comments on commit 7c667d6

Please sign in to comment.