Skip to content

Multi-Agent AI Example with LangChain, AutoGen, Azure OpenAI, and Neon Serverless Postgres

Notifications You must be signed in to change notification settings

neondatabase-labs/multi-agent-ai-azure-neon-openai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Agent AI Example with LangChain, AutoGen, Azure OpenAI, and Neon Serverless Postgres

This repository demonstrates how to build a multi-agent AI solution using:

  • LangChain for natural language to SQL translation.
  • AutoGen for coordinating AI agents in collaborative workflows.
  • Azure OpenAI GPT-4o for intelligent language understanding and generation of SQL queries in Neon PostgreSQL.
  • Neon Serverless Postgres for scalable database branching and dynamic data management.

The application showcases a shipping company where AI agents manage shipments, customers, and product information. The main goal is to demonstrate how AI agents can not only query data but also act on it, extending the "Chat With Your Data" concept to "Chat and Act on Your Data."

Multi-Agent AI Example with LangChain, AutoGen, Azure OpenAI, and Neon Serverless Postgres


Features

  • 🌐 Gradio UI: User-friendly interface for natural language interactions.
  • πŸ€– AutoGen Multi-Agent: AI agents collaborate for specific tasks:
    • SchemaAgent: Manages database schema retrieval and sharing.
    • ShipmentAgent: Handles shipment-related queries and updates. Uses the send_shipment stored procedure.
    • CRMAgent: Manages customer and product-related data. Uses the add_customer stored procedure.

Getting Started

1. Prerequisites


2. Setup Instructions

Clone the Repository

git clone https://github.com/your-username/multi-agent-ai-azure-neon-openai.git
cd multi-agent-ai-azure-neon-openai

Create and Configure a Neon Serverless Postgres Database

You can manually create a Neon project in your Neon Console or via Neon API.

Initialize Schema & Data: Run the SQL queries using Neon Console SQL Editor to create databases, tables, insert sample data, and create stored procedures:

First run SQL queries in sql/schema_crm.sql and then sql/schema_shipment.sql files.

  • 1️⃣ CRM Database: Stores customer and product information.
  • 2️⃣ Shipment Database: Stores shipment tracking and logistics data.

Configure .env File

Create a .env file in the root directory with the following contents:

# OpenAI API
AZURE_OPENAI_KEY=your_openai_api_key
AZURE_OPENAI_ENDPOINT=https://your-openai-endpoint
AZURE_OPENAI_DEPLOYMENT=gpt-4o

# Neon Database URIs
NEON_CRM_DB_URI=
NEON_SHIPMENT_DB_URI=

🚨 Important: Ensure you update these values with your actual credentials.


3. Virtual Environment & Dependencies

Create a Virtual Environment

python3 -m venv .venv

Activate the Virtual Environment

  • Windows:
    .venv\Scripts\activate
  • Mac/Linux:
    source .venv/bin/activate

Install Required Libraries

pip install -r requirements.txt

Usage Examples

πŸ” Chat With Your Data

βœ… Example Questions:

  • "Which products are currently in transit?"
  • "Is Alice Johnson a customer?"

πŸ’‘ Database Development Assistance

βœ… Example Task:

  • "I need to create a stored procedure to delete customers. What would be the best way to do this?"

πŸš€ Acting on Data

βœ… Example Actions:

  • "Can you add Marc with email marc@contoso.com, phone +1 123 456 7890, and address 1 Main Street, Redmond?"
  • "Can you create a new shipment of 1 Laptop and 1 Smartphone for Marc and update its status to Departed Origin from New York to Los Angeles?"

πŸ”§ Running the Gradio UI

python -m app.app

This will launch a Gradio UI where you can interact with the multi-agent AI chat.


About

Multi-Agent AI Example with LangChain, AutoGen, Azure OpenAI, and Neon Serverless Postgres

Topics

Resources

Stars

Watchers

Forks