Case · 02 — Production

ERP widget

Stock and complaints assistant · the next step after MerchBot

An AI assistant inside the ERP. The purchasing team uses it to check stock instantly without walking to the warehouse, and to compare the physical count with the system. It also logs customer complaints and ranks them by priority.

454automated tests

The problem

Checking stock meant walking to the warehouse or asking someone, and gaps between the physical count and the system showed up late. Customer complaints came in through scattered channels and were lost before they could turn into improvements.

What I built

The Telegram bot grew into a web widget. Gemini picks one of nine functions, the code runs the SQL query, and every number comes from the database, never from the model. Questions about procedures are answered with RAG over the policy document: embeddings and cosine similarity, with BM25 as a fallback if the API fails. Each complaint gets a tone and a 0–100 priority with its reasons, and every query is logged and shown on a metrics panel.

What changed

In production with the purchasing team, who check stock without leaving their desk and keep a complaints log to spot improvements. It is measured with a 28-case set (exact data, right function, off-topic and prompt-injection attempts), a RAG evaluation with hit@k and MRR, and tests with the model mocked. If Gemini runs out of quota, it falls back to backup models.

Tools

  • Python
  • Gemini
  • Function calling
  • RAG
  • FastAPI
  • PostgreSQL