{"id":13644986,"url":"https://github.com/metauto-ai/gptswarm","last_synced_at":"2026-04-06T01:02:37.492Z","repository":{"id":224621258,"uuid":"763733771","full_name":"metauto-ai/GPTSwarm","owner":"metauto-ai","description":"🐝 GPTSwarm: LLM agents as (Optimizable) Graphs ","archived":false,"fork":false,"pushed_at":"2025-01-03T07:42:52.000Z","size":19721,"stargazers_count":820,"open_issues_count":2,"forks_count":59,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-05T08:35:22.781Z","etag":null,"topics":["agent","ai","gpt","multi-agent","python","reinforcement-learning","self-improvement","society-of-mind","swarm-intelligence"],"latest_commit_sha":null,"homepage":"https://gptswarm.org","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metauto-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-26T20:29:59.000Z","updated_at":"2025-04-02T07:48:16.000Z","dependencies_parsed_at":"2024-07-08T21:23:40.175Z","dependency_job_id":"15dedba9-ca1a-4eb1-9d5c-c0a66c458afd","html_url":"https://github.com/metauto-ai/GPTSwarm","commit_stats":null,"previous_names":["metauto-ai/gptswarm"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metauto-ai%2FGPTSwarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metauto-ai%2FGPTSwarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metauto-ai%2FGPTSwarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metauto-ai%2FGPTSwarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metauto-ai","download_url":"https://codeload.github.com/metauto-ai/GPTSwarm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250047972,"owners_count":21366149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai","gpt","multi-agent","python","reinforcement-learning","self-improvement","society-of-mind","swarm-intelligence"],"created_at":"2024-08-02T01:02:23.205Z","updated_at":"2025-12-14T18:04:49.457Z","avatar_url":"https://github.com/metauto-ai.png","language":"Python","readme":"[![Page](https://img.shields.io/badge/Project-Page-lightgreen.svg)](https://gptswarm.org)\n[![arXiv](https://img.shields.io/badge/arXiv-Paper-gold.svg)](https://arxiv.org/abs/2402.16823)\n[![License](https://img.shields.io/badge/License-MIT-orange.svg)](https://github.com/metauto-ai/GPTSwarm/blob/main/LICENSE)\n[![Issues](https://img.shields.io/github/issues/metauto-ai/GPTSwarm?color=00afaa)](https://github.com/metauto-ai/gptswarm/issues)\n[![Twitter Follow](https://img.shields.io/twitter/follow/Mingchen?style=social)](https://x.com/MingchenZhuge)\n[![Wechat](https://img.shields.io/badge/Wechat-7BB32E?logo=wechat\u0026logoColor=white)](https://metauto.ai/images/wechat.jpeg)\n[![Coverage Status](https://coveralls.io/repos/github/metauto-ai/GPTSwarm/badge.svg?branch=main)](https://coveralls.io/github/metauto-ai/GPTSwarm?branch=main)\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"\"\u003e\u003cimg src=\"swarm/utils/assets/logo.png\" alt=\"GPTSwarm\" width=\"430px\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n🐝 **GPTSwarm is a graph-based framework for LLM-based agents, providing two high-level features:**\n\n* It lets you build LLM-based agents from graphs.\n* It enables the customized and automatic self-organization of agent swarms with self-improvement capabilities.\n\n## About GPTSwarm\n\n\u003cimg src=\"assets/gpt_swarm.png\" alt=\"Framework\" width=\"799\"\u003e\n\nAt a granular level, GPTSwarm is a library that includes the following components: \n\n\n| Module | Description |\n| ---- | --- |\n| [**swarm.environment**](swarm/environment) | Domain-specific operations, agents, tools, and tasks |\n| [**swarm.graph**](swarm/graph) | Graph-related functions for creating and executing agent graphs and swarm composite graphs |\n| [**swarm.llm**](swarm/llm) | Interface for selecting LLM backends and calculating their operational costs |\n| [**swarm.memory**](swarm/memory) | Index-based memory |\n| [**swarm.optimizer**](swarm/optimizer) | Optimization algorithms designed to enhance agent performance and overall swarm efficiency |\n\n## Visualizations of the graphs\n\n\u003cimg src=\"assets/swarm_vis.png\" alt=\"Edge optimization\" width=\"800\"\u003e\n\n## News\n\n* 😎 **[10/12]** Respect 🐝 OpenAI's [Swarm](https://github.com/openai/swarm), but 🐝 [GPTSwarm](https://github.com/metauto-ai/GPTSwarm) is the better option if consider the 🐝**Swarm Intelligence**🐝.\n\n* 🔥 **[08/07]** Mingchen attended an invited seminar with Shanghai AI Lab.\n\n* 🔥 **[07/25]** Louis and Francesco gave the oral presentation in ICML 2024.\n\n* 🔥 **[07/17]** Mingchen introduced GPTSwarm to Meta.\n\n* 🔥 **[07/05]** Mingchen gave an invited talk to WAIC.\n\n* 🔥 **[06/21]** Mingchen gave an invited talk to IA-CAS.\n\n* 🔥 **[06/20]** Dmitrii gave an invited talk to Sberbank.\n\n* 🔥 **[06/03]** [SDAIA](https://sdaia.gov.sa/en) invited GPTSwarm team (Wenyi, Francesco, Dmitrii) for a 5 hour seminar.\n\n* 🔥 **[06/02]** GPTSwarm has been selected as **Oral Presentation** (top 1.5%, 144 in 9,473) by [ICML2024](https://icml.cc)! Congratulation!\n\n* 🔥 **[05/01]** GPTSwarm has been accepted by [ICML2024](https://icml.cc).\n\n* 🔥 **[04/18]** Mingchen gave the invited talk to ByteDance.\n\n* 🔥 **[03/20]** Mingchen gave the invited talk to HUAWEI.\n\n* 🔥 **[03/13]** [MITTR China Exclusive Interview](https://mp.weixin.qq.com/s/Nsn3rk07mXC_3JaRk4qrTQ) with Mingchen.\n\n* 🔥 **[03/01]** GPTSwarm can be installed via pip now: ``pip install gptswarm``\n\n* 🔥 **[02/27]** Our academic paper: [Language Agents as Optimizable Graphs](https://arxiv.org/abs/2402.16823) is released.\n\n## Edge optimization example\n\nHere 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).\n\n\u003cimg src=\"assets/edge_opt.gif\" alt=\"Edge optimization\" width=\"300\"\u003e\n\n\n\n\n## Quickstart\n\n**Clone the repo**\n\n```bash\ngit clone https://github.com/metauto-ai/GPTSwarm.git\ncd GPTSwarm/\n```\n\n**Install packages**\n```\nconda create -n swarm python=3.10\nconda activate swarm\npip install poetry\npoetry install\n```\n\n**You should add API keys in `.env.template` and change its name to `.env`**\n\n```python\nOPENAI_API_KEY=\"\" # for OpenAI LLM backend\nBING_API_KEY=\"\" # for Bing Web Search\nGOOGLE_API_KEY=\"\" # for Google Web Search\nSEARCHAPI_API_KEY=\"\" # for SearchAPI  Web Search\n```\n\n**Selecting the Search Engine**\n\nThe system will automatically select the appropriate search engine based on the following priority:\n \n  - [Bing API](https://www.microsoft.com/en-us/bing/apis/bing-web-search-api): If `BING_API_KEY` is provided\n  - [Search API](https://www.searchapi.io/): If `SEARCHAPI_API_KEY` is provided\n  - [Google API](https://developers.google.com/custom-search/?csw=1): If `GOOGLE_API_KEY` is provided\n\n**Getting started with GPTSwarm is easy. Quickly run a predefined swarm**\n\n```python\nfrom swarm.graph.swarm import Swarm\n\nswarm = Swarm([\"IO\", \"IO\", \"IO\"], \"gaia\")\ntask = \"What is the capital of Jordan?\"\ninputs = {\"task\": task}\nanswer = await swarm.arun(inputs)\n```\n\n**or make use of tools, such as the file analyzer**\n\n```python\nfrom swarm.graph.swarm import Swarm\nswarm = Swarm([\"IO\", \"TOT\"], \"gaia\")\ntask = \"Tell me more about this image and summarize it in 3 sentences.\"\nfiles = [\"./datasets/demos/js.png\"]\ninputs = {\"task\": task, \"files\": files}\ndanswer = swarm.run(inputs)\n```\n\nCheck out the minimal Swarm example in Colab here: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/metauto-ai/GPTSwarm/blob/main/notebooks/demo_swarm.ipynb).\n\nSee how to create a custom Agent and run a Swarm with it here: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/metauto-ai/GPTSwarm/blob/main/notebooks/demo_custom_agent.ipynb).\n\nHere is a Youtube video on how to run the demo notebooks:\n\n[\u003cimg src=\"assets/youtube_preview.png\" width=\"75%\"\u003e](https://www.youtube.com/watch?v=QOLQse5ZBV8\u0026t=8s\u0026ab_channel=GPTSwarm \"Running swarm inference\")\n\n\n**🔥🔥🔥 See [our experiments](https://github.com/metauto-ai/GPTSwarm/tree/main/experiments) for more advanced use of our framework.**\n\n## Class diagram\n\n\u003cimg src=\"assets/class_diagram.png\" alt=\"Edge optimization\" width=\"700\"\u003e\n\n## Example of the Swarm\n\n\u003cimg src=\"assets/swarm_v3.png\" alt=\"Edge optimization\" width=\"500\"\u003e\n\n\n## Running with a local LLM\n\nWe support local LM inference via [LM Studio](https://lmstudio.ai). 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.\n\n\u003cimg src=\"assets/lm_studio.png\" alt=\"Edge optimization\" width=\"800\"\u003e\n\n## Contributors\n\n\u003ca href=\"https://github.com/metauto-ai/gptswarm/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=metauto-ai/gptswarm\u0026max=200\" /\u003e\n\u003c/a\u003e\n\n* [Mingchen Zhuge](http://metauto.ai) (PhD Student@KAUST; Project Initiator)\n* [Wenyi Wang](https://scholar.google.com/citations?user=79ODhuQAAAAJ\u0026hl=en\u0026oi=ao) (PhD Student @ KAUST; Initial Participant)\n* [Dmitrii Khizbullin](http://www.khizbullin.tech) (Research Engineer Lead @ KAUST; Project Engineer Lead)\n* [Louis Kirsch](http://louiskirsch.com) (PhD Student @ IDSIA)\n* [Francesco Faccio](https://scholar.google.com/citations?user=0z3DkrkAAAAJ\u0026hl=en\u0026oi=ao) (PostDoc@IDSIA; Visiting Researcher@KAUST)\n* [Jürgen Schmidhuber](http://www.idsia.ch/~juergen/) (Director @ KAUST AI Initiative; Scientific Director @ IDSIA)\n* [William FH](https://github.com/hinthornw) (Engineering @ LangChain)\n* [Lukas Vierling](https://www.linkedin.com/in/lukas-vierling/) (BS Student @ RWTH \u0026 HKUST)\n* [Sandro Hanea](https://github.com/sandrohanea) (Senior SDE @ Microsoft)\n\nPlease read our [developer document](DEVELOPMENT.md) if you are interested in contributing.\n\n\n## Citation\nPlease cite our paper if you find the library useful or interesting.\n```\n@inproceedings{zhugegptswarm,\n  title={GPTSwarm: Language Agents as Optimizable Graphs},\n  author={Zhuge, Mingchen and Wang, Wenyi and Kirsch, Louis and Faccio, Francesco and Khizbullin, Dmitrii and Schmidhuber, J{\\\"u}rgen},\n  booktitle={Forty-first International Conference on Machine Learning}\n}\n```\n\n\n\n\n","funding_links":[],"categories":["NLP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetauto-ai%2Fgptswarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetauto-ai%2Fgptswarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetauto-ai%2Fgptswarm/lists"}