This December, I'm highlighting how naive chatbots fail at budget-focused inquiries and how AI agents get it right.
We've seen naive chatbots fail at clarifying questions, context shifts, numerical requirements, multiple requests in one query, price filters, style suggestions, unavailable colors, negations, new color requirements, multi-color requests and special occasions.
In yesterday's issue, we saw how AI agents handle multiple product requests in a single query.
Today, we focus on a budget-focused searches.
A customer says, "Do you have blue sports shoes under $60?"
A naive chatbot may ignore the price constraint or claim none exist. An AI agent, on the other hand, applies both color and price filters, returning exactly what the user needs.
Source Code
For a deeper dive into this example, check out my GitHub repository for a detailed, step-by-step implementation in Jupyter Notebooks, breaking down the code and methodology used by the AI agent in today's scenario.
Introducing SoleMates
SoleMates is our fictional online shoe store we'll use to illustrate these concepts:
SoleMates is our fictional online shoe store
Today's Challenge: Budget-Focused Filtering
Scenario
A customer asks:
Customer: "Do you have blue sports shoes under $60?":
A customer initiates a chat with SoleMates and asks about blue sports shoes under $60
Naive Chatbot Response
The naive chatbot vectorizes the entire query but doesn't apply a proper price filter:
The naive chatbot tries to pull shoes that match the request
It either shows any blue sports shoes or says there are none under $60:
The naive chatbot found blue sports shoes but none under $60
Naive Chatbot: "Sorry, there are no blue sports shoes available under $60":
The naive chatbot failed to find blue sports shoes under $60
It fails to recognize that there is a pair priced at $55.
Why Did the Naive Chatbot Fail?
- No numeric filtering to enforce "under $60"
- Treats the entire query as text without structured metadata
- Misses real budget-focused options
Limitations Highlighted
- No concept of "price < 60"
- Inaccurate product suggestions
- Missed opportunities to show users the right products
AI Agent Solution
The AI agent parses "blue sports shoes under $60" into:
- color=blue
- usage=sports
- price <60
It queries the product database with these filters. When it finds a pair of blue sports shoe sat $55, it returns that as a match.
AI Agent: "Here is a pair of blue sports shoes under $60":
AI agent applies filters for each request and pulls suitable products for the whole request
How Did the AI Agent Succeed?
- Applies the "under $60" numeric filter
- Ensures
color=blue
andusage=sports
are met - Delivers matches within the requested budget
Key Takeaways
Naive Chatbot Limitation
- Can't apply price filters and misses available products
AI Agent Advantages
- Accurately enforces numeric budget constraints
- Uses color, category, and price filters together
- Presents users with relevant options
Conclusion
Price-based queries are common in online shopping.
Naive chatbots fail to parse "under $60" and often give incomplete answers.
AI agents apply these filters correctly, delivering the product that meets both color and budget needs.
About This Series
In this series, we highlight how naive chatbots fail and how AI agents solve real-world shopping demands.
Stay tuned for tomorrow's issue, where we show yet another scenario where AI agents outperform naive chatbots.
I'm preparing a course to teach you how to build and deploy your own AI agent chatbot. Sign up here!
Behind the Scenes: Code Snippets
Here's a simplified illustration of how the AI agent processes the query.
We're giving the agent access to two tools it can use freely:
- Vector database metadata filtering
- Vector database query
1. Vector database metadata filtering tool
def create_metadata_filter(filter_string):
# For "blue sports shoes under $60"
# Returns: [{"key": "color", "value": "blue", "operator": "=="},
# {"key": "price", "value": 60, "operator": "<"}]
filters = parse_filters(filter_string)
return filters
2. Vector database query
def search_footwear_database(query_str, filters_json):
embedded_query = embed_query_aws_titan(query_str)
results = vector_db.search(embedded_query, filters=filters_json)
return results
I use AWS Titan, a multimodal embedding model that converts both product texts and images into vectors, integrated as the function embed_query_aws_titan
into the AI agent tool search_footwear_database
.
This means the AI agent can process a query like "red heels" and match it to not only product descriptions but also actual images of red heels in the database.
By combining text and image data, the model helps the AI agent provide more relevant and visually aligned recommendations based on the customer's input.
Agent workflow
Construct agent worker with access to the two tools and initiate the agent:
from llama_index.core.agent import AgentRunner, FunctionCallingAgentWorker
agent_worker = FunctionCallingAgentWorker.from_tools(
[
create_metadata_filters_tool,
query_vector_database_tool,
])
agent = AgentRunner(
agent_worker,
)
Initiate conversation with agent:
agent.chat("Do you have blue sports shoes under $60?")
Agent workflow:
Agent:
- Interprets "under $60" as a numeric filter on price
- Agent calls
create_metadata_filter("blue sports shoes under $60")
- Gets filters:
[
{"key": "color", "value": "blue", "operator": "=="},
{"key": "price", "value": 60, "operator": "<"}
]
- Calls
search_footwear_database("sports shoes", filters)
- Finds blue sports shoes priced under $60
- Returns them to user:
The AI agent sees the request and decides to apply a price filter
Here's the full agent output:
Added user message to memory: Do you have blue sports shoes under $60?
=== Calling Function ===
Calling function: create_metadata_filter with args: {"filter_string": "blue sports shoes under $60"}
=== Function Output ===
[{"key": "color", "value": "blue", "operator": "=="}, {"key": "price", "value": 60, "operator": "<"}]
=== Calling Function ===
Calling function: search_footwear_database with args: {"query_str": "sports shoes", "filters_json": [{"key": "color", "value": "blue", "operator": "=="}, {"key": "price", "value": 60, "operator": "<"}]}
=== Function Output ===
[{'color': 'blue', 'text': "Adidas men's canon dialect blue yellow shoe", 'gender': 'men', 'product_type': 'sports shoes', 'product_id': 31, 'usage': 'sports', 'price': 55, 'heels_height': None, 'similarity_score': 1.24849772}]
=== LLM Response ===
I found a pair of blue sports shoes under $60 for you:
- **Adidas Men's Canon Dialect Blue Yellow Shoe**
- Price: $55
- Usage: Sports
Let me know if you need more information or if you're interested in purchasing!
Additional Resources
For a deeper dive into this example, check out my GitHub repository where I break down the code and methodology used by the AI agent in today's scenario.
Sign up here for my upcoming course to learn how to build your own AI agent chatbot
Why use AI agents instead of simple chatbots?
Online shoppers often search with budget constraints, like "blue sports shoes under $60."
AI agents use numeric filters and metadata to find matching items.
This approach increases customer satisfaction, drives more conversions, and keeps users engaged, highlighting the power of AI-driven search solutions.