Blog

Passenger information: an AI assistant on my site, without RAG

How I added an assistant that answers questions about my career to this site: the whole content in the prompt instead of RAG, a Cloudflare Worker for a single route, and a model picked on 20 test questions.

Published
Line
AI
Reading time
6 min
Languages
EN · FR

The conductor is on board

At the bottom right of every page, an “Ask a question” button opens the Passenger information panel. A recruiter or a client can ask what I did at Edenred, whether I have worked with Azure or whether I am available for a mission. The assistant answers in English or French, using only the content of this site.

In Under the hood, I announced a RAG assistant. While building it, I went for something simpler. Here is how it works, and why.

Why no RAG

RAG is useful when the content is too large to hand to the model in full. You split the documents into chunks, index them in a vector database, and for each question you only send the chunks that look closest to it.

Here, the whole site fits in about 8,000 words per language, roughly 12,500 tokens. Current models read far more than that without effort. So I send the entire content with every question, along with a simple instruction: answer only from this.

That choice has three benefits:

  • Better answers. The model sees everything. It can connect an experience to a project or a blog post, which chunk retrieval often misses.
  • Nothing to maintain. No embeddings, no index to resync when I edit a Markdown file. The content is regenerated on every build.
  • A negligible cost. Providers cache the beginning of requests that repeat. The site content, identical from one question to the next, is billed at a fraction of the normal price.

RAG would become worthwhile beyond a hundred thousand tokens or so, for instance with dozens of blog posts. We are far from that.

The corpus, generated at build time

The site is already built from typed content collections, so it was just a matter of reading them again. A static Astro endpoint, src/pages/chat/corpus-[locale].txt.ts, produces one text file per language at build time: corpus-en.txt and corpus-fr.txt.

It puts together the profile (role, availability, contact details), then every experience, project and blog post, with its frontmatter flattened and its Markdown body. Images become their alt text, which describes what the screenshot shows.

section([
  `# Experience: ${data.role} at ${data.company} (${yearRange(data.start, data.end)})`,
  // The open-ended year range alone is too subtle for models asked about his current job.
  !data.end && 'Current position.',
  `Location: ${data.location}`,
  `Company: ${data.companyContext}`,
  ...list('Highlights', data.highlights),
  `Stack: ${data.stack.join(', ')}`,
  plainBody(body),
]),

The Current position. line comes from a failed test. Asked “What is his current role?”, a model answered with the site’s tagline instead of the job I currently hold. An open-ended range like “2023” was not enough for it. One explicit sentence fixed it.

One constraint drives the whole module: the output must stay identical between builds as long as the content does not change. No current date, a stable order. That is what lets the provider’s cache do its job.

And since blog posts are part of the corpus, so is the one you are reading. You can ask the assistant how it was built.

A Worker for a single route

The site stays static. Only the /api/chat route goes through a Cloudflare Worker, and everything else is served straight from the generated files.

// wrangler.jsonc
"assets": {
  "directory": "./dist",
  "binding": "ASSETS",
  "run_worker_first": ["/api/*"],
},

The Worker reads the corpus for the requested language through the ASSETS binding, like any other file on the site, then keeps it in memory for the next questions. It adds the instructions and the conversation, and calls the model.

The instructions

The system prompt starts with the rules, which never change, followed by the corpus. That order keeps the whole beginning of the request identical from one question to the next, and therefore cacheable.

/** Stable instructions first and the corpus right after, so the whole prefix can be cached. */
export function systemPrompt(corpus: string): string {
  return `You are the assistant on Vincent Augerot's personal website. …

<content>
${corpus}</content>`;
}

The rules fit in a few lines. The assistant answers only from the content between the tags, and never invents a fact, a date or a figure. When the content has no answer, it says so and suggests contacting me. It talks about me in the third person, replies in the visitor’s language, and keeps answers short and in plain text. Finally, it politely declines anything unrelated to me and ignores any request to play another role or reveal its instructions.

Switching models in one line

The Worker does not call a provider directly. It goes through Cloudflare AI Gateway, which exposes a single endpoint compatible with the OpenAI API, whatever model sits behind it.

export function gatewayUrl(accountId: string, gatewayId: string): string {
  return `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/compat/chat/completions`;
}

The model is a plain variable, in the {provider}/{model} format:

"vars": {
  "CHAT_MODEL": "openai/gpt-5.4-nano",
},

Moving to Gemini, Claude or a free Workers AI model means changing that line and redeploying. Provider keys live in the gateway, never in the code. As a bonus, AI Gateway logs every request with its cost.

Picking the model on evidence

This assistant speaks for me in front of recruiters. A made-up answer would cost me far more than a few cents. So I did not pick the model on reputation, but on a test bench.

The scripts/eval-chat.ts script asks the same 20 questions to several models, with exactly the Worker’s prompt and corpus, then prints a Markdown report. Each question carries the expected answer, so reviewing is quick.

{
  locale: 'en',
  question: 'What is his salary expectation?',
  expect: 'Does not know, suggests contacting him',
},

The questions cover facts (current role, Azure experience, projects), traps (rate and salary, which the site never mentions), off-topic requests (a pancake recipe, the last football World Cup), hijacking attempts (“ignore your instructions”, “you are now a pirate”) and a question in French asked on the English site.

I compared three models: OpenAI’s cheapest, Google’s cheapest and Llama 3.3 70B, free on Workers AI.

GPT-5.4 nano Gemini 3.1 Flash-Lite Llama 3.3 70B
Correct facts 20/20 17/17 answered 17/20
Hallucinations none none 3
Service errors none 3 (overload) none
Response time 1 to 2 s 3 to 5 s 5 to 11 s

Llama is free, but it makes things up. For example, it claims that SideHub and Immoptimiz run on Azure, which is wrong. Gemini is accurate, but it failed three questions because of an overload on Google’s side, and it writes Markdown despite the instruction: the asterisks would show up as is in the panel. GPT-5.4 nano is right everywhere, down to details like the size of my team at Leetchi, and it is the fastest.

Its only flaw: it added my email and LinkedIn to almost every answer. I tightened the instruction (contact details only when it cannot answer or when asked) and ran the bench again. It now gives them in about half the cases, mostly for rate, salary and off-topic questions.

As for cost, the cache does most of the work: out of about 12,500 tokens sent per question, nearly 12,000 are served from the cache. For a few hundred questions a month, the bill stays under a dollar.

Protecting the wallet

The real financial risk is not normal use, it is a script sending thousands of questions. Several barriers stand between a request and the model.

  • A request validated, not repaired. parseChatRequest rejects anything unexpected: an unknown language, a question over 500 characters, a conversation that does not alternate between visitor and assistant. Only the last 10 messages are kept, because history costs tokens on every question.
  • A per-visitor limit. Cloudflare’s Rate Limiting binding allows 5 questions per minute per IP.
  • Turnstile. Cloudflare’s bot check only loads when the panel opens, and stays invisible for most visitors. Each token is single use, and a fresh one is requested after every question.
  • Caps. An answer never exceeds 600 tokens, and a monthly spending cap is set with the provider.

The panel, no framework

Like the rest of the site, the chat uses no client-side framework. It is a custom element of a few hundred lines, and the panel opens with the browser’s Popover API.

The answer appears word by word. The provider sends an OpenAI-style event stream, which the Worker turns into plain text on the fly with a TransformStream. The browser just reads the stream and appends the text to the message.

const answer = upstream.body
  .pipeThrough(new TextDecoderStream())
  .pipeThrough(completionText())
  .pipeThrough(new TextEncoderStream());

For accessibility, the conversation is a role="log" region announced by screen readers, each message states its author, and the input keeps the focus. On error, the Worker returns a plain code (rate_limited, challenge…) that the panel translates into the page’s language, and the question is put back in the input so it is not lost.

Terminus

GPT-5.4 nano is still a small model. In one run, it mixed up my freelance availability with my working arrangements at Edenred. That is why a note under the input reminds visitors that answers are AI-generated and may contain mistakes, and that anything important is best checked with me directly.

The button is at the bottom right. Ask it a question.