Skip to content

Commit

Permalink
Merge branch 'main' into pr/bonk1t/188
Browse files Browse the repository at this point in the history
  • Loading branch information
VRSEN committed Dec 4, 2024
2 parents 0b0de93 + dbd0299 commit 3a9a295
Show file tree
Hide file tree
Showing 127 changed files with 3,883 additions and 2,048 deletions.
320 changes: 199 additions & 121 deletions .cursorrules

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: docs
on:
push:
branches:
- master
- master
- main
permissions:
contents: write
Expand All @@ -23,12 +23,12 @@ jobs:
with:
python-version: "3.10"

- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install -r requirements-docs.txt
- run: mkdocs gh-deploy --force
- run: mkdocs gh-deploy --force
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ cython_debug/
settings.json
.DS_Store
tests/test_agents/
test_agents/
test_agents/
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 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.
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.

Expand Down Expand Up @@ -157,4 +157,4 @@ class AgentName(Agent):

---

Thank you for contributing to Agency Swarm! Your efforts help us build a more robust and versatile framework.
Thank you for contributing to Agency Swarm! Your efforts help us build a more robust and versatile framework.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,40 @@ Define your custom tools by extending the `BaseTool` class:
from agency_swarm.tools import BaseTool
from pydantic import Field


class MyCustomTool(BaseTool):
"""
A brief description of what the custom tool does.
A brief description of what the custom tool does.
The docstring should clearly explain the tool's purpose and functionality.
It will be used by the agent to determine when to use this tool.
"""


# Define the fields with descriptions using Pydantic Field
example_field: str = Field(
..., description="Description of the example field, explaining its purpose and usage for the Agent."
)
# Additional fields as required
# ...


def run(self):
"""
The implementation of the run method, where the tool's main functionality is executed.
"""
# Your custom tool logic goes here
do_something(self.example_field)


# Return the result of the tool's operation
return "Result of MyCustomTool operation"
```


or convert from OpenAPI schemas:


```python
from agency_swarm.tools import ToolFactory
# using local file
Expand All @@ -77,6 +84,7 @@ Define your custom tools by extending the `BaseTool` class:
f.read(),
)


# using requests
tools = ToolFactory.from_openapi_schema(
requests.get("https://api.example.com/openapi.json").json(),
Expand Down Expand Up @@ -107,9 +115,11 @@ Define your custom tools by extending the `BaseTool` class:
agency-swarm import-agent --name "Devid" --destination "./"
```


This will import Devid (Software Developer) Agent locally, including all source code files, so you have full control over your system. Currently, available agents are: `Devid`, `BrowsingAgent`.


4. **Define Agency Communication Flows**:
4. **Define Agency Communication Flows**:
Establish how your agents will communicate with each other.

Expand All @@ -119,9 +129,11 @@ Establish how your agents will communicate with each other.
from Developer import Developer
from VirtualAssistant import VirtualAssistant


dev = Developer()
va = VirtualAssistant()


agency = Agency([
ceo, # CEO will be the entry point for communication with the user
[ceo, dev], # CEO can initiate communication with Developer
Expand All @@ -136,23 +148,29 @@ Establish how your agents will communicate with each other.

In Agency Swarm, communication flows are directional, meaning they are established from left to right in the agency_chart definition. For instance, in the example above, the CEO can initiate a chat with the developer (dev), and the developer can respond in this chat. However, the developer cannot initiate a chat with the CEO. The developer can initiate a chat with the virtual assistant (va) and assign new tasks.

5. **Run Demo**:
5. **Run Demo**:
Run the demo to see your agents in action!


Web interface:

```python
agency.demo_gradio(height=900)
```


Terminal version:


```python
agency.run_demo()
```


Backend version:


```python
completion_output = agency.get_completion("Please create a new website for our client.")
```
Expand Down Expand Up @@ -208,11 +226,13 @@ When you run the `create-agent-template` command, it creates the following folde
├── files/ # Directory for files that will be uploaded to openai
├── schemas/ # Directory for OpenAPI schemas to be converted into tools
├── tools/ # Directory for tools to be imported by default.
├── tools/ # Directory for tools to be imported by default.
├── 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 # 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
5 changes: 1 addition & 4 deletions agency_swarm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from .agency import Agency
from .agents import Agent
from .tools import BaseTool
from .util import set_openai_key
from .util import set_openai_client
from .util import get_openai_client
from .util import get_openai_client, llm_validator, set_openai_client, set_openai_key
from .util.streaming import AgencyEventHandler
from .util import llm_validator
Loading

0 comments on commit 3a9a295

Please sign in to comment.