Skip to content
← Back to projects

Product Advisor — LLM Assistant

An LLM-powered shopping assistant that classifies user intent, recommends smartphones from a catalog based on stated preferences, and compares two products using structured specifications.

By Jawher Ennaceur

View on GitHub
  • LLMs
  • LangChain
  • Prompt Engineering
  • Natural Language Processing
  • Intent Classification
  • Fuzzy Matching

The Problem

Choosing between products often means comparing several specifications and working out which options fit a user's preferences. Traditional filters struggle with natural-language requests and conversational follow-ups. This project tackles interpreting user queries, identifying the products they refer to, and generating useful recommendations and comparisons from structured product data.

The Approach

I built the assistant in Python with LangChain's Google Gemini integration (Gemini 1.5 Flash). A first LLM call classifies each query as recommendation, comparison, clarification or other, and returns either product names or filters (brand, price range, RAM, storage) as JSON, using the recent conversation history for context. For comparisons, the extracted product names are matched against a 10-phone catalog using Levenshtein distance (maximum distance of two) to tolerate typos, and the matched specifications are passed to the LLM for a short, buyer-focused comparison. For recommendations, the extracted filters and the catalog are given to the LLM, which picks one or two phones and explains why. A regex-based JSON extractor and field validation handle messy model output, and unparseable or unclear requests fall back to a general answer instead of failing.

Results

  • Implemented four intent categories: recommendation, comparison, clarification and other
  • Matched product names with Levenshtein distance (configurable maximum of two) so small typos still resolve
  • Built a catalog of 10 smartphones with brand, price, RAM, storage, camera and battery fields
  • Generated comparisons covering price, RAM, storage, camera and battery
  • Added JSON extraction, field validation and safe fallbacks when the model's output can't be parsed
  • Passed conversation history to the intent step so follow-ups like "which one is better?" can be resolved

Tech Stack

Python
LangChain
Google GeminiLevenshteinJSONRegular ExpressionsPython-dotenv