🐝 GPTSwarm is a graph-based framework for LLM-based agents, providing two high-level features:
- It lets you build LLM-based agents from graphs.
- It enables the customized and automatic self-organization of agent swarms with self-improvement capabilities.
News
🚀 Feb 27, 2024: Our academic paper: Language Agents as Optimizable Graphs is released.
Edge optimization example
Here is the edge optimization process that updates edge probabilities toward improvement of the benchmark score. Notice that within an agent, the edges are fixed, whereas the inter-agent connections are getting optimized towards either edge pruning (value 0, blue) or creation (value 1, red).
About GPTSwarm
At a granular level, GPTSwarm is a library that includes the following components:
| Module | Description |
|---|---|
| swarm.environment | Domain-specific operations, agents, tools, and tasks |
| swarm.graph | Graph-related functions for creating and executing agent graphs and swarm composite graphs |
| swarm.llm | Interface for selecting LLM backends and calculating their operational costs |
| swarm.memory | Index-based memory |
| swarm.optimizer | Optimization algorithms designed to enhance agent performance and overall swarm efficiency |
Quickstart
Clone the repo
git clone https://github.com/metauto-ai/GPTSwarm.git
cd GPTSwarm/
Install packages
conda create -n swarm python=3.10
conda activate swarm
pip install poetry
poetry install
You should add API keys in .env.template and change its name to .env
OPENAI_API_KEY="" # for OpenAI LLM backend
SEARCHAPI_API_KEY="" # for Web Search
Getting started with GPTSwarm is easy. Quickly run a predefined swarm
from swarm.graph.swarm import Swarm
swarm = Swarm(["IO", "IO", "IO"], "gaia")
task = "What is the capital of Jordan?"
inputs = {"task": task}
answer = await swarm.arun(inputs)
or make use of tools, such as the file analyzer
from swarm.graph.swarm import Swarm
swarm = Swarm(["IO", "TOT"], "gaia")
task = "Tell me more about this image and summarize it in 3 sentences."
files = ["./datasets/demos/js.png"]
inputs = {"task": task, "files": files}
danswer = swarm.run(inputs)
Check out the minimal Swarm example in Colab here: .
See how to create a custom Agent and run a Swarm with it here: .
Here is a Youtube video on how to run the demo notebooks:
🛠 See our experiments for more advanced use of our framework.
Class diagram
Example of the Swarm
More Visualizations
Running with a local LLM
We support local LM inference via LM Studio. Download their desktop app for Mac or Windows, choose a model from the Huggingface repository and start the server. Use model_name='lmstudio' in GPTSwarm code to run with the local LLM.
Initial Contributors
- Mingchen Zhuge (PhD Student, KAUST; Project Initiator)
- Wenyi Wang (PhD Student, KAUST; Initial Participant)
- Dmitrii Khizbullin (Research Engineer Lead, KAUST; Project Engineer Lead)
- Louis Kirsch (PhD Student, IDSIA)
- Francesco Faccio (PostDoc, IDSIA; Visiting Researcher, KAUST)
- Jürgen Schmidhuber (Director, KAUST AI Initiative; Scientific Director, IDSIA)
Please read our developer document if you are interested in contributing.
Citation
Please cite our paper if you find the library useful or interesting.
@article{zhuge2024language,
title={Language Agents as Optimizable Graphs},
author={Zhuge, Mingchen and Wang, Wenyi and Kirsch, Louis and Faccio, Francesco and Khizbullin, Dmitrii and Schmidhuber, Jurgen},
journal={arXiv preprint arXiv:2402.16823},
year={2024}
}
Metadata
Release files for gptswarm 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gptswarm-0.1.0.tar.gz | 2.9 MB | Without provenance | Details for gptswarm-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gptswarm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for gptswarm-0.1.0-py3-none-any.whl |
Total release size: 5.9 MB
Release files / gptswarm-0.1.0.tar.gz
| Download URL | gptswarm-0.1.0.tar.gz |
|---|---|
| Size | 2.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
343bffda4217c090da1f4c9b2dc5002504050b74d6b967e08a847d7996ad8587
|
|
BLAKE2b-256 checksum How to use checksums |
8025157aa47ad8d7eaee800c95163d64e3cf66a55bc3e0f258018be9b16e8fdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.10.13 Darwin/23.3.0
|
Release files / gptswarm-0.1.0-py3-none-any.whl
| Download URL | gptswarm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 2.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a77d4db24269ca96f78ae7aeb3d0c756f562156fc7bd924deaba45787b1382c5
|
|
BLAKE2b-256 checksum How to use checksums |
6147e452968b69c7616530138b19fab77e059ad8596c2cef97573740ee99a616
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.10.13 Darwin/23.3.0
|
Security for gptswarm 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.