Skip to content

Commit

Permalink
Added ReadRequirements tool to genesis agency
Browse files Browse the repository at this point in the history
  • Loading branch information
VRSEN committed Mar 22, 2024
1 parent 946a934 commit 9edfea6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion agency_swarm/agency/genesis/GenesisCEO/GenesisCEO.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from agency_swarm import Agent
from .tools.CreateAgencyFolder import CreateAgencyFolder
from .tools.FinalizeAgency import FinalizeAgency
from .tools.ReadRequirements import ReadRequirements


class GenesisCEO(Agent):
Expand All @@ -13,7 +14,7 @@ def __init__(self, **kwargs):
kwargs['description'] = "Acts as the overseer and communicator across the agency, ensuring alignment with the agency's goals."

# Add required tools
kwargs['tools'].extend([CreateAgencyFolder, FinalizeAgency])
kwargs['tools'].extend([CreateAgencyFolder, FinalizeAgency, ReadRequirements])

# Set instructions
kwargs['instructions'] = "./instructions.md"
Expand Down
28 changes: 28 additions & 0 deletions agency_swarm/agency/genesis/GenesisCEO/tools/ReadRequirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from agency_swarm.tools import BaseTool
from pydantic import Field
import os


class ReadRequirements(BaseTool):
"""
Use this tool to read the agency requirements if user provides them as a file.
"""

file_path: str = Field(
..., description="The path to the file that needs to be read."
)

def run(self):
"""
Checks if the file exists, and if so, opens the specified file, reads its contents, and returns them.
If the file does not exist, raises a ValueError.
"""
if not os.path.exists(self.file_path):
raise ValueError(f"File path does not exist: {self.file_path}")

try:
with open(self.file_path, 'r', encoding='utf-8') as file:
content = file.read()
return content
except Exception as e:
return f"An error occurred while reading the file: {str(e)}"

0 comments on commit 9edfea6

Please sign in to comment.