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: