Skip to content

Commit

Permalink
Added check when loading instructions from file
Browse files Browse the repository at this point in the history
  • Loading branch information
VRSEN committed Feb 1, 2024
1 parent ba4ea59 commit bc4d8ac
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions agency_swarm/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,16 @@ def get_settings_path(self):
return self.settings_path

def _read_instructions(self):
class_path = os.path.normpath(os.path.join(self.get_class_folder_path(), self.instructions))
class_instructions_path = os.path.normpath(os.path.join(self.get_class_folder_path(), self.instructions))
if os.path.isfile(self.instructions):
with open(self.instructions, 'r') as f:
self.instructions = f.read()
elif os.path.isfile(class_path):
with open(class_path, 'r') as f:
elif os.path.isfile(class_instructions_path):
with open(class_instructions_path, 'r') as f:
self.instructions = f.read()
elif "./instructions.md" in self.instructions or "./instructions.txt" in self.instructions:
raise Exception("Instructions file not found.")


def get_class_folder_path(self):
try:
Expand Down

0 comments on commit bc4d8ac

Please sign in to comment.