e147209e77
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes: **Backend Changes:** - Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log) - Database schema: wiki_pages table with full migration support - WikiPageService: CRUD operations and page management - WikiPageRepository: GORM-based persistence layer - Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents * Summary page generation using LLM * Entity and concept extraction in a single LLM call * Synthesis opportunity detection * Index page rebuilding * Log page maintenance - Wiki boost feature: Enhance chat retrieval with wiki context - Wiki linting: Maintenance and validation utilities - Agent wiki tools: Enable agents to query and interact with wiki pages - Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks - Language support: Reuse existing middleware language infrastructure for LLM prompts **Frontend Changes:** - Wiki browser UI: View all wiki pages with filtering and search - Wiki API client: Knowledge base wiki management endpoints - Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model) - i18n updates: Support for English, Korean, Russian, and Chinese interfaces **Configuration:** - Container DI: Wire up all wiki services - Router: Register wiki API endpoints - Task handling: Support async wiki ingest tasks **Testing:** - Unit tests for wiki page types - Service layer tests - Endpoint tests for wiki operations - Integration tests with LLM mocking **Documentation:** - Language refactoring analysis and guides - Implementation completion reports - Quick reference guides for developers **Key Features:** ✅ LLM-powered wiki page generation from documents ✅ Multi-language support (9+ languages) ✅ Automatic extraction of entities and concepts ✅ Synthesis opportunity detection ✅ Index and log page maintenance ✅ Progressive wiki building across multiple documents ✅ Agent-based wiki interaction ✅ Chat retrieval enhancement with wiki context ✅ Full frontend UI for wiki browsing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
81 lines
3.7 KiB
Go
81 lines
3.7 KiB
Go
package tools
|
|
|
|
// maxFunctionNameLength is the maximum length for a tool/function name
|
|
// imposed by the OpenAI API.
|
|
const maxFunctionNameLength = 64
|
|
|
|
// Tool names constants
|
|
const (
|
|
ToolThinking = "thinking"
|
|
ToolTodoWrite = "todo_write"
|
|
ToolGrepChunks = "grep_chunks"
|
|
ToolKnowledgeSearch = "knowledge_search"
|
|
ToolListKnowledgeChunks = "list_knowledge_chunks"
|
|
ToolQueryKnowledgeGraph = "query_knowledge_graph"
|
|
ToolGetDocumentInfo = "get_document_info"
|
|
ToolDatabaseQuery = "database_query"
|
|
ToolDataAnalysis = "data_analysis"
|
|
ToolDataSchema = "data_schema"
|
|
ToolWebSearch = "web_search"
|
|
ToolWebFetch = "web_fetch"
|
|
ToolFinalAnswer = "final_answer"
|
|
// Skills-related tools (only available when skills are enabled)
|
|
ToolExecuteSkillScript = "execute_skill_script"
|
|
ToolReadSkill = "read_skill"
|
|
// Wiki-related tools (only available when wiki KBs are in scope)
|
|
ToolWikiReadPage = "wiki_read_page"
|
|
ToolWikiWritePage = "wiki_write_page"
|
|
ToolWikiSearch = "wiki_search"
|
|
ToolWikiReadIndex = "wiki_read_index"
|
|
ToolWikiLint = "wiki_lint"
|
|
)
|
|
|
|
// AvailableTool defines a simple tool metadata used by settings APIs.
|
|
type AvailableTool struct {
|
|
Name string `json:"name"`
|
|
Label string `json:"label"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// AvailableToolDefinitions returns the list of tools exposed to the UI.
|
|
// Keep this in sync with registered tools in this package.
|
|
func AvailableToolDefinitions() []AvailableTool {
|
|
return []AvailableTool{
|
|
{Name: ToolThinking, Label: "思考", Description: "动态和反思性的问题解决思考工具"},
|
|
{Name: ToolTodoWrite, Label: "制定计划", Description: "创建结构化的研究计划"},
|
|
{Name: ToolGrepChunks, Label: "关键词搜索", Description: "快速定位包含特定关键词的文档和分块"},
|
|
{Name: ToolKnowledgeSearch, Label: "语义搜索", Description: "理解问题并查找语义相关内容"},
|
|
{Name: ToolListKnowledgeChunks, Label: "查看文档分块", Description: "获取文档完整分块内容"},
|
|
{Name: ToolQueryKnowledgeGraph, Label: "查询知识图谱", Description: "从知识图谱中查询关系"},
|
|
{Name: ToolGetDocumentInfo, Label: "获取文档信息", Description: "查看文档元数据"},
|
|
{Name: ToolDatabaseQuery, Label: "查询数据库", Description: "查询数据库中的信息"},
|
|
{Name: ToolDataAnalysis, Label: "数据分析", Description: "理解数据文件并进行数据分析"},
|
|
{Name: ToolDataSchema, Label: "查看数据元信息", Description: "获取表格文件的元信息"},
|
|
{Name: ToolReadSkill, Label: "读取技能", Description: "按需读取技能内容以学习专业能力"},
|
|
{Name: ToolExecuteSkillScript, Label: "执行技能脚本", Description: "在沙箱环境中执行技能脚本"},
|
|
{Name: ToolFinalAnswer, Label: "提交最终回答", Description: "提交最终回答给用户"},
|
|
{Name: ToolWikiReadPage, Label: "读取Wiki页面", Description: "读取指定的Wiki页面内容"},
|
|
{Name: ToolWikiWritePage, Label: "写入Wiki页面", Description: "创建或更新Wiki页面"},
|
|
{Name: ToolWikiSearch, Label: "搜索Wiki", Description: "在Wiki中搜索页面"},
|
|
{Name: ToolWikiReadIndex, Label: "读取Wiki索引", Description: "读取Wiki索引目录"},
|
|
{Name: ToolWikiLint, Label: "Wiki健康检查", Description: "检查Wiki健康状况"},
|
|
}
|
|
}
|
|
|
|
// DefaultAllowedTools returns the default allowed tools list.
|
|
func DefaultAllowedTools() []string {
|
|
return []string{
|
|
ToolThinking,
|
|
ToolTodoWrite,
|
|
ToolKnowledgeSearch,
|
|
ToolGrepChunks,
|
|
ToolListKnowledgeChunks,
|
|
ToolQueryKnowledgeGraph,
|
|
ToolGetDocumentInfo,
|
|
ToolDatabaseQuery,
|
|
ToolDataAnalysis,
|
|
ToolDataSchema,
|
|
ToolFinalAnswer,
|
|
}
|
|
}
|