Skip to content

A sample for multi-agent orchestration in Python using Azure Cosmos DB with LangGraph

License

Notifications You must be signed in to change notification settings

AzureCosmosDB/multi-agent-langgraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 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:

Backend agent activity

Run as an 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

Setup

Clone the repository:

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

Install dependencies:

pip install -r src/app/requirements.txt 

Ensure you have the following environment variables set:

COSMOSDB_ENDPOINT=your_cosmosdb_account_uri
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 azure_cosmos_db.py to create the required Cosmos DB containers and load the sample data. Note: Ensure that you have enabled both vector search capability in your Cosmos DB account. Please wait at least 10 minutes after enabling this feature before running the sample code. Note: The Products container is initially created with 10000 RUs for faster loading of 1000 products. If you are using a free tier account, you may need to reduce the RUs to avoid exceeding the free tier limit. You can also reduce the RUs after the initial data load to avoid excessive charges.

python src/app/azure_cosmos_db.py

Then run the chat bot code below and click on url provided in the output:

python src/app/ai_chat_bot.py

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

python3 src/app/multi_agent_service.py

About

A sample for multi-agent orchestration in Python using Azure Cosmos DB with LangGraph

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages