使用Qdrant建立地端版RAG系統,但問答時AI Agent不會讀取Qdrant裡的資料

Describe the problem/error/question

我想使用Qdrant地端版建立了一個RAG問答系統,依著YT上的教學操作(https://www.youtube.com/watch?v=LOWYPjSmFi4&t=26s),設定也改為了對應的內容,但在進行測試的時候AI Agent並不會去讀取Qdrant資料庫裡的資料,而是使用Ollama模型直接回答問題

What is the error message (if any)?

Please share your workflow

  "name": "RAG-對話查詢",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        -80,
        -120
      ],
      "id": "caa3444d-48ab-40a1-9549-9ccb3957588f",
      "name": "When chat message received",
      "webhookId": "4fb35e49-a9ff-4119-a5cd-69764a2aec7a"
    },
    {
      "parameters": {
        "hasOutputParser": true,
        "options": {
          "systemMessage": "You are a helpful assistant. You have access to a vector database that contains knowledge about hospital regulations and relevant application procedures. Always use the vector database to search for relevant information before answering any user questions. If the answer cannot be found in the database, then you may use your general knowledge to respond.\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        180,
        -120
      ],
      "id": "dae4cdaa-a8b7-49ee-aa91-2bbd47f322b3",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "name": "human"
      },
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "typeVersion": 1,
      "position": [
        380,
        60
      ],
      "id": "20c49571-2251-40c5-b9f2-2ebae1faa40a",
      "name": "Answer questions with a vector store"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        260,
        100
      ],
      "id": "9b7a1cf6-fb61-4094-9895-b7d15a8cfe1d",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "model": "mistral:latest",
        "options": {
          "numCtx": 2048
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "typeVersion": 1,
      "position": [
        140,
        100
      ],
      "id": "4915a94c-ac6a-46bd-85e7-955ccdd35329",
      "name": "Ollama Chat Model",
      "credentials": {
        "ollamaApi": {
          "id": "VwD7FXutcZdAatOb",
          "name": "Ollama account"
        }
      }
    },
    {
      "parameters": {
        "qdrantCollection": {
          "__rl": true,
          "value": "cch_test",
          "mode": "list",
          "cachedResultName": "cch_test"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "typeVersion": 1.2,
      "position": [
        260,
        240
      ],
      "id": "18dfcb34-ef95-4be8-9375-a99183bab3ec",
      "name": "Qdrant Vector Store",
      "credentials": {
        "qdrantApi": {
          "id": "tPkHXhlHGp7fBZ7P",
          "name": "QdrantApi account"
        }
      }
    },
    {
      "parameters": {
        "model": "bge-m3:latest"
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOllama",
      "typeVersion": 1,
      "position": [
        340,
        400
      ],
      "id": "fccca68d-faf3-4498-a98b-c5ce84113511",
      "name": "Embeddings Ollama",
      "credentials": {
        "ollamaApi": {
          "id": "VwD7FXutcZdAatOb",
          "name": "Ollama account"
        }
      }
    },
    {
      "parameters": {
        "model": "mistral:latest",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmOllama",
      "typeVersion": 1,
      "position": [
        572,
        300
      ],
      "id": "4fef6cc5-4108-4e98-bffc-eba98b8d21d5",
      "name": "Ollama Model",
      "credentials": {
        "ollamaApi": {
          "id": "VwD7FXutcZdAatOb",
          "name": "Ollama account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer questions with a vector store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Qdrant Vector Store": {
      "ai_vectorStore": [
        []
      ]
    },
    "Embeddings Ollama": {
      "ai_embedding": [
        [
          {
            "node": "Qdrant Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Model": {
      "ai_languageModel": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9186a63d-c21d-441a-b922-7bfb915d183f",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "ff8eb97212e88cf30db364541df465bfbf6607014c9f710f1cd7ab3e573feeda"
  },
  "id": "ofVLC34lsvkqrTwW",
  "tags": []
}
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

根據一般医療機構的規定,連續曠工超過三天的情況下,醫療人員應該提出病假或者事假申請,以確保醫療服務的積極性和品質。但這些規定並非一致,各個國家、城市和醫院可能有不同的政策。

在查詢時,您應該先查詢特定醫療機構的具體政策,以確保您提供正確的信息。

Information on your n8n setup

  • n8n version:1.95.3
  • Database (default: SQLite):Qdrant
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):Docker
  • Operating system:Windows 10 企業版 LTSC

有幾個可能的原因

  1. prompt 的優化
You are a specialized hospital regulation assistant. You MUST follow this process for EVERY user question:

MANDATORY STEPS:
1. ALWAYS use the "human" vector database tool FIRST to search for relevant information
2. NEVER provide answers without checking the vector database first
3. If the vector database contains relevant information, base your answer primarily on that data
4. Only supplement with general knowledge if the database information is incomplete
5. If no relevant information is found in the database, clearly state this before using general knowledge

RESPONSE FORMAT:
- Start by searching the vector database
- Indicate what information was found or not found
- Provide your answer based on the database results
- If using general knowledge, clearly distinguish it from database information

IMPORTANT: You cannot answer any hospital regulation or procedure questions without first consulting the vector database. This is a strict requirement.
  1. Ollama model 的選擇
    看不出來你目前使用的模型
    但通常較小型的模型會有調用 tool 上的困難
    可以嘗試調整看看其他模型,但也要根據你的設備能跑的動的模型為主