From bc4d8ac3635d1bd163ec02e5d2a3f06808de292a Mon Sep 17 00:00:00 2001 From: Arsenii Shatokhin Date: Thu, 1 Feb 2024 08:25:17 +0400 Subject: [PATCH] Added check when loading instructions from file --- agency_swarm/agents/agent.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/agency_swarm/agents/agent.py b/agency_swarm/agents/agent.py index 35b55ea1..1bc90792 100644 --- a/agency_swarm/agents/agent.py +++ b/agency_swarm/agents/agent.py @@ -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: