๐ Build a dual-stage RAG chat assistant with Google Drive, Ollama, Pinecone and Gemini
โก 6 views ยท ๐ Internal Wiki & Knowledge Base
Description
Quick overview
This template builds a dual-stage RAG system that ingests PDFs/text from Google Drive into a Pinecone knowledge-base index with Ollama embeddings, and serves chat queries via a Pinecone semantic cache that falls back to a Google Gemini AI Agent with vector retrieval.
How it works
- Triggers on a Google Drive folder update (or manually) to list and download files from a specified Drive folder.
- Detects whether each file is a PDF or plain text and extracts the document text accordingly.
- Splits extracted content into overlapping chunks, embeds them with Ollama (nomic-embed-text), and inserts the vectors into a Pinecone index for the knowledge base.
- Triggers when a chat message is received and embeds the user query with Ollama to search the Pinecone semantic-cache index for the closest prior answer.
- Returns the cached answer immediately when the best match score is at least 0.88.
- On a cache miss, uses a Google Gemini AI Agent with conversation memory and a Pinecone vector-store retrieval tool to generate a grounded answer from the knowledge-base index.
- Stores the new query-and-answer pair back into the Pinecone semantic-cache index for faster responses to future similar questions.
Setup
- Create two Pinecone indexes using cosine similarity and 768 dimensions: one for the knowledge base (e.g.
nomic-embed-text) and one for the semantic cache (e.g.rag-semantic-cache). - Set up Pinecone credentials in n8n and select the correct index names in the Pinecone vector store nodes.
- Run Ollama and pull the
nomic-embed-textmodel, then configure Ollama credentials/base URL in n8n. - Add Google Drive OAuth2 credentials and replace
YOUR_GOOGLE_DRIVE_FOLDER_IDwith the folder you want to ingest. - Add a Google Gemini API key and confirm the model name (for example
models/gemini-1.5-flash) in both Gemini chat model nodes. - If you use the chat trigger via webhook, copy the chat/webhook URL from n8n and configure your client to send messages to it.
๐ Nodes Used
Google Drive, Google Drive Trigger, AI Agent, Simple Memory, Pinecone Vector Store, Extract from File
๐ฅ Import
Download workflow.json and import into n8n:
Workflow menu โ Import from File