Skip to content

A sample exploring ergonomic, lightweight multi-agent orchestration in Python using Azure Cosmos DB with OpenAI Swarm

License

Notifications You must be signed in to change notification settings

AzureCosmosDB/multi-agent-swarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-agent AI sample with Azure Cosmos DB

A sample personal shopping AI Chatbot that can help with product enquiries, making sales, and refunding orders by transferring to different agents for those tasks.

Features:

  • Multi-agent: OpenAI Swarm to orchestrate multi-agent interactions with Azure OpenAI API calls.
  • Transactional data management: planet scale Azure Cosmos DB database service to store transactional user and product operational data.
  • Retrieval Augmented Generation (RAG): vector search in Azure Cosmos DB with powerful DiskANN index to serve product enquiries from the same database.
  • Gradio UI: Gradio to provide a simple UI ChatBot for the end-user.

Backend agent activity

Run the CLI interactive session to see the agent handoffs in action...

Demo

Front-end AI chat bot

Run the AI chat bot for the end-user experience...

Demo

Overview

The personal shopper example includes four main agents to handle various customer service requests:

  1. Triage Agent: Determines the type of request and transfers to the appropriate agent.
  2. Product Agent: Answers customer queries from the products container using Retrieval Augmented Generation (RAG).
  3. Refund Agent: Manages customer refunds, requiring both user ID and item ID to initiate a refund.
  4. Sales Agent: Handles actions related to placing orders, requiring both user ID and product ID to complete a purchase.

Prerequisites

How to run locally

Clone the repository:

git clone https://github.com/AzureCosmosDB/multi-agent-swarm
cd multi-agent-swarm

Create and activate a virtual environment (Linux/Mac):

python -m venv venv
source venv/bin/activate
# Install AZD
curl -fsSL https://aka.ms/install-azd.sh | bash

Create and activate a virtual environment (Windows):

python -m venv venv
venv\Scripts\activate
# Install AZD
powershell -ex AllSigned -c "Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression"

Install dependencies:

pip install -r requirements.txt

Deploy the Azure Services via AZD and inject the service names into the .env file

azd up

From your terminal or IDE, run below and click on URL provided in output:

python src/app/ai_chat_bot.py

To see the agent handoffs, you can also run as an interactive Swarm CLI session using:

python src/app/multi_agent_service.py

There 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

Here 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.

I need some help

I'm looking for footwear

Do you have any shoes

I'd like to purchase these

My user id is 1 and product id is 9

These are the wrong size. Can i return them?

My user id is 1

About

A sample exploring ergonomic, lightweight multi-agent orchestration in Python using Azure Cosmos DB with OpenAI Swarm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •