diff --git a/docs/assets/img/swarmbanner.png b/docs/assets/img/swarmbanner.png new file mode 100644 index 00000000..f88646db Binary files /dev/null and b/docs/assets/img/swarmbanner.png differ diff --git a/docs/corporate/swarm_memo.md b/docs/corporate/swarm_memo.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/index.md b/docs/index.md index 11f532ab..1e32b32c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,19 +1,74 @@ -# Swarms Docs +
+

+ + + +

+
-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/) diff --git a/mkdocs.yml b/mkdocs.yml index 145e49eb..e2e913a9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -160,4 +160,5 @@ nav: - Architecture: "corporate/architecture.md" - Checklist: "corporate/checklist.md" - Hiring: "corporate/hiring.md" - - SwarmCloud: "corporate/swarm_cloud.md" \ No newline at end of file + - SwarmCloud: "corporate/swarm_cloud.md" + - SwarmMemo: "corporate/swarm_memo.md" \ No newline at end of file diff --git a/swarms/structs/swarming_architectures.py b/swarms/structs/swarming_architectures.py new file mode 100644 index 00000000..0ea84fb4 --- /dev/null +++ b/swarms/structs/swarming_architectures.py @@ -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) \ No newline at end of file