RAG, Two Ways

One retrieval-augmented generation problem, solved twice. Once as a no-code n8n workflow answering questions over WhatsApp, and once as a Python pipeline built on LlamaIndex's router query engine. Same job, two very different sets of trade-offs.

The n8n workflow end to end: WhatsApp trigger, retrieval tool, agent, reply.
The n8n workflow end to end: WhatsApp trigger, retrieval tool, agent, reply.
The chat path: the agent calls Retrieve Documents before it composes an answer.
The chat path: the agent calls Retrieve Documents before it composes an answer.
The insertion branch that chunks, embeds and fills the vector store.
The insertion branch that chunks, embeds and fills the vector store.

Why build it twice

A RAG system is easy to demo and hard to place. The interesting question is not whether retrieval works, it is which shape of system you should reach for. So I built the same capability along both routes: an orchestrated no-code workflow, and a Python pipeline with explicit control over routing and indexing.

The n8n route

A WhatsApp message hits the trigger, the agent calls a retrieval tool that runs a similarity search over a Supabase pgvector store, and the answer is written only from the passages that came back. A second branch handles ingestion: documents are chunked with a recursive splitter, embedded and inserted. Chat and embedding models both run on local Ollama, so there is no per-token cost and nothing leaves the machine.

The LlamaIndex route

Here the routing is the point. The same document is indexed twice (a summary index for whole-document questions and a vector index for specific passages) and an LLMSingleSelector reads each tool's description to decide which one should answer. Swapping between Google Gemini and a fully local Ollama backend is a config change, not a rewrite.

Highlights

More AI