{"id":28438334,"url":"https://github.com/azurecosmosdb/multi-agent-swarm","last_synced_at":"2025-06-28T15:30:44.628Z","repository":{"id":267739302,"uuid":"902206764","full_name":"AzureCosmosDB/multi-agent-swarm","owner":"AzureCosmosDB","description":"A sample exploring ergonomic, lightweight multi-agent orchestration in Python using Azure Cosmos DB with OpenAI Swarm","archived":false,"fork":false,"pushed_at":"2025-04-01T17:19:42.000Z","size":30898,"stargazers_count":19,"open_issues_count":2,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-06T01:06:05.391Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"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/AzureCosmosDB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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-12-12T05:48:06.000Z","updated_at":"2025-04-02T15:52:36.000Z","dependencies_parsed_at":"2025-03-13T21:23:32.586Z","dependency_job_id":"cbd34513-978f-4500-b474-c84fef181bb1","html_url":"https://github.com/AzureCosmosDB/multi-agent-swarm","commit_stats":null,"previous_names":["azurecosmosdb/multi-agent-swarm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AzureCosmosDB/multi-agent-swarm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzureCosmosDB%2Fmulti-agent-swarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzureCosmosDB%2Fmulti-agent-swarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzureCosmosDB%2Fmulti-agent-swarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzureCosmosDB%2Fmulti-agent-swarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AzureCosmosDB","download_url":"https://codeload.github.com/AzureCosmosDB/multi-agent-swarm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AzureCosmosDB%2Fmulti-agent-swarm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262452069,"owners_count":23313371,"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":[],"created_at":"2025-06-06T01:06:05.248Z","updated_at":"2025-06-28T15:30:44.622Z","avatar_url":"https://github.com/AzureCosmosDB.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi-agent AI sample with Azure Cosmos DB\n\nA sample personal shopping AI Chatbot that can help with product enquiries, making sales, and refunding orders by transferring to different agents for those tasks.\n\nFeatures:\n\n- **Multi-agent**: [OpenAI Swarm](https://github.com/openai/swarm) to orchestrate multi-agent interactions with [Azure OpenAI](https://learn.microsoft.com/azure/ai-services/openai/overview) API calls.\n- **Transactional data management**: planet scale [Azure Cosmos DB database service](https://learn.microsoft.com/azure/cosmos-db/introduction) to store transactional user and product operational data.\n- **Retrieval Augmented Generation (RAG)**: [vector search](https://learn.microsoft.com/azure/cosmos-db/nosql/vector-search) in Azure Cosmos DB with powerful [DiskANN index](https://www.microsoft.com/en-us/research/publication/diskann-fast-accurate-billion-point-nearest-neighbor-search-on-a-single-node/?msockid=091c323873cd6bd6392120ac72e46a98) to serve product enquiries from the same database.\n- **Gradio UI**: [Gradio](https://www.gradio.app/) to provide a simple UI ChatBot for the end-user.\n\n## Backend agent activity\n\nRun the CLI interactive session to see the agent handoffs in action...\n\n![Demo](./media/demo-cli.gif)\n\n## Front-end AI chat bot\n\nRun the AI chat bot for the end-user experience...\n\n![Demo](./media/demo-chatbot.gif)\n\n## Overview\n\nThe personal shopper example includes four main agents to handle various customer service requests:\n\n1. **Triage Agent**: Determines the type of request and transfers to the appropriate agent.\n2. **Product Agent**: Answers customer queries from the products container using [Retrieval Augmented Generation (RAG)](https://learn.microsoft.com/azure/cosmos-db/gen-ai/rag).\n3. **Refund Agent**: Manages customer refunds, requiring both user ID and item ID to initiate a refund.\n4. **Sales Agent**: Handles actions related to placing orders, requiring both user ID and product ID to complete a purchase.\n\n## Prerequisites\n\n- [Azure Cosmos DB account](https://learn.microsoft.com/azure/cosmos-db/) - configured for Serverless and [vector search](https://learn.microsoft.com/azure/cosmos-db/nosql/vector-search).\n- [Azure OpenAI Account](https://learn.microsoft.com/azure/ai-services/openai/overview) endpoint with embedding `text-3-embedding-large` and GPT `gpt-4o-mini` models deployed.\n- [Azure Developer CLI - AZD](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview) to deploy Azure Services and configure environment variables.\n\n## How to run locally\n\nClone the repository:\n\n```shell\ngit clone https://github.com/AzureCosmosDB/multi-agent-swarm\ncd multi-agent-swarm\n```\n\nCreate and activate a virtual environment (Linux/Mac):\n\n```shell\npython -m venv venv\nsource venv/bin/activate\n```\n\n```shell\n# Install AZD\ncurl -fsSL https://aka.ms/install-azd.sh | bash\n```\n\nCreate and activate a virtual environment (Windows):\n\n```shell\npython -m venv venv\nvenv\\Scripts\\activate\n```\n\n```shell\n# Install AZD\npowershell -ex AllSigned -c \"Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression\"\n```\n\nInstall dependencies:\n\n```shell\npip install -r requirements.txt\n```\n\nDeploy the Azure Services via AZD and inject the service names into the .env file\n\n```shell\nazd up\n```\n\nFrom your terminal or IDE, run below and click on URL provided in output:\n\n```shell\npython src/app/ai_chat_bot.py\n```\n\nTo see the agent handoffs, you can also run as an interactive Swarm CLI session using:\n\n```shell\npython src/app/multi_agent_service.py\n```\n\nThere are three products you can ask about: a hat, wool socks and shoes. For more details on data like users and products in this sample, see the `initialize_database()` function in [azure_cosmos_db.py](./src/app/azure_cosmos_db.py)\n\nHere are a series of user prompts you can enter to watch this multi-agent application in action. Enter these one at a time and watch how the app responds. Feel free to explore with your own prompts.\n\n```text\nI need some help\n\nI'm looking for footwear\n\nDo you have any shoes\n\nI'd like to purchase these\n\nMy user id is 1 and product id is 9\n\nThese are the wrong size. Can i return them?\n\nMy user id is 1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazurecosmosdb%2Fmulti-agent-swarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazurecosmosdb%2Fmulti-agent-swarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazurecosmosdb%2Fmulti-agent-swarm/lists"}