
DESIGN NOTES
An English demo of a Vietnamese production support agent. From the client's raw documents to a streamed answer: what was built, and why each choice was made.
6
policy documents
48
searchable chunks
1,307
catalog products
98%
answers in the top 5
01
One streaming endpoint, one agent, three kinds of knowledge, each stored the way it is used.
POST /api/v1/chat streams text and reasoning in the Vercel AI SDK protocol; tool calls and their raw results stay on the server.02
A retrieval system repeats whatever its sources say, so the documents were fixed before any code.
01
Merged conflicts
Store phones, resizing and payment rules disagreed across files. Each fact now lives in one place.
02
Checked against tierra.vn
Changed the store list (13 to 17), hours, cash on delivery and buyback terms.
03
Instructions out of the knowledge
Notes written for the chatbot moved to the system prompt instead of being retrieved as facts.
04
Translated with trade terms
Center stone, melee, pavé, GIA grading report. Every number compared automatically.
05
Left out what the bot must not say
The internal staff-training deck, and internal notes in the promotion document.
06
One topic per heading
Two answers were unfindable until a mixed-topic section was split into sub-headings.
| Document | Covers | Chunks |
|---|---|---|
| Company and Stores | Brand, collections, 17 stores and hours, hotline | 8 |
| Products and Design | Metals, colors, ring sizing, customization, production time | 5 |
| Gemstones and Certification | Diamonds, moissanite, CZ, GIA reports; 25 FAQs | 16 |
| Ordering and Payment | Deposits, payment methods, card fees, installments | 5 |
| Delivery and Shipping | Pickup vs delivery, timelines, inspection, fees | 6 |
| Warranty and Buyback | Warranty, cleaning, buyback rates, resizing, trade-in | 8 |
03
Not everything belongs in a vector store. Each source is stored the way the agent needs to read it.
Policy documents
Product catalog
Promotions
04
The documents are curated and organized by heading, so headings are the natural units. Seven strategies were compared on the same 50 questions.
Step 1
Split
at every ### and every numbered FAQ
Step 2
Merge
sections under 350 chars with their neighbours
Step 3
Cap
split anything over 1,500 chars at paragraphs
Step 4
Prefix
the heading path, embedded with the text
Step 5
Embed
text-embedding-3-large, 3,072 dims
Ordering and payment > Payment methods Tierra Diamond accepts cash (VND), bank transfer, card payment (VISA, in store or online) and 0% installment plans on credit cards. Tierra does not accept cash on delivery (COD).
halfvec(3072): pgvector's HNSW index stops at 2,000 dimensions for plain vector.05
Two searches with opposite strengths, merged into one ranking.
PT900, 3EX. Accent-stripped, so “bao hanh” matches “bảo hành”.06
A wrong discount is the costliest mistake this bot can make, so dates are checked in code, never by the model.
07
Pydantic AI on FastAPI. The demo runs a free model; the production pick was chosen by measurement on the same question.
| Model | Visible reasoning | Full answer |
|---|---|---|
| nemotron-3-ultra:free (demo) | Not measured | 3.7s |
| gpt-5.4-mini (production) | Summary, from 2.7s | 3.7s |
| glm-5.3-flash | Default effort ran out of tokens | 5.7s |
| gpt-5.4-nano | None returned | 2.6s |
| gpt-5-mini | Summary, from 4.3s | 12.3s |
08
Three tools, described in their docstrings. Those descriptions are the only routing: the model reads them and decides which to call, with which arguments, and how often.
search_knowledge
search_products
escalate_to_staff
search_products(category, stone_shape) and returned NCH8501.09
Order status, complaints and custom quotes need a person. The bot offers the handoff and escalates only once the customer agrees.
10
50 questions with casual phrasing and typos, each with the exact text its answer must contain, run through the real search.
0.82
right chunk first
0.94
in the top 3
0.98
in the top 5
0.88
mean reciprocal rank
| Choice | Compared with | Result |
|---|---|---|
| Hybrid search | Vector only | Top 5: 1.00 vs 0.96 |
| text-embedding-3-large | bge-m3, text-embedding-3-small | MRR 0.90 vs 0.86 and 0.79 |
| Heading path in each chunk | No prefix | Top 5: 0.94 vs 0.88 |
| One topic per heading | Mixed-topic sections | Two questions from unfindable to found |
Design comparisons were measured on the Vietnamese knowledge base. Promotions were tested with the live agent on five dates.