Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 13.3 — Design: A Customer-Support Assistant
RAG and Vector Search · Example 1 of 1

Hand-off and budget rules in one tested function

MIN_EVIDENCE of 0.30 is an example for a real embedding model's cosine. A real value comes from the golden set (Topic 8.4).

A worked design for a multi-tenant support assistant: fresh tickets and articles, per-customer separation, hand-off to a human, and cost limits, with the hand-off and budget rules written and run.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write should_hand_off(answered_history) where the list holds True for an answered turn and False for a refusal. Hand off when the last two entries are both False. Print the result as yes or no for three histories.

02

A dict maps tenants to tokens used today. Print, sorted by name and comma separated, the tenants whose use is at or over a limit of 500.

Explain it without notes

01

How do you keep tenants apart in a support assistant?

02

List the hand-off rules and say why their order matters.

03

How do you limit cost per customer without breaking the experience?

04

Why can containment rate mislead, and what pairs with it?

Hand-off and budget rules in one tested function
Sign in to run this example in your browser.

Expected output

clear question (best 0.82): answer with sources
weak match, first time (best 0.18): refuse and ask to rephrase
weak match again (best 0.21): hand off: second weak answer in a row
asks for a person (best 0.75): hand off: the customer asked for a person
budget used up (best 0.80): hand off: this tenant's daily budget is used up
weak match and budget used up (best 0.10): hand off: this tenant's daily budget is used up