ID: 001
An AI-powered shopping assistant built with Streamlit, LangGraph, and LangChain for the fictional US retail chain Target Superstore.
The assistant supports:
- 🔍 Product search and filtering
- 🛍️ Cart management
- 👤 User loyalty lookup
- 💰 Final price calculation with loyalty points
- ✅ Human-in-the-loop approval for cart additions
- 🤖 Tool-calling AI agent using LangGraph
- 💬 Conversational UI with Streamlit
Users can chat naturally in English or Urdu to:
- Search products
- Add/remove products from cart
- View cart contents
- Checkout
- Ask pricing questions
Before adding products to the cart, the system pauses execution and asks for explicit approval using LangGraph interrupts.
Example flow:
-
User says:
Add Nestle Milk Pack
-
AI triggers
add_to_cart -
Graph pauses with:
- Approve ✅
- Reject ❌
-
Execution resumes after user decision
The assistant uses LangChain tools:
| Tool | Description |
|---|---|
get_product_info |
Product search/filtering |
get_user_data |
Retrieve customer profile |
calculate_final_price |
Loyalty discount calculation |
add_to_cart |
Add item with approval workflow |
view_cart |
Show cart |
remove_from_cart |
Remove item from cart |
- Python
- Streamlit
- LangGraph
- LangChain
- Pandas
- OpenAI / LLM Provider
- dotenv
project/
│
├── app.py
├── llm.py
├── users_data.json
├── superstore_products.xlsx
├── .env
├── requirements.txt
└── README.mdgit clone <your_repo_url>
cd <project_name>python -m venv venvActivate it:
source venv/bin/activatevenv\Scripts\activatepip install -r requirements.txtCreate a .env file:
OPENAI_API_KEY=your_api_key_hereYou may also configure your custom LLM provider inside llm.py.
streamlit run app.pyUser Input
↓
LLM Node
↓
Tool Decision
↓
Tool Execution
↓
Interrupt (if approval needed)
↓
Resume Execution
↓
Assistant Response
User → "Add product X"
↓
AI calls add_to_cart
↓
Interrupt triggered
↓
User approves/rejects
↓
Cart updated
The assistant supports filtering by:
- Product Name
- Product ID
- Brand
- Category
- Subcategory
- Price Range
- Tags
Example queries:
Show me imported chocolates
Find organic products under 1000 PKR
Search for Nestle products
get_user_data(user_id) returns:
{
"user_id": "U1001",
"name": "Ali Khan",
"loyalty_points": 2500,
"tier": "Gold"
}calculate_final_price(price=5000, loyalty_points=1200)Output:
Discount applied: 1200 PKR.
Final price: 3800 PKR.
Defines the agent workflow graph.
Executes LangChain tools automatically.
Pauses execution for human approval.
Resumes graph execution after approval/rejection.
Persists conversation state across Streamlit reruns.
- User/assistant conversation
- Approval prompts
- Tool responses
Displays:
- Cart items
- Quantity
- Total price
Show me snacks under 500 PKR
Add P1001 to cart
View my cart
Remove P1001
Checkout
The AI strictly follows rules such as:
- Only one cart tool per turn
- Approval required for add-to-cart
- No approval for remove-from-cart
- Checkout triggered only on explicit request
- Persistent database storage
- Real payment integration
- Inventory updates
- Voice assistant support
- Multi-user authentication
- Recommendation engine
- Order history
- WhatsApp integration
streamlit
pandas
langchain
langgraph
python-dotenv
openpyxlUser: Add Milk Pack
AI:
Approval Required
[Approve] [Reject]
User clicks Approve
AI:
Added Milk Pack x1 to cart.
Cart total: PKR 450
MIT License
Built with: