refactor: Enhance knowledge base and agent features in documentation
This commit is contained in:
@@ -58,10 +58,15 @@ WeKnora employs a modern modular design to build a complete document understandi
|
||||
|
||||
## 🎯 Key Features
|
||||
|
||||
- **🤖 Agent Mode**: Support for ReACT Agent mode that can use built-in tools to retrieve knowledge bases, MCP tools, and web search tools to access external services, providing comprehensive summary reports through multiple iterations and reflection
|
||||
- **🔍 Precise Understanding**: Structured content extraction from PDFs, Word documents, images and more into unified semantic views
|
||||
- **🧠 Intelligent Reasoning**: Leverages LLMs to understand document context and user intent for accurate Q&A and multi-turn conversations
|
||||
- **📚 Multi-Type Knowledge Bases**: Support for FAQ and document knowledge base types, with folder import, URL import, tag management, and online entry capabilities
|
||||
- **🔧 Flexible Extension**: All components from parsing and embedding to retrieval and generation are decoupled for easy customization
|
||||
- **⚡ Efficient Retrieval**: Hybrid retrieval strategies combining keywords, vectors, and knowledge graphs
|
||||
- **⚡ Efficient Retrieval**: Hybrid retrieval strategies combining keywords, vectors, and knowledge graphs, with cross-knowledge base retrieval support
|
||||
- **🌐 Web Search**: Support for extensible web search engines with built-in DuckDuckGo search engine
|
||||
- **🔌 MCP Tool Integration**: Support for extending Agent capabilities through MCP, with built-in uvx and npx launchers, supporting multiple transport methods
|
||||
- **⚙️ Conversation Strategy**: Support for configuring Agent models, normal mode models, retrieval thresholds, and Prompts, with precise control over multi-turn conversation behavior
|
||||
- **🎯 User-Friendly**: Intuitive web interface and standardized APIs for zero technical barriers
|
||||
- **🔒 Secure & Controlled**: Support for local deployment and private cloud, ensuring complete data sovereignty
|
||||
|
||||
@@ -79,15 +84,22 @@ WeKnora employs a modern modular design to build a complete document understandi
|
||||
|
||||
| Module | Support | Description |
|
||||
|---------|---------|------|
|
||||
| Agent Mode | ✅ ReACT Agent Mode | Support for using built-in tools to retrieve knowledge bases, MCP tools, and web search, with cross-knowledge base retrieval and multiple iterations |
|
||||
| Knowledge Base Types | ✅ FAQ / Document | Support for creating FAQ and document knowledge base types, with folder import, URL import, tag management, and online entry |
|
||||
| Document Formats | ✅ PDF / Word / Txt / Markdown / Images (with OCR / Caption) | Support for structured and unstructured documents with text extraction from images |
|
||||
| Model Management | ✅ Centralized configuration, built-in model sharing | Centralized model configuration with model selection in knowledge base settings, support for multi-tenant shared built-in models |
|
||||
| Embedding Models | ✅ Local models, BGE / GTE APIs, etc. | Customizable embedding models, compatible with local deployment and cloud vector generation APIs |
|
||||
| Vector DB Integration | ✅ PostgreSQL (pgvector), Elasticsearch | Support for mainstream vector index backends, flexible switching for different retrieval scenarios |
|
||||
| Retrieval Strategies | ✅ BM25 / Dense Retrieval / GraphRAG | Support for sparse/dense recall and knowledge graph-enhanced retrieval with customizable retrieve-rerank-generate pipelines |
|
||||
| LLM Integration | ✅ Support for Qwen, DeepSeek, etc., with thinking/non-thinking mode switching | Compatible with local models (e.g., via Ollama) or external API services with flexible inference configuration |
|
||||
| Conversation Strategy | ✅ Agent models, normal mode models, retrieval thresholds, Prompt configuration | Support for configuring Agent models, normal mode models, retrieval thresholds, online Prompt configuration, precise control over multi-turn conversation behavior |
|
||||
| Web Search | ✅ Extensible search engines, DuckDuckGo | Support for extensible web search engines with built-in DuckDuckGo search engine |
|
||||
| MCP Tools | ✅ uvx, npx launchers, Stdio/HTTP Streamable/SSE | Support for extending Agent capabilities through MCP, with built-in uvx and npx launchers, supporting three transport methods |
|
||||
| QA Capabilities | ✅ Context-aware, multi-turn dialogue, prompt templates | Support for complex semantic modeling, instruction control and chain-of-thought Q&A with configurable prompts and context windows |
|
||||
| E2E Testing | ✅ Retrieval+generation process visualization and metric evaluation | End-to-end testing tools for evaluating recall hit rates, answer coverage, BLEU/ROUGE and other metrics |
|
||||
| Deployment Modes | ✅ Support for local deployment / Docker images | Meets private, offline deployment and flexible operation requirements |
|
||||
| User Interfaces | ✅ Web UI + RESTful API | Interactive interface and standard API endpoints, suitable for both developers and business users |
|
||||
| Deployment Modes | ✅ Support for local deployment / Docker images | Meets private, offline deployment and flexible operation requirements, with fast development mode support |
|
||||
| User Interfaces | ✅ Web UI + RESTful API | Interactive interface and standard API endpoints, with Agent mode/normal mode switching and tool call process display |
|
||||
| Task Management | ✅ MQ async tasks, automatic database migration | MQ-based async task state maintenance, support for automatic database schema and data migration during version upgrades |
|
||||
|
||||
## 🚀 Getting Started
|
||||
|
||||
@@ -272,7 +284,11 @@ On your first visit, you will be automatically redirected to the registration/lo
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
**Knowledge Base Management:** Support for dragging and dropping various documents, automatically identifying document structures and extracting core knowledge to establish indexes. The system clearly displays processing progress and document status, achieving efficient knowledge base management.
|
||||
**Knowledge Base Management:** Support for creating FAQ and document knowledge base types, with multiple import methods including drag-and-drop, folder import, and URL import. Automatically identifies document structures and extracts core knowledge to establish indexes. Supports tag management and online entry. The system clearly displays processing progress and document status, achieving efficient knowledge base management.
|
||||
|
||||
**Agent Mode:** Support for ReACT Agent mode that can use built-in tools to retrieve knowledge bases, call user-configured MCP tools and web search tools to access external services, providing comprehensive summary reports through multiple iterations and reflection. Supports cross-knowledge base retrieval, allowing selection of multiple knowledge bases for simultaneous retrieval.
|
||||
|
||||
**Conversation Strategy:** Support for configuring Agent models, normal mode models, retrieval thresholds, and online Prompt configuration, with precise control over multi-turn conversation behavior and retrieval execution methods. The conversation input box supports Agent mode/normal mode switching, enabling/disabling web search, and selecting conversation models.
|
||||
|
||||
### Document Knowledge Graph
|
||||
|
||||
|
||||
+20
-4
@@ -58,10 +58,15 @@ WeKnora 采用现代化模块化设计,构建了一条完整的文档理解与
|
||||
|
||||
## 🎯 核心特性
|
||||
|
||||
- **🤖 Agent模式**:支持ReACT Agent模式,可调用内置工具检索知识库、MCP工具和网络搜索,通过多次迭代和反思给出全面总结报告
|
||||
- **🔍 精准理解**:支持 PDF、Word、图片等文档的结构化内容提取,统一构建语义视图
|
||||
- **🧠 智能推理**:借助大语言模型理解文档上下文与用户意图,支持精准问答与多轮对话
|
||||
- **📚 多类型知识库**:支持FAQ和文档两种类型知识库,支持文件夹导入、URL导入、标签管理和在线录入
|
||||
- **🔧 灵活扩展**:从解析、嵌入、召回到生成全流程解耦,便于灵活集成与定制扩展
|
||||
- **⚡ 高效检索**:混合多种检索策略:关键词、向量、知识图谱
|
||||
- **⚡ 高效检索**:混合多种检索策略:关键词、向量、知识图谱,支持跨知识库检索
|
||||
- **🌐 网络搜索**:支持可扩展的网络搜索引擎,内置DuckDuckGo搜索引擎
|
||||
- **🔌 MCP工具集成**:支持通过MCP扩展Agent能力,内置uvx、npx启动工具,支持多种传输方式
|
||||
- **⚙️ 对话策略**:支持配置Agent模型、普通模式模型、检索阈值和Prompt,精确控制多轮对话行为
|
||||
- **🎯 简单易用**:直观的Web界面与标准API,零技术门槛快速上手
|
||||
- **🔒 安全可控**:支持本地化与私有云部署,数据完全自主可控
|
||||
|
||||
@@ -79,15 +84,22 @@ WeKnora 采用现代化模块化设计,构建了一条完整的文档理解与
|
||||
|
||||
| 功能模块 | 支持情况 | 说明 |
|
||||
|---------|---------|------|
|
||||
| Agent模式 | ✅ ReACT Agent模式 | 支持使用内置工具检索知识库、MCP工具和网络搜索,跨知识库检索,多次迭代和反思 |
|
||||
| 知识库类型 | ✅ FAQ / 文档 | 支持创建FAQ和文档两种类型知识库,支持文件夹导入、URL导入、标签管理和在线录入 |
|
||||
| 文档格式支持 | ✅ PDF / Word / Txt / Markdown / 图片(含 OCR / Caption) | 支持多种结构化与非结构化文档内容解析,支持图文混排与图像文字提取 |
|
||||
| 模型管理 | ✅ 集中配置、内置模型共享 | 模型集中配置,知识库设置页增加模型选择,支持多租户共享内置模型 |
|
||||
| 嵌入模型支持 | ✅ 本地模型、BGE / GTE API 等 | 支持自定义 embedding 模型,兼容本地部署与云端向量生成接口 |
|
||||
| 向量数据库接入 | ✅ PostgreSQL(pgvector)、Elasticsearch | 支持主流向量索引后端,可灵活切换与扩展,适配不同检索场景 |
|
||||
| 检索机制 | ✅ BM25 / Dense Retrieve / GraphRAG | 支持稠密/稀疏召回、知识图谱增强检索等多种策略,可自由组合召回-重排-生成流程 |
|
||||
| 大模型集成 | ✅ 支持 Qwen、DeepSeek 等,思考/非思考模式切换 | 可接入本地大模型(如 Ollama 启动)或调用外部 API 服务,支持推理模式灵活配置 |
|
||||
| 对话策略 | ✅ Agent模型、普通模式模型、检索阈值、Prompt配置 | 支持配置Agent模型、普通模式所需的模型、检索阈值,在线配置Prompt,精确控制多轮对话行为 |
|
||||
| 网络搜索 | ✅ 可扩展搜索引擎、DuckDuckGo | 支持可扩展的网络搜索引擎,内置DuckDuckGo搜索引擎 |
|
||||
| MCP工具 | ✅ uvx、npx启动工具,Stdio/HTTP Streamable/SSE | 支持通过MCP扩展Agent能力,内置uvx、npx两种MCP启动工具,支持三种传输方式 |
|
||||
| 问答能力 | ✅ 上下文感知、多轮对话、提示词模板 | 支持复杂语义建模、指令控制与链式问答,可配置提示词与上下文窗口 |
|
||||
| 端到端测试支持 | ✅ 检索+生成过程可视化与指标评估 | 提供一体化链路测试工具,支持评估召回命中率、回答覆盖度、BLEU / ROUGE 等主流指标 |
|
||||
| 部署模式 | ✅ 支持本地部署 / Docker 镜像 | 满足私有化、离线部署与灵活运维的需求 |
|
||||
| 用户界面 | ✅ Web UI + RESTful API | 提供交互式界面与标准 API 接口,适配开发者与业务用户使用习惯 |
|
||||
| 部署模式 | ✅ 支持本地部署 / Docker 镜像 | 满足私有化、离线部署与灵活运维的需求,支持快速开发模式 |
|
||||
| 用户界面 | ✅ Web UI + RESTful API | 提供交互式界面与标准 API 接口,支持Agent模式/普通模式切换,展示工具调用过程 |
|
||||
| 任务管理 | ✅ MQ异步任务、数据库自动迁移 | 引入MQ对异步任务进行状态维护,支持版本升级时的数据库表结构和数据自动迁移 |
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
@@ -274,7 +286,11 @@ http://localhost
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
**知识库管理:** 支持拖拽上传各类文档,自动识别文档结构并提取核心知识,建立索引。系统清晰展示处理进度和文档状态,实现高效的知识库管理。
|
||||
**知识库管理:** 支持创建FAQ和文档两种类型知识库,支持拖拽上传、文件夹导入、URL导入等多种方式,自动识别文档结构并提取核心知识,建立索引。支持标签管理和在线录入,系统清晰展示处理进度和文档状态,实现高效的知识库管理。
|
||||
|
||||
**Agent模式:** 支持开启ReACT Agent模式,可使用内置工具检索知识库,调用用户配置的MCP工具和网络搜索工具访问外部服务,通过多次迭代和反思,最终给出全面的总结报告。支持跨知识库检索,可以选择多个知识库同时检索。
|
||||
|
||||
**对话策略:** 支持配置Agent模型、普通模式所需的模型、检索阈值,支持在线配置Prompt,精确控制多轮对话行为和检索召回执行方式。对话输入框支持Agent模式/普通模式切换,支持开启和关闭网络搜索,支持选择对话模型。
|
||||
|
||||
### 文档知识图谱
|
||||
|
||||
|
||||
@@ -621,11 +621,7 @@ func (s *knowledgeService) createKnowledgeFromPassageInternal(ctx context.Contex
|
||||
|
||||
// GetKnowledgeByID retrieves a knowledge entry by its ID
|
||||
func (s *knowledgeService) GetKnowledgeByID(ctx context.Context, id string) (*types.Knowledge, error) {
|
||||
logger.Info(ctx, "Start getting knowledge by ID")
|
||||
logger.Infof(ctx, "Knowledge ID: %s", id)
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
logger.Infof(ctx, "Tenant ID: %d", tenantID)
|
||||
|
||||
knowledge, err := s.repo.GetKnowledgeByID(ctx, tenantID, id)
|
||||
if err != nil {
|
||||
@@ -2914,7 +2910,7 @@ func (s *knowledgeService) SearchFAQEntries(ctx context.Context,
|
||||
|
||||
// Prepare search parameters
|
||||
searchParams := types.SearchParams{
|
||||
QueryText: req.QueryText,
|
||||
QueryText: secutils.SanitizeForLog(req.QueryText),
|
||||
VectorThreshold: req.VectorThreshold,
|
||||
MatchCount: req.MatchCount,
|
||||
DisableKeywordsMatch: true,
|
||||
|
||||
@@ -101,6 +101,7 @@ func (h *AuthHandler) Login(c *gin.Context) {
|
||||
c.Error(appErr)
|
||||
return
|
||||
}
|
||||
email := secutils.SanitizeForLog(req.Email)
|
||||
|
||||
// Validate required fields
|
||||
if req.Email == "" || req.Password == "" {
|
||||
@@ -128,7 +129,7 @@ func (h *AuthHandler) Login(c *gin.Context) {
|
||||
|
||||
// User is already in the correct format from service
|
||||
|
||||
logger.Infof(ctx, "User logged in successfully: %s", req.Email)
|
||||
logger.Infof(ctx, "User logged in successfully, email: %s", email)
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,10 @@ func (e *EvaluationHandler) Evaluation(c *gin.Context) {
|
||||
)
|
||||
|
||||
task, err := e.evaluationService.Evaluation(ctx,
|
||||
request.DatasetID,
|
||||
request.KnowledgeBaseID,
|
||||
request.ChatModelID,
|
||||
request.RerankModelID,
|
||||
secutils.SanitizeForLog(request.DatasetID),
|
||||
secutils.SanitizeForLog(request.KnowledgeBaseID),
|
||||
secutils.SanitizeForLog(request.ChatModelID),
|
||||
secutils.SanitizeForLog(request.RerankModelID),
|
||||
)
|
||||
if err != nil {
|
||||
logger.ErrorWithFields(ctx, err, nil)
|
||||
|
||||
@@ -444,18 +444,18 @@ func (h *InitializationHandler) InitializeByKB(c *gin.Context) {
|
||||
}{
|
||||
{
|
||||
modelType: types.ModelTypeKnowledgeQA,
|
||||
name: req.LLM.ModelName,
|
||||
name: secutils.SanitizeForLog(req.LLM.ModelName),
|
||||
source: types.ModelSource(req.LLM.Source),
|
||||
description: "LLM Model for Knowledge QA",
|
||||
baseURL: req.LLM.BaseURL,
|
||||
baseURL: secutils.SanitizeForLog(req.LLM.BaseURL),
|
||||
apiKey: req.LLM.APIKey,
|
||||
},
|
||||
{
|
||||
modelType: types.ModelTypeEmbedding,
|
||||
name: req.Embedding.ModelName,
|
||||
name: secutils.SanitizeForLog(req.Embedding.ModelName),
|
||||
source: types.ModelSource(req.Embedding.Source),
|
||||
description: "Embedding Model",
|
||||
baseURL: req.Embedding.BaseURL,
|
||||
baseURL: secutils.SanitizeForLog(req.Embedding.BaseURL),
|
||||
apiKey: req.Embedding.APIKey,
|
||||
dimension: req.Embedding.Dimension,
|
||||
},
|
||||
@@ -474,10 +474,10 @@ func (h *InitializationHandler) InitializeByKB(c *gin.Context) {
|
||||
interfaceType string
|
||||
}{
|
||||
modelType: types.ModelTypeRerank,
|
||||
name: req.Rerank.ModelName,
|
||||
name: secutils.SanitizeForLog(req.Rerank.ModelName),
|
||||
source: types.ModelSourceRemote,
|
||||
description: "Rerank Model",
|
||||
baseURL: req.Rerank.BaseURL,
|
||||
baseURL: secutils.SanitizeForLog(req.Rerank.BaseURL),
|
||||
apiKey: req.Rerank.APIKey,
|
||||
})
|
||||
}
|
||||
@@ -495,10 +495,10 @@ func (h *InitializationHandler) InitializeByKB(c *gin.Context) {
|
||||
interfaceType string
|
||||
}{
|
||||
modelType: types.ModelTypeVLLM,
|
||||
name: req.Multimodal.VLM.ModelName,
|
||||
name: secutils.SanitizeForLog(req.Multimodal.VLM.ModelName),
|
||||
source: types.ModelSourceRemote,
|
||||
description: "VLM Model",
|
||||
baseURL: req.Multimodal.VLM.BaseURL,
|
||||
baseURL: secutils.SanitizeForLog(req.Multimodal.VLM.BaseURL),
|
||||
apiKey: req.Multimodal.VLM.APIKey,
|
||||
interfaceType: req.Multimodal.VLM.InterfaceType,
|
||||
})
|
||||
|
||||
@@ -404,8 +404,6 @@ type GetKnowledgeBatchRequest struct {
|
||||
func (h *KnowledgeHandler) GetKnowledgeBatch(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
|
||||
logger.Info(ctx, "Start batch retrieving knowledge")
|
||||
|
||||
// Get tenant ID from context
|
||||
tenantID, ok := c.Get(types.TenantIDContextKey.String())
|
||||
if !ok {
|
||||
@@ -451,8 +449,6 @@ func (h *KnowledgeHandler) GetKnowledgeBatch(c *gin.Context) {
|
||||
|
||||
func (h *KnowledgeHandler) UpdateKnowledge(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
logger.Info(ctx, "Start Update knowledge")
|
||||
|
||||
// Get knowledge ID from URL path parameter
|
||||
id := secutils.SanitizeForLog(c.Param("id"))
|
||||
if id == "" {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
secutils "github.com/Tencent/WeKnora/internal/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -107,7 +108,7 @@ func (h *KnowledgeBaseHandler) validateAndGetKnowledgeBase(c *gin.Context) (*typ
|
||||
}
|
||||
|
||||
// Get knowledge base ID from URL parameter
|
||||
id := c.Param("id")
|
||||
id := secutils.SanitizeForLog(c.Param("id"))
|
||||
if id == "" {
|
||||
logger.Error(ctx, "Knowledge base ID is empty")
|
||||
return nil, "", errors.NewBadRequestError("Knowledge base ID cannot be empty")
|
||||
|
||||
@@ -67,20 +67,19 @@ func (s *OllamaService) StartService(ctx context.Context) error {
|
||||
// Check if service is available
|
||||
err := s.client.Heartbeat(ctx)
|
||||
if err != nil {
|
||||
logger.GetLogger(ctx).Warnf("Ollama service unavailable: %v", err)
|
||||
logger.GetLogger(ctx).Warnf("ollama service unavailable: %v", err)
|
||||
s.isAvailable = false
|
||||
|
||||
// If configured as optional, don't return an error
|
||||
if s.isOptional {
|
||||
logger.GetLogger(ctx).Info("Ollama service set as optional, will continue running the application")
|
||||
logger.GetLogger(ctx).Info("ollama service set as optional, will continue running the application")
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("Ollama service unavailable: %w", err)
|
||||
return fmt.Errorf("ollama service unavailable: %w", err)
|
||||
}
|
||||
|
||||
s.isAvailable = true
|
||||
logger.GetLogger(ctx).Info("Ollama service ready")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user