This n8n workflow implements an advanced, adaptive Retrieval-Augmented Generation (RAG) system. It classifies user queries into four types — Factual, Analytical, Opinion, and Contextual — and dynamically applies tailored query adaptation, document retrieval, and answer generation strategies. Powered by Google Gemini models and Qdrant as a vector database, the workflow produces highly relevant, context-aware responses that match the intent and complexity of each query.
Features
- Intelligent Query Classification: Automatically determines the nature of each user query to ensure the best retrieval approach.
- Adaptive Strategies per Query Type:
- Factual: Enhances query precision for exact, verifiable answers.
- Analytical: Breaks down complex questions into sub-questions for deeper coverage.
- Opinion: Identifies diverse viewpoints and presents balanced perspectives.
- Contextual: Infers implied or user-specific context to improve response relevance.
- Vector Database Integration (Qdrant): Searches for relevant documents using Gemini-generated embeddings for high-quality retrieval.
- Customizable Answer Prompts: Adjusts the tone and focus of generated answers based on the query classification.
- Conversation Memory Support: Maintains chat context across interactions using memory buffers keyed per session.
- Flexible Triggering: Can be started via chat interface or called from other workflows with user_query, chat_memory_key, and vector_store_id inputs.
- End-to-End RAG Pipeline: From classification → adaptation → retrieval → context assembly → answer generation → webhook response.