Mughees Ul Haq

Work 17 / 18

A local assistant that answers from a knowledge base

A question-answering service that runs entirely on one machine: a local language model, a local vector store and a self-hosted search engine. Nothing is sent to a paid API.

For
An internal tool and a client assistant rebuild
When
2026
My part
Design and build
Routing benchmark
10 of 10
A 10-query smoke test
Direct reply
under 2 s
Greetings and small talk
API cost
$0 a month
Everything runs locally
GPU memory needed
24 GB

The problem

The assistant it replaced queried its knowledge base on every message, including ‘hello’, and it sometimes answered with links that did not exist.

What I built

A router decides, per message, whether to answer directly or to retrieve first. Greetings and small talk get a direct reply in under 2 seconds. Questions go to ChromaDB, and if the knowledge base returns nothing the service runs a web search through a self-hosted SearXNG instance. A persona file includes a rule to link the specific page an answer came from.

The service is FastAPI around Ollama. It refuses to start if Ollama is unreachable or a model is missing. A circuit breaker opens after five failed searches in a row, so the sixth call fails immediately and the breaker tries again after 60 seconds. There are 18 typed errors, with rate limiting and structured logs.

The router uses the model’s native tool-use API and falls back to a JSON classifier, because tool use was not confirmed across all quantisations.

  1. MessageFrom the chat window
  2. RouterAnswer directly or retrieve first
  3. ChromaDBSearch the knowledge base
  4. SearXNGWeb search only if the knowledge base is empty
  5. Local modelAnswers and links the page it used
One request. Small talk skips straight from the router to the model.

Limits

The routing benchmark has 10 queries, and the router got all 10 right. That is a smoke test. It needs a GPU with 24 GB of memory. It has no API bill.

From the run log

rg.01Router with two modes10 of 10 on a 10-query benchmarkShipped

Setup: Native tool-use API, falling back to a JSON classifier

Tool use with Kimi K2.5 through Ollama worked well but was not confirmed across all quantisations, so I built both paths from the start with automatic fallback. On a 10-query benchmark with a hand-written expected tool per query, it chose correctly every time.

rg.03Circuit breaker on the search backendSixth call fails with no upstream requestShipped

Setup: Threshold 5, recovery 60 s, closed / open / half-open

I tested it directly: five consecutive failures open the circuit, and the sixth call fails at once without contacting the search engine. Any exception that reaches the handler becomes a clean error event.

All 4 runs for this project

Tools

FastAPI, Ollama (Kimi K2.5), ChromaDB, nomic-embed-text, SearXNG, Docker.