This repository demonstrates how to build a multi-agent AI system using:
- LangChain for natural language to SQL translation.
- AutoGen for coordinating AI agents in collaborative workflows.
- Azure OpenAI GPT-4 for intelligent language understanding and generation of SQL queries in PostgreSQL.
- Azure Database for PostgreSQL for data storage and querying.
The application showcases a shipping company where agents manage shipments, customers and product informations. The main goal of this repository is to illustrate how easy it is to have agents not just reading data but also acting on them. It extends the "Chat With Your Data" to "Chat and Act on Your Data".
- 🌐 Gradio UI: User-friendly interface for natural language interactions.
- 🤖 AutoGen Multi-Agent System: Agents collaborate to handle specific tasks:
- SchemaAgent: Manages database schema retrieval and sharing.
- ShipmentAgent: Handles shipment-related queries and updates.
- CRMAgent: Manages customer and product-related data.
- 🧠 Azure OpenAI GPT-4: Generates SQL queries and natural language responses.
- 🛢️ Azure PostgreSQL: Stores shipment, customer, and product data.
- Python 3.7+
- An Azure account with:
- Azure OpenAI Service (GPT-4 deployed).
- Azure Database for PostgreSQL (configured with necessary tables).
- Environment setup:
python-dotenv
for environment variables.- PostgreSQL client library (
psycopg2
or similar).
git clone https://github.com/arno756/multi-ai-agents-with-postgresql.git
cd multi-ai-agents-with-postgresql
Create a .env file in the root directory to store sensitive credentials. Use the following template:
# Azure OpenAI
AZURE_OPENAI_KEY=your_openai_api_key
AZURE_OPENAI_ENDPOINT=https://your-openai-endpoint
AZURE_OPENAI_DEPLOYMENT=gpt-4
# PostgreSQL Database
POSTGRES_USER=your_username
POSTGRES_PASSWORD=your_password
POSTGRES_HOST=your_postgresql_host
POSTGRES_PORT=5432
POSTGRES_DB=your_database_name
Replace the placeholder values with your actual credentials. The Jupyter Notebook is configured with .env been located in the same root folder in my machine.
If you use Google Collab and you want to upload .env file, you will have to add the following code:
from google.colab import files
files.upload() # Upload your .env file
- How many customers do we have?
- What products are currently in transit?
- Can you add Marc with email address marc@contoso.com, phone number +1 123 456 7890 and address in 1 Main Street, Seattle?
- Can you create a new shipment of 1 Laptop and 1 Smartphone to Marc and ensure shipment is updated to Departed Origin from the location in New York and towards Los Angeles date is today?