The case study on Habr describes a dialogue: a customer writes "a gift for my brother, he's 30, loves board games, under $70." The assistant asks when the birthday is and learns there are 5 working days left until Friday. Per store rules, such an order gets a 20% discount, so three gifts worth $83.99 fit into the $70 budget, coming to $67.19 after the discount. The dialogue is handled by the qwen3.5 9B model, running in LM Studio in 4-bit format (about 6 GB) on a MacBook M3 Max. Instead of LM Studio, you can plug in any OpenAI-compatible API — the address, model, and key are set in.env. The architecture is a monorepo: apps/backend on NestJS 11, Prisma 7, and PostgreSQL; apps/harness — the assistant itself with no database of its own; apps/frontend on React 19, Vite, and HeroUI; packages/contracts — zod schemas; bench — benchmarks. The catalog has 64 products, 3 are out of stock, and 8 require buying batteries or wrapping paper separately. Each message triggers 8 steps, of which the model handles only 3: parsing the message, selecting products, and writing the reply. Medians across 6 conversations: parsing ~3.3 s, selection ~4.3 s, reply ~2 s, while the SQL filter takes ~22 ms and price calculation ~9 ms. An answer to a question arrives in 3–7 seconds; product suggestions take 9–15 seconds. Across six customers, the assistant never exceeded the budget and never quoted an incorrect amount.
The case demonstrates a working pattern for separating responsibilities: the model handles only dialogue and selection, while verifiable operations are done by code. The assistant talks to the store via two requests — product search with filters for age, price, and delivery time, and order total calculation — so it can be connected to a real online store via API. Customer-facing questions live in a config file, so adapting to another store only requires changing that file, not the code. The model's reply is validated before sending: the code finds all dollar amounts, cross-checks them against backend data, and if a made-up figure appears, replaces the reply with a template.
The first version of the assistant made mistakes with dates: if you wrote "by Monday" on a Saturday, the model would set the following week's Monday. So now the model doesn't compute the date — it only extracts the word "Monday" from the message, while the code calculates the date and the number of working days. For product selection, the model picks up to 5 top items from a list already filtered by an SQL query, following a JSON schema, and the code fits them into the budget, skipping anything that doesn't fit. A separate fitsRequest flag helps respond correctly when no suitable product exists: the model honestly marks it as unsuitable. First, the assistant offers one gift and two backup options, and when sever
Source: habr.com · post in Telegram