Quick Overview
This workflow ingests documents from an FTP server into MariaDB Vector using Ollama embeddings, then provides a local chat interface that answers questions with retrieved context and caches repeated questions in a MariaDB Q&A table.
How it works
- Starts a manual ingestion run that lists and downloads a file from an FTP server and extracts its text.
- Sends the extracted text to an Ollama chat model to generate a short summary and assign a category from an allowed list.
- Splits the document text into chunks, creates embeddings with Ollama, and inserts each chunk plus its vector and metadata into a MariaDB
documents table.
- Receives a question via an n8n Chat trigger and normalizes it to look up a matching answer in the MariaDB
qa_cache table.
- If there is no cached answer, embeds the question with Ollama and retrieves the top similar chunks from MariaDB using vector distance.
- Builds a context-cited prompt from the retrieved chunks and uses an Ollama chat model to answer strictly from that context.
- Stores the new answer back into
qa_cache and returns either the cached or newly generated answer to the chat.
Setup
- Set up a MariaDB 11.7+ database with the
documents (VECTOR column) and qa_cache tables, and add an n8n MySQL/MariaDB credential.
- Run Ollama and ensure the chat and embedding models are available, then set the Ollama base URL and model names in the workflow settings nodes.
- Add an FTP credential and update the FTP path to point to the document(s) you want to ingest.
- Adjust the allowed category list for classification and the
top_k retrieval value to match your use case.