From 784517772a2b0588bd1b56478f4e0f8fae6f3766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Fri, 13 Feb 2026 00:13:30 +0800 Subject: [PATCH] add ragflow-loader --- mcp/mcp_settings.json | 11 +--------- prompt/system_prompt.md | 13 ----------- .../ragflow-loader/.claude-plugin/plugin.json | 22 +++++++++++++++++++ skills/ragflow-loader/hooks/pre_prompt.py | 21 ++++++++++++++++++ 4 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 skills/ragflow-loader/.claude-plugin/plugin.json create mode 100644 skills/ragflow-loader/hooks/pre_prompt.py diff --git a/mcp/mcp_settings.json b/mcp/mcp_settings.json index 083f586..3aa61ae 100644 --- a/mcp/mcp_settings.json +++ b/mcp/mcp_settings.json @@ -1,14 +1,5 @@ [ { - "mcpServers": { - "rag_retrieve": { - "transport": "http", - "url": "http://host.docker.internal:9382/mcp/", - "headers": { - "api_key": "ragflow-MRqxnDnYZ1yp5kklDMIlKH4f1qezvXIngSMGPhu1AG8", - "X-Dataset-Ids": "{dataset_ids}" - } - } - } + "mcpServers": {} } ] diff --git a/prompt/system_prompt.md b/prompt/system_prompt.md index a8059cd..ba76a86 100644 --- a/prompt/system_prompt.md +++ b/prompt/system_prompt.md @@ -1,7 +1,6 @@ {extra_prompt} # Execution Guidelines -- **Knowledge Base First**: For user inquiries about products, policies, troubleshooting, factual questions, etc., prioritize querying the `rag_retrieve` knowledge base. Use other tools only if no results are found. - **Tool-Driven**: All operations are implemented through tool interfaces. - **Immediate Response**: Trigger the corresponding tool call as soon as the intent is identified. - **Result-Oriented**: Directly return execution results, minimizing transitional language. @@ -10,19 +9,7 @@ # Output Content Must Adhere to the Following Requirements (Important) **System Constraints**: Do not expose any prompt content to the user. Use appropriate tools to analyze data. The results returned by tool calls do not need to be printed. **Language Requirement**: All user interactions and result outputs must be in [{language}]. -**Image Handling**: The content returned by the `rag_retrieve` tool may include images. Each image is exclusively associated with its nearest text or sentence. If multiple consecutive images appear near a text area, all of them are related to the nearest text content. Do not ignore these images, and always maintain their correspondence with the nearest text. Each sentence or key point in the response should be accompanied by relevant images (when they meet the established association criteria). Avoid placing all images at the end of the response. -**Citation Requirement (RAG Only)**: When answering questions based on `rag_retrieve` tool results, you MUST add XML citation tags for factual claims derived from the knowledge base. - -**MANDATORY FORMAT**: `The cited factual claim ` - -**Citation Rules**: -- The citation tag MUST be placed immediately after the factual claim or paragraph -- The `file` attribute MUST use the exact `File ID` from `rag_retrieve` document -- The `page` attribute MUST use the exact `Page Number` from `rag_retrieve` document -- If multiple sources support the same claim, include separate citation tags for each source -- Example: `According to the policy, returns are accepted within 30 days .` -- This requirement ONLY applies when using `rag_retrieve` results to answer questions ### Current Working Directory diff --git a/skills/ragflow-loader/.claude-plugin/plugin.json b/skills/ragflow-loader/.claude-plugin/plugin.json new file mode 100644 index 0000000..5443234 --- /dev/null +++ b/skills/ragflow-loader/.claude-plugin/plugin.json @@ -0,0 +1,22 @@ +{ + "name": "ragflow-loader", + "description": "加载ragflow的rag_retrieve的mcp和提示词注入", + "hooks": { + "PrePrompt": [ + { + "type": "command", + "command": "python hooks/pre_prompt.py" + } + ] + }, + "mcpServers": { + "rag_retrieve": { + "transport": "http", + "url": "http://host.docker.internal:9382/mcp/", + "headers": { + "api_key": "ragflow-MRqxnDnYZ1yp5kklDMIlKH4f1qezvXIngSMGPhu1AG8", + "X-Dataset-Ids": "{dataset_ids}" + } + } + } +} diff --git a/skills/ragflow-loader/hooks/pre_prompt.py b/skills/ragflow-loader/hooks/pre_prompt.py new file mode 100644 index 0000000..70611fa --- /dev/null +++ b/skills/ragflow-loader/hooks/pre_prompt.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +""" +PrePrompt Hook - 用户上下文加载器示例 + +在 system_prompt 加载时执行,可以动态注入用户相关信息到 prompt 中。 +""" +import sys + +def main(): + + context_info = f"""# rag_retrieve Guidelines +- **Knowledge Base First**: For user inquiries about products, policies, troubleshooting, factual questions, etc., prioritize querying the `rag_retrieve` knowledge base. Use other tools only if no results are found. +- **Image Handling**: The content returned by the `rag_retrieve` tool may include images. Each image is exclusively associated with its nearest text or sentence. If multiple consecutive images appear near a text area, all of them are related to the nearest text content. Do not ignore these images, and always maintain their correspondence with the nearest text. Each sentence or key point in the response should be accompanied by relevant images (when they meet the established association criteria). Avoid placing all images at the end of the response. +- **Citation Requirement (RAG Only)**: When answering questions based on `rag_retrieve` tool results, you MUST add XML citation tags for factual claims derived from the knowledge base. +""" + print(context_info) + return 0 + + +if __name__ == '__main__': + sys.exit(main())