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."
- π 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.
- Python 3.9+ (Recommended: 3.10 or 3.11)
- A Neon account (Sign up for Neon)
- Azure OpenAI API Endpoint, Model Deployment Name and API Key (For GPT-4)
git clone https://github.com/your-username/multi-agent-ai-azure-neon-openai.git
cd multi-agent-ai-azure-neon-openai
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.
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.
python3 -m venv .venv
- Windows:
.venv\Scripts\activate
- Mac/Linux:
source .venv/bin/activate
pip install -r requirements.txt
β Example Questions:
- "Which products are currently in transit?"
- "Is Alice Johnson a customer?"
β Example Task:
- "I need to create a stored procedure to delete customers. What would be the best way to do this?"
β Example Actions:
- "Can you add Marc with email
marc@contoso.com
, phone+1 123 456 7890
, and address1 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?"
python -m app.app
This will launch a Gradio UI where you can interact with the multi-agent AI chat.