Zum Inhalt springen
Business ProcessPro — €97

Adaptive RAG Framework Triggered by Webhook

100/100
30 Nodes

Beschreibung

Eine grundlegende adaptive RAG-Struktur, die durch einen Webhook ausgelöst wird, um Abfragen zu verarbeiten.

Setup-Anleitung

# 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 how to behave based on the query type (e.g., focus on precision for Factual, present diverse views for Opinion).

6.  **Document Retrieval (RAG):**
    * The `Retrieve Documents from Vector Store` node uses the adapted query/output from the strategy step to search the specified Qdrant collection (`vector_store_id`).
    * It retrieves the top relevant document chunks using Google Gemini embeddings.

7.  **Context Preparation:**
    * The content from the retrieved document chunks is concatenated (`Concatenate Context`) to form a single context block for the final answer generation.

8.  **Answer Generation:**
    * The final `Answer` agent (powered by Google Gemini) generates the response.
    * It uses:
        * The tailored system prompt set in step 5.
        * The concatenated context from retrieved documents (step 7).
        * The original `user_query`.
        * The shared chat history (`Chat Buffer Memory` using `chat_memory_key`).

9.  **Response:**
    * The generated answer is sent back to the user via the `Respond to Webhook` node.

Benötigte Integrationen (3)

Execute Workflow

ExecuteWorkflow

Summarize

Summarize

Webhook

Webhook

API Key

Workflow freischalten

Kaufe das Pro Bundle für 97 — erhalte sofortigen Zugang zu diesem und allen weiteren Starter + Pro Workflows als ZIP-Datei zum Import in n8n.

Sichere Zahlung via Stripe. 7-Tage Geld-zurück-Garantie.
← Zurück zum Marketplace