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 - ensure the vector search feature is enabled.
- Azure OpenAI API key and endpoint.
- Azure OpenAI Embedding Deployment ID for the RAG model.
Clone the repository:
git clone https://github.com/AzureCosmosDB/multi-agent-swarm
cd multi-agent-swarm
Install dependencies:
pip install git+https://github.com/openai/swarm.git
pip install azure-cosmos==4.9.0
pip install gradio
Ensure you have the following environment variables set:
AZURE_COSMOSDB_ENDPOINT=your_cosmosdb_account_uri
AZURE_COSMOSDB_KEY=your_cosmosdb_account_key
AZURE_OPENAI_API_KEY=your_azure_openai_api_key
AZURE_OPENAI_ENDPOINT=your_azure_openai_endpoint
AZURE_OPENAI_EMBEDDINGDEPLOYMENTID=your_azure_openai_embeddingdeploymentid
Once you have installed dependencies, run below and click on url provided in output:
python3 src/app/ai_chat_bot.py
To see the agent handoffs, you can also run as an interactive Swarm CLI session using:
python3 src/app/multi_agent_service.py