RAG 2.0 - Schéma de réponse

Avancé

Ceci est unBuilding Blocks, AIworkflow d'automatisation du domainecontenant 40 nœuds.Utilise principalement des nœuds comme Set, Switch, Summarize, Agent, RespondToWebhook, combinant la technologie d'intelligence artificielle pour une automatisation intelligente. RAG adaptatif (Google Gemini et Qdrant) : réponses contextuelles aux requêtes

Prérequis
  • Point de terminaison HTTP Webhook (généré automatiquement par n8n)
  • Informations de connexion au serveur Qdrant
  • Clé API Google Gemini
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "id": "uZtDG9wLeCBZbaoK",
  "meta": {
    "instanceId": "2848b874676d610ec8f8106a5acf41448278a62b14e4a776b42d6977aab508d7",
    "templateId": "3459"
  },
  "name": "RAG 2.0 - Answer Architecture",
  "tags": [],
  "nodes": [
    {
      "id": "856bd809-8f41-41af-8f72-a3828229c2a5",
      "name": "Classification de la requête",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Classify a query into one of four categories: Factual, Analytical, Opinion, or Contextual.\n        \nReturns:\nstr: Query category",
      "position": [
        420,
        340
      ],
      "parameters": {
        "text": "=Classify this query: {{ $('Combined Fields').item.json.user_query }}",
        "options": {
          "systemMessage": "You are an expert at classifying questions. \n\nClassify the given query into exactly one of these categories:\n- Factual: Queries seeking specific, verifiable information.\n- Analytical: Queries requiring comprehensive analysis or explanation.\n- Opinion: Queries about subjective matters or seeking diverse viewpoints.\n- Contextual: Queries that depend on user-specific context.\n\nReturn ONLY the category name, without any explanation or additional text."
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "cc2106fc-f1a8-45ef-b37b-ab981ac13466",
      "name": "Commutateur",
      "type": "n8n-nodes-base.switch",
      "position": [
        780,
        380
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Factual",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "87f3b50c-9f32-4260-ac76-19c05b28d0b4",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.trim() }}",
                    "rightValue": "Factual"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Analytical",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f8651b36-79fa-4be4-91fb-0e6d7deea18f",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.trim() }}",
                    "rightValue": "Analytical"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Opinion",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5dde06bc-5fe1-4dca-b6e2-6857c5e96d49",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.trim() }}",
                    "rightValue": "Opinion"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Contextual",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bf97926d-7a0b-4e2f-aac0-a820f73344d8",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.trim() }}",
                    "rightValue": "Contextual"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": 0
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "63889cad-1283-4dbf-ba16-2b6cf575f24a",
      "name": "Stratégie factuelle - Précision ciblée",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Retrieval strategy for factual queries focusing on precision.",
      "position": [
        1180,
        -440
      ],
      "parameters": {
        "text": "=Enhance this factual query: {{ $('Combined Fields').item.json.user_query }}",
        "options": {
          "systemMessage": "=You are an expert at enhancing search queries.\n\nYour task is to reformulate the given factual query to make it more precise and specific for information retrieval. Focus on key entities and their relationships.\n\nProvide ONLY the enhanced query without any explanation."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "020d2201-9590-400d-b496-48c65801271c",
      "name": "Stratégie analytique - Couverture exhaustive",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Retrieval strategy for analytical queries focusing on comprehensive coverage.",
      "position": [
        1180,
        140
      ],
      "parameters": {
        "text": "=Generate sub-questions for this analytical query: {{ $('Combined Fields').item.json.user_query }}",
        "options": {
          "systemMessage": "=You are an expert at breaking down complex questions.\n\nGenerate sub-questions that explore different aspects of the main analytical query.\nThese sub-questions should cover the breadth of the topic and help retrieve comprehensive information.\n\nReturn a list of exactly 3 sub-questions, one per line."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "c35d1b95-68c8-4237-932d-4744f620760d",
      "name": "Stratégie d'opinion - Perspectives diversifiées",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Retrieval strategy for opinion queries focusing on diverse perspectives.",
      "position": [
        1220,
        700
      ],
      "parameters": {
        "text": "=Identify different perspectives on: {{ $('Combined Fields').item.json.user_query }}",
        "options": {
          "systemMessage": "=You are an expert at identifying different perspectives on a topic.\n\nFor the given query about opinions or viewpoints, identify different perspectives that people might have on this topic.\n\nReturn a list of exactly 3 different viewpoint angles, one per line."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "363a3fc3-112f-40df-891e-0a5aa3669245",
      "name": "Stratégie contextuelle - Intégration du contexte utilisateur",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Retrieval strategy for contextual queries integrating user context.",
      "position": [
        1180,
        1320
      ],
      "parameters": {
        "text": "=Infer the implied context in this query: {{ $('Combined Fields').item.json.user_query }}",
        "options": {
          "systemMessage": "=You are an expert at understanding implied context in questions.\n\nFor the given query, infer what contextual information might be relevant or implied but not explicitly stated. Focus on what background would help answering this query.\n\nReturn a brief description of the implied context."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "45887701-5ea5-48b4-9b2b-40a80238ab0c",
      "name": "Chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        0,
        640
      ],
      "webhookId": "56f626b5-339e-48af-857f-1d4198fc8a4d",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "7f7df364-4829-4e29-be3d-d13a63f65b8f",
      "name": "Invite et sortie factuelles",
      "type": "n8n-nodes-base.set",
      "position": [
        1640,
        -300
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a4a28ac2-4a56-46f6-8b86-f5d1a34b2ced",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "7aa6ce13-afbf-4871-b81c-6e9c722a53dc",
              "name": "prompt",
              "type": "string",
              "value": "You are a helpful assistant providing factual information. Answer the question based on the provided context. Focus on accuracy and precision. If the context doesn't contain the information needed, acknowledge the limitations."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "590d8667-69eb-4db2-b5be-714c602b319a",
      "name": "Invite et sortie contextuelles",
      "type": "n8n-nodes-base.set",
      "position": [
        1640,
        1400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a4a28ac2-4a56-46f6-8b86-f5d1a34b2ced",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "7aa6ce13-afbf-4871-b81c-6e9c722a53dc",
              "name": "prompt",
              "type": "string",
              "value": "You are a helpful assistant providing contextually relevant information. Answer the question considering both the query and its context. Make connections between the query context and the information in the provided documents. If the context doesn't fully address the specific situation, acknowledge the limitations."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fa3228ee-62d8-4c02-9dca-8a1ebc6afc74",
      "name": "Invite et sortie d'opinion",
      "type": "n8n-nodes-base.set",
      "position": [
        1620,
        820
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a4a28ac2-4a56-46f6-8b86-f5d1a34b2ced",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "7aa6ce13-afbf-4871-b81c-6e9c722a53dc",
              "name": "prompt",
              "type": "string",
              "value": "You are a helpful assistant discussing topics with multiple viewpoints. Based on the provided context, present different perspectives on the topic. Ensure fair representation of diverse opinions without showing bias. Acknowledge where the context presents limited viewpoints."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c769a76a-fb26-46a1-a00d-825b689d5f7a",
      "name": "Invite et sortie analytiques",
      "type": "n8n-nodes-base.set",
      "position": [
        1620,
        220
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a4a28ac2-4a56-46f6-8b86-f5d1a34b2ced",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "7aa6ce13-afbf-4871-b81c-6e9c722a53dc",
              "name": "prompt",
              "type": "string",
              "value": "You are a helpful assistant providing analytical insights. Based on the provided context, offer a comprehensive analysis of the topic. Cover different aspects and perspectives in your explanation. If the context has gaps, acknowledge them while providing the best analysis possible."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fcd29f6b-17e8-442c-93f9-b93fbad7cd10",
      "name": "Gemini Classification",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        580,
        600
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "vGGCUG66DLA8zNyX",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c0828ee3-f184-41f5-9a25-0f1059b03711",
      "name": "Gemini Factuel",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1240,
        -240
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "vGGCUG66DLA8zNyX",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "98f9981d-ea8e-45cb-b91d-3c8d1fe33e25",
      "name": "Gemini Analytique",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1240,
        340
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "vGGCUG66DLA8zNyX",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c85f270d-3224-4e60-9acf-91f173dfe377",
      "name": "Mémoire tampon de chat analytique",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1400,
        340
      ],
      "parameters": {
        "sessionKey": "={{ $('Combined Fields').item.json.chat_memory_key }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "c39ba907-7388-4152-965a-e28e626bc9b2",
      "name": "Mémoire tampon de chat factuelle",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1400,
        -240
      ],
      "parameters": {
        "sessionKey": "={{ $('Combined Fields').item.json.chat_memory_key }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "52dcd9f0-e6b3-4d33-bc6f-621ef880178e",
      "name": "Gemini Opinion",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1280,
        900
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "vGGCUG66DLA8zNyX",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "147a709a-4b46-4835-82cf-7d6b633acd4c",
      "name": "Mémoire tampon de chat d'opinion",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1440,
        900
      ],
      "parameters": {
        "sessionKey": "={{ $('Combined Fields').item.json.chat_memory_key }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "3cb6bf32-5937-49b9-acf7-d7d01dc2ddd1",
      "name": "Gemini Contextuel",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1240,
        1500
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "vGGCUG66DLA8zNyX",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5916c4f1-4369-4d66-8553-2fff006b7e69",
      "name": "Mémoire tampon de chat contextuelle",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1420,
        1500
      ],
      "parameters": {
        "sessionKey": "={{ $('Combined Fields').item.json.chat_memory_key }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "d33377c2-6b98-4e4d-968f-f3085354ae50",
      "name": "Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "notes": "{ $node[\"Embeddings\"].json.response }}",
      "position": [
        2400,
        600
      ],
      "parameters": {
        "modelName": "models/text-embedding-004"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "vGGCUG66DLA8zNyX",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "32d9a0c0-0889-4cb2-a088-8ee9cfecacd3",
      "name": "Note adhésive",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        -600
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 520,
        "content": "## Factual Strategy\n**Retrieve precise facts and figures.**\n## Olgusal Strateji\n**Kesin gerçeklere ve rakamlara ulaşın.**"
      },
      "typeVersion": 1
    },
    {
      "id": "064a4729-717c-40c8-824a-508406610a13",
      "name": "Note adhésive1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        -40
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 520,
        "content": "## Analytical Strategy\n**Provide comprehensive coverage of a topics and exploring different aspects.**\n## Analitik Strateji\n**Bir konunun kapsamlı bir şekilde ele alınmasını ve farklı yönlerinin keşfedilmesini sağlar.**"
      },
      "typeVersion": 1
    },
    {
      "id": "9fd52a28-44bc-4dfd-bdb7-90987cc2f4fb",
      "name": "Note adhésive2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        520
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 520,
        "content": "## Opinion Strategy\n**Gather diverse viewpoints on a subjective issue.**\n## Görüş Stratejisi\n**Öznel bir konuda farklı bakış açıları toplayın.**"
      },
      "typeVersion": 1
    },
    {
      "id": "3797b21f-cc2a-4210-aa63-6d181d413c5e",
      "name": "Note adhésive3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        1100
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 540,
        "content": "## Contextual Strategy\n**Incorporate user-specific context to fine-tune the retrieval.**\n## Bağlamsal Strateji\n**Getirmeye ince ayar yapmak için kullanıcıya özgü bağlamı dahil edin.**"
      },
      "typeVersion": 1
    },
    {
      "id": "16fa1531-9fb9-4b12-961c-be12e20b2134",
      "name": "Concaténer le contexte",
      "type": "n8n-nodes-base.summarize",
      "position": [
        2900,
        380
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "document.pageContent",
              "separateBy": "other",
              "aggregation": "concatenate",
              "customSeparator": "={{ \"\\n\\n---\\n\\n\" }}"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "4d6147d1-7a3d-42ab-b23f-cdafe8ea30b0",
      "name": "Récupérer les documents du Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        2140,
        380
      ],
      "parameters": {
        "mode": "load",
        "topK": 10,
        "prompt": "=Prompt\n{{ $json.prompt }}\n\nUser query: \n{{ $json.output }}",
        "options": {},
        "qdrantCollection": {
          "__rl": true,
          "mode": "id",
          "value": "=vector_store_id"
        }
      },
      "credentials": {
        "qdrantApi": {
          "id": "ivp7KsCQyRCs5owS",
          "name": "QdrantApi account"
        }
      },
      "executeOnce": false,
      "notesInFlow": false,
      "retryOnFail": false,
      "typeVersion": 1.1,
      "alwaysOutputData": false
    },
    {
      "id": "7e68f9cb-0a0d-4215-8083-3b9ef92cd237",
      "name": "Définir l'invite et la sortie",
      "type": "n8n-nodes-base.set",
      "position": [
        1900,
        460
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1d782243-0571-4845-b8fe-4c6c4b55379e",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "547091fb-367c-44d4-ac39-24d073da70e0",
              "name": "prompt",
              "type": "string",
              "value": "={{ $json.prompt }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0c623ca1-da85-48a3-9d8b-90d97283a015",
      "name": "Gemini Réponse",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3340,
        620
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "vGGCUG66DLA8zNyX",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fab91e48-1c62-46a8-b9fc-39704f225274",
      "name": "Réponse",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3120,
        380
      ],
      "parameters": {
        "text": "=User query: {{ $('Combined Fields').item.json.user_query }}",
        "options": {
          "systemMessage": "={{ $('Set Prompt and Output').item.json.prompt }}\n\nUse the following context (delimited by <ctx></ctx>) and the chat history to answer the user query.\n<ctx>\n{{ $json.concatenated_document_pageContent }}\n</ctx>"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "d69f8d62-3064-40a8-b490-22772fbc38cd",
      "name": "Mémoire tampon de chat",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        3500,
        620
      ],
      "parameters": {
        "sessionKey": "={{ $('Combined Fields').item.json.chat_memory_key }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "a399f8e6-fafd-4f73-a2de-894f1e3c4bec",
      "name": "Note adhésive4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1860,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 820,
        "height": 580,
        "content": "## Perform adaptive retrieval\n**Find document considering both query and context.**\n## Uyarlanabilir RAG gerçekleştirin\n**Hem sorguyu hem de bağlamı dikkate alarak belge bulun.**"
      },
      "typeVersion": 1
    },
    {
      "id": "7f10fe70-1af8-47ad-a9b5-2850412c43f8",
      "name": "Note adhésive5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2760,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 1060,
        "height": 580,
        "content": "## Reply to the user integrating retrieval context\n## Kullanıcıya RAG bağlamını entegre ederek yanıt verin"
      },
      "typeVersion": 1
    },
    {
      "id": "5cd0dd02-65f4-4351-aeae-c70ecf5f1d66",
      "name": "Répondre à Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        3540,
        400
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "4c56ef8f-8fce-4525-bb87-15df37e91cc4",
      "name": "Note adhésive6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 580,
        "content": "## User query classification\n**Classify the query into one of four categories: Factual, Analytical, Opinion, or Contextual.**\n## Kullanıcı sorgu sınıflandırması\n**Sorguyu dört kategoriden birine sınıflandırın: Olgusal, Analitik, Görüş veya Bağlamsal.**\n"
      },
      "typeVersion": 1
    },
    {
      "id": "3ef73405-89de-4bed-9673-90e2c1f2e74b",
      "name": "Lors de l'exécution par un autre workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        0,
        340
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "user_query"
            },
            {
              "name": "chat_memory_key"
            },
            {
              "name": "vector_store_id"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "0785714f-c45c-4eda-9937-c97e44c9a449",
      "name": "Champs combinés",
      "type": "n8n-nodes-base.set",
      "position": [
        140,
        480
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "90ab73a2-fe01-451a-b9df-bffe950b1599",
              "name": "user_query",
              "type": "string",
              "value": "={{ $json.user_query || $json.chatInput }}"
            },
            {
              "id": "36686ff5-09fc-40a4-8335-a5dd1576e941",
              "name": "chat_memory_key",
              "type": "string",
              "value": "={{ $json.chat_memory_key || $('Chat').item.json.sessionId }}"
            },
            {
              "id": "4230c8f3-644c-4985-b710-a4099ccee77c",
              "name": "vector_store_id",
              "type": "string",
              "value": "={{ $json.vector_store_id || \"<ID HERE>\" }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "57a93b72-4233-4ba2-b8c7-99d88f0ed572",
      "name": "Note adhésive7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1420,
        -560
      ],
      "parameters": {
        "color": 3,
        "width": 1280,
        "height": 1680,
        "content": "# Uyarlanabilir RAG İş Akışı\n\nBu n8n iş akışı, Uyarlanabilir Geri Getirme Destekli Üretim (Adaptive RAG) yaklaşımının bir versiyonunu uygular. Kullanıcı sorgularını sınıflandırır ve sorgu türüne (Olgusal, Analitik, Görüş veya Bağlamsal) göre farklı geri getirme ve üretim stratejileri uygulayarak bir Qdrant vektör deposunda saklanan bilgi tabanından daha alakalı ve özel yanıtlar sunar.\n\n## Nasıl Çalışır?\n\n### Giriş Tetikleyicisi\n\n- İş akışı, yerleşik Sohbet arayüzü aracılığıyla veya başka bir n8n iş akışı tarafından tetiklenebilir.\n- Girdiler beklenir: `user_query` (kullanıcı sorgusu), `chat_memory_key` (konuşma geçmişi için) ve `vector_store_id` (Qdrant koleksiyonunu belirten).\n- Bir `Set` düğümü (`Combined Fields` - Birleştirilmiş Alanlar) bu girdileri standartlaştırır.\n\n### Sorgu Sınıflandırması\n\n- Bir Google Gemini ajanı (`Query Classification` - Sorgu Sınıflandırması) `user_query`'yi analiz eder.\n- Sorguyu dört kategoriden birine sınıflandırır:\n  - **Olgusal:** Belirli, doğrulanabilir bilgi arayan.\n  - **Analitik:** Kapsamlı analiz veya açıklama gerektiren.\n  - **Görüş:** Öznel konular hakkında soru soran veya farklı bakış açıları arayan.\n  - **Bağlamsal:** Kullanıcıya özel veya örtük bağlama bağlı olan.\n\n### Uyarlanabilir Strateji Yönlendirmesi\n\n- Bir `Switch` düğümü (Yönlendirme Düğümü), iş akışını bir önceki adımdaki sınıflandırma sonucuna göre yönlendirir.\n\n### Strateji Uygulaması (Sorgu Uyarlaması)\n\n- Yönlendirmeye bağlı olarak, belirli bir Google Gemini ajanı sorguyu veya yaklaşımı uyarlar:\n  - **Olgusal Strateji:** Anahtar varlıklara odaklanarak daha iyi kesinlik için sorguyu yeniden yazar (`Factual Strategy - Focus on Precision` - Olgusal Strateji - Kesinliğe Odaklanma).\n  - **Analitik Strateji:** Kapsamlı bir şekilde ele alınmasını sağlamak için ana sorguyu birden fazla alt soruya böler (`Analytical Strategy - Comprehensive Coverage` - Analitik Strateji - Kapsamlı Ele Alma).\n  - **Görüş Stratejisi:** Sorguyla ilgili farklı potansiyel bakış açılarını veya yaklaşımları tanımlar (`Opinion Strategy - Diverse Perspectives` - Görüş Stratejisi - Farklı Bakış Açıları).\n  - **Bağlamsal Strateji:** Sorguyu etkili bir şekilde yanıtlamak için gereken örtük bağlamı çıkarır (`Contextual Strategy - User Context Integration` - Bağlamsal Strateji - Kullanıcı Bağlamı Entegrasyonu).\n- Her strateji yolu, uyarlama adımı için kendi sohbet belleği tamponunu kullanır.\n\n### Geri Getirme İstemcisi ve Çıktı Kurulumu\n\n- *Orijinal* sorgu sınıflandırmasına dayanarak, bir `Set` düğümü (`Factual/Analytical/Opinion/Contextual Prompt and Output` - Olgusal/Analitik/Görüş/Bağlamsal İstemci ve Çıktı, `Set Prompt and Output` - İstemci ve Çıktı Ayarla düğümüne bağlantılar aracılığıyla birleştirilir) şunları hazırlar:\n  - Strateji adımından gelen çıktı (örneğin, yeniden yazılmış sorgu, alt sorular, bakış açıları).\n  - Son yanıt üretim ajanı için özel olarak hazırlanmış bir sistem istemcisi; sorgu türüne göre nasıl davranacağını belirtir (örneğin, Olgusal için kesinliğe odaklan, Görüş için farklı görüşler sun).\n\n### Belge Geri Getirme (RAG)\n\n- `Retrieve Documents from Vector Store` (Vektör Deposundan Belgeleri Geri Getir) düğümü, belirtilen Qdrant koleksiyonunda (`vector_store_id`) arama yapmak için strateji adımından gelen uyarlanmış sorguyu/çıktıyı kullanır.\n- Google Gemini gömülerini (vektörlerini) kullanarak en alakalı belge parçalarını geri getirir.\n\n### Bağlam Hazırlığı\n\n- Geri getirilen belge parçalarından elde edilen içerik, son yanıt üretimi için tek bir bağlam bloğu oluşturmak üzere birleştirilir (`Concatenate Context` - Bağlamı Birleştir).\n\n### Yanıt Üretimi\n\n- Son `Answer` (Yanıt) ajanı (Google Gemini tarafından desteklenir) yanıtı üretir.\n- Şunları kullanır:\n  - 5. adımda ayarlanan özel sistem istemcisi.\n  - Geri getirilen belgelerden birleştirilmiş bağlam (7. adım).\n  - Orijinal `user_query`.\n  - Paylaşılan sohbet geçmişi (`Chat Buffer Memory` - Sohbet Belleği Tamponu, `chat_memory_key` kullanılarak).\n\n### Yanıt\n\n- Üretilen yanıt, `Respond to Webhook` (Webhook'a Yanıt Ver) düğümü aracılığıyla kullanıcıya geri gönderilir.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "bec8070f-2ce9-4930-b71e-685a2b21d3f2",
      "name": "Note adhésive8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -20
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 820,
        "content": "## ⚠️  Using in Chat mode\n\nUpdate the `vector_store_id` variable to the corresponding Qdrant ID needed to perform the documents retrieval.\n\n## ⚠️ Sohbet modunda kullanım sağlayın\n\nvector_store_id` değişkenini belge alımını gerçekleştirmek için gereken ilgili Qdrant ID'sine güncelleyin."
      },
      "typeVersion": 1
    },
    {
      "id": "dc002d7a-df79-4d61-880a-db32917d9814",
      "name": "Note adhésive9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1220,
        580
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {},
  "versionId": "fbee3fa8-a249-4841-b786-817f0992ae6b",
  "connections": {
    "45887701-5ea5-48b4-9b2b-40a80238ab0c": {
      "main": [
        [
          {
            "node": "0785714f-c45c-4eda-9937-c97e44c9a449",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fab91e48-1c62-46a8-b9fc-39704f225274": {
      "main": [
        [
          {
            "node": "5cd0dd02-65f4-4351-aeae-c70ecf5f1d66",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cc2106fc-f1a8-45ef-b37b-ab981ac13466": {
      "main": [
        [
          {
            "node": "63889cad-1283-4dbf-ba16-2b6cf575f24a",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "020d2201-9590-400d-b496-48c65801271c",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "c35d1b95-68c8-4237-932d-4744f620760d",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "363a3fc3-112f-40df-891e-0a5aa3669245",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d33377c2-6b98-4e4d-968f-f3085354ae50": {
      "ai_embedding": [
        [
          {
            "node": "4d6147d1-7a3d-42ab-b23f-cdafe8ea30b0",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "0c623ca1-da85-48a3-9d8b-90d97283a015": {
      "ai_languageModel": [
        [
          {
            "node": "fab91e48-1c62-46a8-b9fc-39704f225274",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "c0828ee3-f184-41f5-9a25-0f1059b03711": {
      "ai_languageModel": [
        [
          {
            "node": "63889cad-1283-4dbf-ba16-2b6cf575f24a",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "52dcd9f0-e6b3-4d33-bc6f-621ef880178e": {
      "ai_languageModel": [
        [
          {
            "node": "c35d1b95-68c8-4237-932d-4744f620760d",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "0785714f-c45c-4eda-9937-c97e44c9a449": {
      "main": [
        [
          {
            "node": "856bd809-8f41-41af-8f72-a3828229c2a5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "98f9981d-ea8e-45cb-b91d-3c8d1fe33e25": {
      "ai_languageModel": [
        [
          {
            "node": "020d2201-9590-400d-b496-48c65801271c",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "3cb6bf32-5937-49b9-acf7-d7d01dc2ddd1": {
      "ai_languageModel": [
        [
          {
            "node": "363a3fc3-112f-40df-891e-0a5aa3669245",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "d69f8d62-3064-40a8-b490-22772fbc38cd": {
      "ai_memory": [
        [
          {
            "node": "fab91e48-1c62-46a8-b9fc-39704f225274",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "16fa1531-9fb9-4b12-961c-be12e20b2134": {
      "main": [
        [
          {
            "node": "fab91e48-1c62-46a8-b9fc-39704f225274",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "856bd809-8f41-41af-8f72-a3828229c2a5": {
      "main": [
        [
          {
            "node": "cc2106fc-f1a8-45ef-b37b-ab981ac13466",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fcd29f6b-17e8-442c-93f9-b93fbad7cd10": {
      "ai_languageModel": [
        [
          {
            "node": "856bd809-8f41-41af-8f72-a3828229c2a5",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "7e68f9cb-0a0d-4215-8083-3b9ef92cd237": {
      "main": [
        [
          {
            "node": "4d6147d1-7a3d-42ab-b23f-cdafe8ea30b0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7f7df364-4829-4e29-be3d-d13a63f65b8f": {
      "main": [
        [
          {
            "node": "7e68f9cb-0a0d-4215-8083-3b9ef92cd237",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fa3228ee-62d8-4c02-9dca-8a1ebc6afc74": {
      "main": [
        [
          {
            "node": "7e68f9cb-0a0d-4215-8083-3b9ef92cd237",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c39ba907-7388-4152-965a-e28e626bc9b2": {
      "ai_memory": [
        [
          {
            "node": "63889cad-1283-4dbf-ba16-2b6cf575f24a",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "147a709a-4b46-4835-82cf-7d6b633acd4c": {
      "ai_memory": [
        [
          {
            "node": "c35d1b95-68c8-4237-932d-4744f620760d",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "c769a76a-fb26-46a1-a00d-825b689d5f7a": {
      "main": [
        [
          {
            "node": "7e68f9cb-0a0d-4215-8083-3b9ef92cd237",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "590d8667-69eb-4db2-b5be-714c602b319a": {
      "main": [
        [
          {
            "node": "7e68f9cb-0a0d-4215-8083-3b9ef92cd237",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c85f270d-3224-4e60-9acf-91f173dfe377": {
      "ai_memory": [
        [
          {
            "node": "020d2201-9590-400d-b496-48c65801271c",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "5916c4f1-4369-4d66-8553-2fff006b7e69": {
      "ai_memory": [
        [
          {
            "node": "363a3fc3-112f-40df-891e-0a5aa3669245",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "3ef73405-89de-4bed-9673-90e2c1f2e74b": {
      "main": [
        [
          {
            "node": "0785714f-c45c-4eda-9937-c97e44c9a449",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4d6147d1-7a3d-42ab-b23f-cdafe8ea30b0": {
      "main": [
        [
          {
            "node": "16fa1531-9fb9-4b12-961c-be12e20b2134",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "63889cad-1283-4dbf-ba16-2b6cf575f24a": {
      "main": [
        [
          {
            "node": "7f7df364-4829-4e29-be3d-d13a63f65b8f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c35d1b95-68c8-4237-932d-4744f620760d": {
      "main": [
        [
          {
            "node": "fa3228ee-62d8-4c02-9dca-8a1ebc6afc74",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "020d2201-9590-400d-b496-48c65801271c": {
      "main": [
        [
          {
            "node": "c769a76a-fb26-46a1-a00d-825b689d5f7a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "363a3fc3-112f-40df-891e-0a5aa3669245": {
      "main": [
        [
          {
            "node": "590d8667-69eb-4db2-b5be-714c602b319a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Avancé - Blocs de construction, Intelligence Artificielle

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Avancé
Nombre de nœuds40
Catégorie2
Types de nœuds12
Description de la difficulté

Adapté aux utilisateurs avancés, avec des workflows complexes contenant 16+ nœuds

Auteur

software dev | business automation specialist

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34