[PROTOTYPE][Swarm Architectures] [DOCS][Fix]

pull/347/head
Kye 1 year ago
parent a4b91ca02f
commit 6c21fc2421

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 KiB

@ -1,19 +1,74 @@
# Swarms Docs
<div align="center">
<p>
<a align="center" href="" target="_blank">
<img
width="850"
src="https://github.com/kyegomez/swarms/raw/master/images/swarmslogobanner.png"
>
</a>
</p>
</div>
Welcome to Swarm's Documentation!
## 👋 Hello
Swarms is a modular framework that enables reliable and useful multi-agent collaboration at scale to automate real-world tasks.
Swarms provides you with all the building blocks you need to build reliable, production-grade, and scalable multi-agent apps!
Swarms is transforming the landscape of AI from siloed AI agents to a unified 'swarm' of intelligence. Through relentless iteration and the power of collective insight from our 1500+ Agora researchers, we're developing a groundbreaking framework for AI collaboration. Our mission is to catalyze a paradigm shift, advancing Humanity with the power of unified autonomous AI agent swarms.
## 💻 Install
You can install `swarms` with pip in a
[**Python>=3.8**](https://www.python.org/) environment.
This documentation covers the fundamentals of the **Swarms** framework and describes how to use **Swarms Tools**.
!!! example "pip install (recommended)"
## Swarms
=== "headless"
The headless installation of `swarms` is designed for environments where graphical user interfaces (GUI) are not needed, making it more lightweight and suitable for server-side applications.
The Swarms framework provides developers with the ability to create AI systems that operate across two dimensions: predictability and creativity. For predictability, Swarms enforces structures like sequential pipelines, DAG-based workflows, and long-term memory. To facilitate creativity, Swarms safely prompts LLMs with [tools](https://github.com/kyegomez/swarms-tools) and short-term memory connecting them to external APIs and data stores. The framework allows developers to transition between those two dimensions effortlessly based on their use case.
```bash
pip install swarms
```
Swarms not only helps developers harness the potential of LLMs but also enforces trust boundaries, schema validation, and tool activity-level permissions. By doing so, Swarms maximizes LLMs reasoning while adhering to strict policies regarding their capabilities.
!!! example "git clone (for development)"
=== "virtualenv"
```bash
# clone repository and navigate to root directory
git clone https://github.com/kyegomez/swarms.git
cd swarms
# setup python environment and activate it
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
# headless install
pip install -e "."
# desktop install
pip install -e ".[desktop]"
```
=== "poetry"
```bash
# clone repository and navigate to root directory
git clone https://github.com/roboflow/swarms.git
cd swarms
# setup python environment and activate it
poetry env use python3.10
poetry shell
# headless install
poetry install
# desktop install
poetry install --extras "desktop"
```
## Documentation
[Learn more about swarms →](swarms/)

@ -160,4 +160,5 @@ nav:
- Architecture: "corporate/architecture.md"
- Checklist: "corporate/checklist.md"
- Hiring: "corporate/hiring.md"
- SwarmCloud: "corporate/swarm_cloud.md"
- SwarmCloud: "corporate/swarm_cloud.md"
- SwarmMemo: "corporate/swarm_memo.md"

@ -0,0 +1,161 @@
import math
from typing import List
from swarms.structs.agent import Agent
def circular_swarm(agents: List[Agent], tasks: List[str]):
ball = 0
while tasks:
task = tasks.pop(0)
agents[ball].run(task)
ball = (ball + 1) % len(agents)
def linear_swarm(agents: List[Agent], tasks: List[str]):
for i in range(len(agents)):
if tasks:
task = tasks.pop(0)
agents[i].run(task)
def star_swarm(agents: List[Agent], tasks: List[str]):
center_agent = agents[0]
for task in tasks:
center_agent.run(task)
for agent in agents[1:]:
agent.run(task)
def mesh_swarm(agents: List[Agent], tasks: List[str]):
task_queue = tasks.copy()
while task_queue:
for agent in agents:
if task_queue:
task = task_queue.pop(0)
agent.run(task)
def grid_swarm(agents: List[Agent], tasks: List[str]):
grid_size = int(
len(agents) ** 0.5
) # Assuming agents can form a perfect square grid
for i in range(grid_size):
for j in range(grid_size):
if tasks:
task = tasks.pop(0)
agents[i * grid_size + j].run(task)
def pyramid_swarm(agents: List[Agent], tasks: List[str]):
levels = int(
(-1 + (1 + 8 * len(agents)) ** 0.5) / 2
) # Assuming agents can form a perfect pyramid
for i in range(levels):
for j in range(i + 1):
if tasks:
task = tasks.pop(0)
agents[int(i * (i + 1) / 2 + j)].run(task)
def fibonacci_swarm(agents: List[Agent], tasks: List[str]):
fib = [1, 1]
while len(fib) < len(agents):
fib.append(fib[-1] + fib[-2])
for i in range(len(fib)):
for j in range(fib[i]):
if tasks:
task = tasks.pop(0)
agents[int(sum(fib[:i]) + j)].run(task)
def prime_swarm(agents: List[Agent], tasks: List[str]):
primes = [
2,
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
] # First 25 prime numbers
for prime in primes:
if prime < len(agents) and tasks:
task = tasks.pop(0)
agents[prime].run(task)
def power_swarm(agents: List[str], tasks: List[str]):
powers = [2**i for i in range(int(len(agents) ** 0.5))]
for power in powers:
if power < len(agents) and tasks:
task = tasks.pop(0)
agents[power].run(task)
def log_swarm(agents: List[Agent], tasks: List[str]):
for i in range(len(agents)):
if 2 ** i < len(agents) and tasks:
task = tasks.pop(0)
agents[2 ** i].run(task)
def exponential_swarm(agents: List[Agent], tasks: List[str]):
for i in range(len(agents)):
index = min(
int(2 ** i),
len(agents)-1
)
if tasks:
task = tasks.pop(0)
agents[index].run(task)
def geometric_swarm(agents, tasks):
ratio = 2
for i in range(range(len(agents))):
index = min(int(ratio ** 2), len(agents)-1)
if tasks:
task = tasks.pop(0)
agents[index].run(task)
def harmonic_swarm(agents: List[Agent], tasks: List[str]):
for i in range(1, len(agents) + 1):
index = min(int(len(agents)/i), len(agents) -1)
if tasks:
task = tasks.pop(0)
agents[index].run(task)
def staircase_swarm(agents: List[Agent], task: str):
step = len(agents) // 5
for i in range(len(agents)):
index = (i // step) * step
agents[index].run(task)
def sigmoid_swarm(agents: List[Agent], task: str):
for i in range(len(agents)):
index = int(len(agents) / (1 + math.exp(-i)))
agents[index].run(task)
def sinusoidal_swarm(agents: List[Agent], task: str):
for i in range(len(agents)):
index = int((math.sin(i) + 1) / 2 * len(agents))
agents[index].run(task)
Loading…
Cancel
Save