Designing guardrails around imperfect language-model outputs.
A local model will sometimes misread a store name, leave out a detail or file a question under the wrong type. Instead of trusting its reading, the assistant checks it in several layers of ordinary code, and asks the operator when it can't be sure.
Ambiguous location
“Show the stock for Harbour.”
Store: “Harbour”
Two stores share the word “Harbour”, so the assistant asks: Harbour East or Harbour West?
A store the model made up
“Which products sell best?”
Store: “Store Z”
The question named no store and “Store Z” doesn't exist, so the invented store is removed and the report covers every store.
A short follow-up
“How did Store A do last week? … And Store B?”
Follow-up, store: Store B (question type and period missing)
Python fills in what wasn't repeated from the previous question: Sales summary · Store B · last week.
Every layer of checks
Store names
Aliases built from the database; typos fuzzy-matched; unknown places refused with an explicit “I don't know that store”.
Low confidence
When the model isn't confident, the assistant asks “Did you mean…?” before running anything.
Rule-based overrides
Python rules route known phrasings directly, so new question types don't need prompt edits.
Second-chance routing
Unmatched questions get one more, catalogue-based attempt before the assistant says it can't help.
Follow-ups
A short follow-up reuses the previous question's details, and a long, self-contained question is never mistaken for one.