@matheusprm-nodes/n8n-nodes-tool-vector-store-custom-prompt
v0.1.9
Published
n8n community node for Vector Store QA Tool with customizable prompt
Maintainers
Readme
n8n-nodes-tool-vector-store-custom-prompt
A custom n8n community node that extends the Vector Store Question Answer Tool with editable prompt templates. This node allows you to customize the QA prompt used in RAG (Retrieval-Augmented Generation) workflows, providing more control over how AI agents answer questions using vector stores.
Features
- ✅ Customizable Prompt Template - Edit the QA prompt via UI (unlike the original node)
- ✅ Two Prompt Modes - Support for both "stuff" (PromptTemplate) and "chat" (ChatPromptTemplate) modes
- ✅ Strict Mode - Prevents AI from making inferences and requires explicit evidence from context
- ✅ Source Return - Optional return of document sources with metadata
- ✅ Full LangChain Integration - Uses VectorDBQAChain with StuffDocumentsChain
- ✅ AI Tool Compatible - Works seamlessly with n8n AI Agents
Installation
Install this node in your n8n instance:
npm install n8n-nodes-tool-vector-store-custom-promptUsage
Basic Setup
- Add the Vector Store QA Tool (Custom Prompt) node to your workflow
- Connect a Vector Store node to the first input
- Connect a Language Model (Chat Model) to the second input
- Configure the node parameters:
- Description: Describe what data is in your vector store (e.g., "imóveis, bairros e empreendimentos")
- Limit (Top-K): Number of documents to retrieve (default: 4)
- Prompt Template: Your custom QA prompt (must include
{context}and{question}) - Strict Mode: Enable to prevent AI inferences (recommended)
Connecting to AI Agent
- Add an AI Agent node to your workflow
- Enable the tool from the Vector Store QA Tool node
- The tool will be available with a sanitized name based on your node name
Example Prompt Template
Você é um assistente de QA (perguntas e respostas) que responde com base APENAS no contexto fornecido.
REGRAS CRÍTICAS:
1) Use SOMENTE as informações presentes no CONTEXTO.
2) Se a resposta não estiver explicitamente no CONTEXTO, responda exatamente: "Não encontrei essa informação no contexto disponível."
3) NÃO inferir bairros/regiões próximas, "na região", "perto de", "equivalentes" ou similares, a menos que o CONTEXTO cite isso explicitamente.
4) NÃO inventar códigos/IDs de imóveis e NÃO supor características que não estejam no CONTEXTO.
5) Se a pergunta exigir filtros (ex.: bairro X, 3 quartos, 2 vagas), só traga itens que tenham esses critérios explícitos no CONTEXTO.
CONTEXTO:
{context}
PERGUNTA:
{question}
RESPONDA de forma direta, curta e objetiva.Node Parameters
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| Description | string | "imóveis, bairros e empreendimentos" | Description of the vector store content (used in tool description) |
| Limit (Top-K) | number | 4 | Maximum number of documents to retrieve in similarity search |
| Prompt Mode | options | "stuff" | Prompt mode: "stuff" (PromptTemplate) or "chat" (ChatPromptTemplate) |
| Document Variable Name | string | "context" | Variable name in template that receives the context (must match {context} in prompt) |
| Strict Mode | boolean | true | When enabled, injects reinforcements to prevent inference and require explicit evidence |
| Return Sources | boolean | false | When enabled, returns a SOURCES section with document metadata |
| Prompt Template | string | (see default above) | Editable prompt used to combine documents from vector store |
Differences from Original Node
| Aspect | Original toolVectorStore | This Node |
|--------|---------------------------|-----------|
| Prompt | Fixed LangChain default (not editable) | Editable via UI |
| Customization | Limited | Full control over instructions, tone, response format |
| Use Cases | Generic | Specific business needs (e.g., real estate, internal docs) |
Requirements
- n8n: Version 1.0.0 or higher
- langchain: ^0.3.0 (peer dependency)
- @langchain/core: ^0.3.0 (peer dependency)
Development
Prerequisites
- Node.js v22 or higher
- npm
Setup
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Lint code
npm run lintTroubleshooting
Node doesn't appear in n8n
- Make sure you ran
npm install - Check that the node is listed in
package.jsonundern8n.nodes - Restart n8n
- Check console for error messages
"Cannot find module 'langchain'"
This usually means langchain dependencies are not installed. Ensure you have:
langchain^0.3.0@langchain/core^0.3.0
These should be available in your n8n environment.
Invalid prompt template
The node validates that your prompt template includes:
{context}(or the name configured in "Document Variable Name"){question}(required in "stuff" mode)
Make sure both placeholders are present in your template.
License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions:
