Initial Release
Customer support agent that helps users resolve questions about orders, products, shipping, etc.
In this project you will build an AI agent powered by Python smolagents and InterSystems IRIS.
AI agents are programs that use an LLM as their βmindβ and then call external tools (databases, APIs, knowledge basesβ¦) to solve real-world tasks.
π You could build such an agent by hand:
That worksβ¦ but itβs complex and fragile π .
Instead, you can use a framework. In this project we use smolagents, a lightweight Hugging Face library. It lets you define tools and data sources, while the agent handles the reasoning.
Think of it as a tiny brain with a toolbox π§°.
This project relies on two key components:
π Python β Runs the AI agent (LLM reasoning + smolagents framework).
ποΈ InterSystems IRIS β Acts as the data and integration platform:
Together, they showcase how IRIS enables real enterprise AI agents that combine reasoning, structured & unstructured data, and live integrations.
You will build an AI agent that:
To run this demo youβll need:
π Python 3.9+
Runs the AI agent with smolagents and connects to IRIS.
π³ Docker
Spins up an InterSystems IRIS container (database + vector search + interoperability).
π» VS Code (recommended)
For editing and exploring the Python code.
π OpenAI API Key
Used for the LLM βmindβ and also to embed documents for RAG.
Create a virtual environment
# Mac/Linux
python3 -m venv .venv
# Windows
python -m venv .venv
Activate the environment:
# Mac/Linux source .venv/bin/activate
Windows (PowerShell)
.venv\Scripts\Activate.ps1
Then, install dependencies:
pip install -r requirements.txt
Create a .env
file:
.env.example
to .env
docker compose build
docker compose up -d
You can access IRIS Management Portal using:
superuser
SYS
Have a look at this summary of the repo contents to understand the project:
customer-support-agent/
ββ .env.example # sample env file (copy to .env)
β
ββ iris/ # InterSystems IRIS assets
β ββ Dockerfile # IRIS container build
β ββ sql/ # SQL scripts
β β ββ schema.sql # creates tables for Customer Support use case
β β ββ load_data.sql # loads CSVs into tables
β β ββ truncate.sql
β ββ data/ # data: customer, orders, etc.
β ββ docs/ # unstructured Knowledge Base (RAG content)
β ββ src/ # IRIS classes. Simulates live shipping status interoperability
β
ββ agent/ # the AI agent (Python) + tools
β ββ customer_support_agent.py # wraps smolagents CodeAgent + tools
β ββ tools/
β ββ sql_tool.py # SQL tools
β ββ rag_tool.py # RAG tools
β ββ shipping_tool.py # calls IRIS interoperability
β
ββ db/ # database adapters & helpers
ββ cli/ # terminal frontend
ββ ui/ # lightweight web UI (Gradio)
ββ scripts/ # utility scripts
Before running the agent, we must create the tables and insert some data.
This will be the structured data that the agent will query to answer user questions.
Run this SQL sentences in IRIS SQL Explorer or using your favorite SQL client.
LOAD SQL FROM FILE '/app/iris/sql/schema.sql' DIALECT 'IRIS' DELIMITER ';'
LOAD SQL FROM FILE '/app/iris/sql/load_data.sql' DIALECT 'IRIS' DELIMITER ';'
Check the data you have just inserted and get yourself familiar with the tables.
Here are some simple queries you can try:
-- List all customers SELECT * FROM Agent_Data.Customers;
-- Get all orders for a given customer
SELECT o.OrderID, o.OrderDate, o.Status, p.Name AS Product
FROM Agent_Data.Orders o
JOIN Agent_Data.Products p ON o.ProductID = p.ProductID
WHERE o.CustomerID = 1;-- Check shipment info for an order
SELECT * FROM Agent_Data.Shipments WHERE OrderID = 1001;-- See products with their warranty
SELECT Name, WarrantyMonths FROM Agent_Data.Products;
-- Find orders that are still Processing
SELECT * FROM Agent_Data.Orders WHERE Status = 'Processing';
The agent will be able also to query non structured data using a RAG (Retrieval Augmented Generation) pattern.
For that, we will be leveraging InterSystems IRIS Vector Search features.
We will embed the data using OpenAI text-embedding-3-small
model.
We will leverage an InterSystems IRIS feature that allows us to setup embedding directly in the database.
INSERT INTO %Embedding.Config (Name, Configuration, EmbeddingClass, VectorLength, Description)
VALUES ('my-openai-config',
'{"apiKey":"your-openai-api-key-here",
"sslConfig": "llm_ssl",
"modelName": "text-embedding-3-small"}',
'%Embedding.OpenAI',
1536,
'a small embedding model provided by OpenAI')
Now, run script that loops over documents and records that needs to be embedded
python scripts/embed_sql.py
After that have a look at the tables and check that embeddings are now included.
-- Products
SELECT * FROM Agent_Data.Products;
-- Chunks from documents
SELECT * FROM Agent_Data.DocChunks;
One of the most powerful features of InterSystems IRIS is its Interoperability framework.
It allows you to seamlessly connect your solution to other systems, APIs, and services in a reliable, monitored, and traceable way.
In this demo, we included a mock shipping service that shows how an agent can call a live API to retrieve status and timeline information:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"orderStatus":"Processing","trackingNumber":"DHL7788"}' \
http://localhost:52773/api/shipping/status
This information can also be consumed by the agent.
β¨ And since IRIS has a built-in Visual Trace viewer, you can actually see each message flowing through the system.
The agent is a smolagents CodeAgent:
β‘οΈ Want to see how it works under the hood? Check out these key files:
Feel free to open them and explore the code β theyβre short, simple, and quite fun to read π.
You can run the agent in three different ways:
Run a single question + get a single answer. Perfect for quick tests.
python -m cli.run --email alice@example.com --message "Where is my order #1001?"
python -m cli.run --email alice@example.com --message "Show electronics that are good for travel"
python -m cli.run --email alice@example.com --message "Was my headphones order delivered, and whatβs the return window?"
python -m cli.run --email alice@example.com --message "Find headphones under $120 with ANC"
python -m cli.run --email alice@example.com --message "If my order is out of warranty, what options do i have?"
Start a small session where you can type multiple questions in a row.
python -m cli.run --email alice@example.com
A lightweight chat UI with Gradio, so you can talk to the agent in your browser.
python -m ui.gradio
Then open the UI in http://localhost:7860