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.
Run the CLI interactive session to see the agent handoffs in action...
Run the AI chat bot for the end-user experience...
The personal shopper example includes four main agents to handle various customer service requests:
- Triage Agent: Determines the type of request and transfers to the appropriate agent.
- Product Agent: Answers customer queries from the products container using Retrieval Augmented Generation (RAG).
- Refund Agent: Manages customer refunds, requiring both user ID and item ID to initiate a refund.
- Sales Agent: Handles actions related to placing orders, requiring both user ID and product ID to complete a purchase.
- Azure Cosmos DB account - configured for Serverless and vector search.
- Azure OpenAI Account endpoint with embedding
text-3-embedding-large
and GPTgpt-4o-mini
models deployed. - Azure Developer CLI - AZD to deploy Azure Services and configure environment variables.
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