Skip to content

Commit

Permalink
Added CONTRIBUTING.md and tests file for tools
Browse files Browse the repository at this point in the history
  • Loading branch information
VRSEN committed Jan 13, 2024
2 parents 640345e + 71e4de8 commit 192961b
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 4 deletions.
77 changes: 77 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Contributing to Agency Swarm
Each agent or tool you add to Agency Swarm will automatically be available for import by the Genesis Swarm, which will help us create an exponentially larger and smarter system.

This document provides guidelines for contributing new agents and tools to the framework.

## Folder Structure for Tools

1. Tools should be added in the `agency_swarm/tools/{category}/` directory like below.
2. Each tool should be in its specific category folder like `coding`, `browsing`, `investing` etc.
3. Your tool file should be named `YourNewTool.py`.
4. Tests should be added in `agency_swarm/tests/test_tools.py`.


Directory structure for a new tool:
```
agency_swarm/tools/your-tool-category/
├── YourNewTool.py # The main agent class file
└── __init__.py # Make sure to import your tool here
```

### Adding Tests For Your Tools
For each tool, please add the following test case in `agency_swarm/tests/test_tools.py`:

```python
def test_my_tool_example(self):
output = MyCustomTool(query='John Doe').run()
self.assertFalse("error" in output.lower())
```

## Folder Structure for Agents

1. Agents should be placed in `agency_swarm/agents/{category}/` directory.
2. Each agent should have its dedicated folder named `AgentName` like below.
3. Make sure to use **CamelCase** for the agent name and the folder.

```
agency_swarm/agents/your-agent-category/AgentName/
├── agency_manifesto.md or .txt # Agency's guiding principles (created if not exists)
└── AgentName/ # Directory for the specific agent
├── files/ # Directory for files that will be uploaded to openai (if any)
├── schemas/ # Directory for OpenAPI schemas to be converted into tools (if any)
├── AgentName.py # The main agent class file
├── __init__.py # Initializes the agent folder as a Python package
└── instructions.md # Instruction document for the agent
```

### Creating an Agent

1. Follow the structure below in your `AgentName.py` as a guideline.
2. All tools (except schemas) should be imported in `AgentName.py` from the `agency_swarm/tools/...` folder.

```python
from agency_swarm import Agent
from agency_swarm.tools.example import ExampleTool

class AgentName(Agent):
def __init__(self, **kwargs):
# Initialize tools in kwargs if not present
if 'tools' not in kwargs:
kwargs['tools'] = []
# Add required tools
kwargs['tools'].extend([ExampleTool])

# Set instructions
kwargs['instructions'] = "./instructions.md"

# Add more kwargs as needed

# Initialize the parent class
super().__init__(**kwargs)
```

---

Thank you for contributing to Agency Swarm! Your efforts help us build a more robust and versatile framework.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ When you run the `create-agent-template` command, it creates the following folde
/your-specified-path/
├── agency_manifesto.md or .txt # Agency's guiding principles (created if not exists)
└── agent_name/ # Directory for the specific agent
├── agent_name.py # The main agent class file
└── AgentName/ # Directory for the specific agent
├── files/ # Directory for files that will be uploaded to openai
├── schemas/ # Directory for OpenAPI schemas to be converted into tools
├── AgentName.py # The main agent class file
├── __init__.py # Initializes the agent folder as a Python package
├── instructions.md or .txt # Instruction document for the agent
── tools.py # Tools specific to the agent
├── files/ # Directory for additional resources
── tools.py # Custom tools specific to the agent
```

This structure ensures that each agent has its dedicated space with all necessary files to start working on its specific tasks. The `tools.py` can be customized to include tools and functionalities specific to the agent's role.
Expand Down
13 changes: 13 additions & 0 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unittest

from agency_swarm.tools.coding import ChangeDir


class ToolsTest(unittest.TestCase):
def test_change_dir_example(self):
output = ChangeDir(path="./").run()
self.assertFalse("error" in output.lower())


if __name__ == '__main__':
unittest.main()

0 comments on commit 192961b

Please sign in to comment.