Skip to main content
A city builds an assistant that tells residents how to renew a residence permit. On an open web search the page ranked first is a forum thread from 2019 with a fee that changed twice since. A resident who follows it comes to the office with the wrong papers. An assistant of a public body has to answer from the body’s own pages and show which page it used. This page builds that assistant.

The run in 4 steps

Name the sites that count

allowed_domains is a hard filter: only results on these sites are in the list. An entry can be a domain, every domain with one ending such as .gov, or the start of an address. source_kinds narrows the list further to sites that a public body publishes. The policy of a key can set the allowed sites for every call. An assistant that runs under such a key cannot search another site, whatever its prompt says.

Get the passages in one call

Send the resident’s question in several wordings and in each official language. contents fetches the first 3 results in the same call and finds the passages for the question in each.
Request body of search
Replace CITY_DOMAIN and MINISTRY_DOMAIN with the domains of the official sites.

Show the passage with its date

Each of the 3 pages comes back as a record with the passages that bear on each question, and with the facts of the page. This part of one record is cut to the fields that an answer shows.
Part of the response
Your assistant writes its answer from the passage and shows the passage under it, in the page’s own words, with the title of the page and its date. The resident can open the page and find the sentence. The page has an English version of its own. For a resident who writes in English, fetch that version and quote from it. Nothing is translated for you, so a quote is the page’s own text.

Know when a page changed

Fetch the pages that your answers rest on each night, with the fingerprint of each one’s last record. A page whose text changed comes back in full, and your assistant stops quoting the old sentence that day.

What the city can check

Know the limits

A model picks the passage that bears on a question, and your own model writes the answer. The passage is the page’s text, word for word. The answer is not. A page that declares no date has none. An answer then shows the day the page was read. Which version of a page binds is stated only where the page itself declares it. For the calls, see Search and get the evidence in one call and Get one ranked list from the web and from specialist datasources.