AI prompts
base on The only reliable agent framework built on top of the latest OpenAI Assistants API. # š Agency Swarm
![Framework](https://firebasestorage.googleapis.com/v0/b/vrsen-ai/o/public%2Fgithub%2Fagency-swarm-logo-white.png?alt=media&token=76d8615d-1211-426a-bd4f-b9098cbfbc43)
## Overview
Agency Swarm started as a desire and effort of Arsenii Shatokhin (aka VRSEN) to fully automate his AI Agency with AI. By building this framework, we aim to simplify the agent creation process and enable anyone to create collaborative swarm of agents (Agencies), each with distinct roles and capabilities. By thinking about automation in terms of real world entities, such as agencies and specialized agent roles, we make it a lot more intuitive for both the agents and the users.
[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1qGVyK-vIoxZD0dMrMVqCxCsgL1euMLKj)
[![Docs](https://img.shields.io/website?label=Docs&up_message=available&url=https://vrsen.github.io/agency-swarm/)](https://vrsen.github.io/agency-swarm/)
[![Subscribe on YouTube](https://img.shields.io/youtube/channel/subscribers/UCSv4qL8vmoSH7GaPjuqRiCQ
)](https://youtube.com/@vrsen/)
[![Follow on Twitter](https://img.shields.io/twitter/follow/__vrsen__.svg?style=social&label=Follow%20%40__vrsen__)](https://twitter.com/__vrsen__)
[![Join our Discord!](https://img.shields.io/discord/1200037936352202802?label=Discord)](https://discord.gg/cw2xBaWfFM)
[![Agents-as-a-Service](https://img.shields.io/website?label=Agents-as-a-Service&up_message=For%20Business&url=https%3A%2F%2Fvrsen.ai)](https://agents.vrsen.ai)
### Key Features
- **Customizable Agent Roles**: Define roles like CEO, virtual assistant, developer, etc., and customize their functionalities with [Assistants API](https://platform.openai.com/docs/assistants/overview).
- **Full Control Over Prompts**: Avoid conflicts and restrictions of pre-defined prompts, allowing full customization.
- **Tool Creation**: Tools within Agency Swarm are created using [Instructor](https://github.com/jxnl/instructor), which provides a convenient interface and automatic type validation.
- **Efficient Communication**: Agents communicate through a specially designed "send message" tool based on their own descriptions.
- **State Management**: Agency Swarm efficiently manages the state of your assistants on OpenAI, maintaining it in a special `settings.json` file.
- **Deployable in Production**: Agency Swarm is designed to be reliable and easily deployable in production environments.
## Installation
```bash
pip install -U agency-swarm
```
## Getting Started
1. **Set Your OpenAI Key**:
```python
from agency_swarm import set_openai_key
set_openai_key("YOUR_API_KEY")
```
2. **Create Tools**:
Define your custom tools with [Instructor](https://github.com/jxnl/instructor):
```python
from agency_swarm.tools import BaseTool
from pydantic import Field
class MyCustomTool(BaseTool):
"""
A brief description of what the custom tool does.
The docstring should clearly explain the tool's purpose and functionality.
"""
# Define the fields with descriptions using Pydantic Field
example_field: str = Field(
..., description="Description of the example field, explaining its purpose and usage."
)
# Additional fields as required
# ...
def run(self):
"""
The implementation of the run method, where the tool's main functionality is executed.
This method should utilize the fields defined above to perform its task.
Doc string description is not required for this method.
"""
# 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
with open("schemas/your_schema.json") as f:
tools = ToolFactory.from_openapi_schema(
f.read(),
)
# using requests
tools = ToolFactory.from_openapi_schema(
requests.get("https://api.example.com/openapi.json").json(),
)
```
3. **Define Agent Roles**: Start by defining the roles of your agents. For example, a CEO agent for managing tasks and a developer agent for executing tasks.
```python
from agency_swarm import Agent
ceo = Agent(name="CEO",
description="Responsible for client communication, task planning and management.",
instructions="You must converse with other agents to ensure complete task execution.", # can be a file like ./instructions.md
files_folder="./files", # files to be uploaded to OpenAI
schemas_folder="./schemas", # OpenAPI schemas to be converted into tools
tools=[MyCustomTool],
temperature=0.5, # temperature for the agent
max_prompt_tokens=25000, # max tokens in conversation history
)
```
Import from existing agents:
```bash
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**:
Establish how your agents will communicate with each other.
```python
from agency_swarm import Agency
# if importing from local files
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
[ceo, va], # CEO can initiate communication with Virtual Assistant
[dev, va] # Developer can initiate communication with Virtual Assistant
],
shared_instructions='agency_manifesto.md', #shared instructions for all agents
temperature=0.5, # default temperature for all agents
max_prompt_tokens=25000 # default max tokens in conversation history
)
```
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**:
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.")
```
# CLI
## Genesis Agency
The `genesis` command starts the genesis agency in your terminal to help you create new agencies and agents.
#### **Command Syntax:**
```bash
agency-swarm genesis [--openai_key "YOUR_API_KEY"]
```
Make sure to include:
- Your mission and goals.
- The agents you want to involve and their communication flows.
- Which tools or APIs each agent should have access to, if any.
## Importing Existing Agents
This CLI command allows you to import existing agents from local files into your agency.
#### **Command Syntax:**
```bash
agency-swarm import-agent --name "AgentName" --destination "/path/to/directory"
```
To check available agents, simply run this command without any arguments.
## Creating Agent Templates Locally
This CLI command simplifies the process of creating a structured environment for each agent.
#### **Command Syntax:**
```bash
agency-swarm create-agent-template --name "AgentName" --description "Agent Description" [--path "/path/to/directory"] [--use_txt]
```
### Folder Structure
When you run the `create-agent-template` command, it creates the following folder structure for your agent:
```
/your-specified-path/
ā
āāā 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
āāā schemas/ # Directory for OpenAPI schemas to be converted into tools
āāā 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.
## Future Enhancements
1. [x] Creation of agencies that can autonomously create other agencies.
2. [x] Asynchronous communication and task handling.
3. [ ] Inter-agency communication for a self-expanding system.
## Contributing
For details on how to contribute you agents and tools to Agency Swarm, please refer to the [Contributing Guide](CONTRIBUTING.md).
## License
Agency Swarm is open-source and licensed under [MIT](https://opensource.org/licenses/MIT).
## Need Help?
If you need help creating custom agent swarms for your business, check out our [Agents-as-a-Service](https://agents.vrsen.ai/) subscription, or schedule a consultation with me at https://calendly.com/vrsen/ai-project-consultation
", Assign "at most 3 tags" to the expected json: {"id":"6411","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"