Zum Inhalt springen
NEUMarktplatz und trig8n Agent: Verkaufen Sie, was Sie bauen, und erhalten Sie Pläne und Änderungen, die getestet sind, bevor Sie sie sehen. Neuigkeiten ansehen

Bibliothek / RAG & Wissensdatenbanken

RAG & Wissensdatenbanken

Fragen mit Adaptive RAG auf Gemini und Qdrant beantworten

Wenn eine Chat-Nachricht eintrifft, wird die Frage klassifiziert und eine faktische oder analytische Retrieval-Strategie über Qdrant angewendet, bevor Gemini antwortet.

Was sie bewirkt

# Adaptive RAG Workflow This n8n workflow implements a version of the Adaptive Retrieval-Augmented Generation (RAG) approach. It classifies user queries and applies different retrieval and generation strategies based on the query type (Factual, Analytical, Opinion, or Contextual) to provide more relevant and tailored answers from a knowledge base stored in a Qdrant vector store. ## How it Works 1. Input Trigger: * The workflow can be initiated via the built-in Chat interface or triggered by another n8n workflow. * It expects inputs: user_query, chat_memory_key (for conversation history), and vector_store_id (specifying the Qdrant collection). * A Set node (Combined Fields) standardizes these inputs. 2. Query Classification: * A Google Gemini agent (Query Classification) analyzes the user_query. * It classifies the query into one of four categories: * Factual: Seeking specific, verifiable information. * Analytical: Requiring comprehensive analysis or explanation. * Opinion: Asking about subjective matters or seeking diverse viewpoints. * Contextual: Depending on user-specific or implied context. 3. Adaptive Strategy Routing: * A Switch node routes the workflow based on the classification result from the previous step. 4. Strategy Implementation (Query Adaptation): * Depending on the route, a specific Google Gemini agent adapts the query or approach: * Factual Strategy: Rewrites the query for better precision, focusing on key entities (Factual Strategy - Focus on Precision). * Analytical Strategy: Breaks down the main query into multiple sub-questions to ensure comprehensive coverage (Analytical Strategy - Comprehensive Coverage). * Opinion Strategy: Identifies different potential perspectives or angles related to the query (Opinion Strategy - Diverse Perspectives). * Contextual Strategy: Infers implied context needed to answer the query effectively (Contextual Strategy - User Context Integration). * Each strategy path uses its own chat memory buffer for the adaptation step. 5. Retrieval Prompt & Output Setup: * Based on the *original* query classification, a Set node (Factual/Analytical/Opinion/Contextual Prompt and Output, combined via connections to Set Prompt and Output) prepares: * The output from the strategy step (e.g., rewritten query, sub-questions, perspectives). * A tailored system prompt for the final answer generation agent, instructing it

Die Schritte

  1. Query Classification
  2. Switch
  3. Factual Strategy - Focus on Precision
  4. Analytical Strategy - Comprehensive Coverage
  5. Opinion Strategy - Diverse Perspectives
  6. Contextual Strategy - User Context Integration
  7. Chat
  8. Factual Prompt and Output
  9. Contextual Prompt and Output
  10. Opinion Prompt and Output
  11. Analytical Prompt and Output
  12. Gemini Classification
  13. Gemini Factual
  14. Gemini Analytical

Insgesamt 30 Schritte.

Ähnliche Automatisierungen