feat: Implement comprehensive wiki feature for knowledge bases
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>
This commit is contained in:
@@ -64,6 +64,7 @@ type RouterParams struct {
|
||||
IMHandler *handler.IMHandler
|
||||
DataSourceHandler *handler.DataSourceHandler
|
||||
WeKnoraCloudHandler *handler.WeKnoraCloudHandler
|
||||
WikiPageHandler *handler.WikiPageHandler
|
||||
}
|
||||
|
||||
// NewRouter 创建新的路由
|
||||
@@ -148,6 +149,7 @@ func NewRouter(params RouterParams) *gin.Engine {
|
||||
RegisterIMChannelRoutes(v1, params.IMHandler)
|
||||
RegisterDataSourceRoutes(v1, params.DataSourceHandler)
|
||||
RegisterWeKnoraCloudRoutes(v1, params.WeKnoraCloudHandler)
|
||||
RegisterWikiPageRoutes(v1, params.WikiPageHandler)
|
||||
}
|
||||
|
||||
return r
|
||||
@@ -833,3 +835,30 @@ func RegisterWeKnoraCloudRoutes(r *gin.RouterGroup, handler *handler.WeKnoraClou
|
||||
r.POST("/weknoracloud/credentials", handler.SaveCredentials)
|
||||
r.GET("/models/weknoracloud/status", handler.Status)
|
||||
}
|
||||
|
||||
// RegisterWikiPageRoutes registers wiki page related routes
|
||||
func RegisterWikiPageRoutes(r *gin.RouterGroup, wikiHandler *handler.WikiPageHandler) {
|
||||
wiki := r.Group("/knowledgebase/:kb_id/wiki")
|
||||
{
|
||||
// Page CRUD
|
||||
wiki.GET("/pages", wikiHandler.ListPages)
|
||||
wiki.POST("/pages", wikiHandler.CreatePage)
|
||||
wiki.GET("/pages/*slug", wikiHandler.GetPage)
|
||||
wiki.PUT("/pages/*slug", wikiHandler.UpdatePage)
|
||||
wiki.DELETE("/pages/*slug", wikiHandler.DeletePage)
|
||||
|
||||
// Special pages
|
||||
wiki.GET("/index", wikiHandler.GetIndex)
|
||||
wiki.GET("/log", wikiHandler.GetLog)
|
||||
|
||||
// Graph and stats
|
||||
wiki.GET("/graph", wikiHandler.GetGraph)
|
||||
wiki.GET("/stats", wikiHandler.GetStats)
|
||||
|
||||
// Search and maintenance
|
||||
wiki.GET("/search", wikiHandler.SearchPages)
|
||||
wiki.POST("/rebuild-links", wikiHandler.RebuildLinks)
|
||||
wiki.GET("/lint", wikiHandler.Lint)
|
||||
wiki.POST("/auto-fix", wikiHandler.AutoFix)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ type SyncTaskParams struct {
|
||||
DataTableSummary interfaces.TaskHandler `name:"dataTableSummary"`
|
||||
ImageMultimodal interfaces.TaskHandler `name:"imageMultimodal"`
|
||||
KnowledgePostProcess interfaces.TaskHandler `name:"knowledgePostProcess"`
|
||||
WikiIngest interfaces.TaskHandler `name:"wikiIngest"`
|
||||
}
|
||||
|
||||
// RegisterSyncHandlers registers all task handlers on the SyncTaskExecutor.
|
||||
@@ -100,5 +101,6 @@ func RegisterSyncHandlers(params SyncTaskParams) {
|
||||
params.Executor.RegisterHandler(types.TypeImageMultimodal, params.ImageMultimodal.Handle)
|
||||
params.Executor.RegisterHandler(types.TypeKnowledgePostProcess, params.KnowledgePostProcess.Handle)
|
||||
params.Executor.RegisterHandler(types.TypeDataSourceSync, params.DataSourceService.ProcessSync)
|
||||
params.Executor.RegisterHandler(types.TypeWikiIngest, params.WikiIngest.Handle)
|
||||
logger.Infof(context.Background(), "[SyncTask] All task handlers registered (Lite mode, no Redis)")
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ type AsynqTaskParams struct {
|
||||
DataTableSummary interfaces.TaskHandler `name:"dataTableSummary"`
|
||||
ImageMultimodal interfaces.TaskHandler `name:"imageMultimodal"`
|
||||
KnowledgePostProcess interfaces.TaskHandler `name:"knowledgePostProcess"`
|
||||
WikiIngest interfaces.TaskHandler `name:"wikiIngest"`
|
||||
}
|
||||
|
||||
func getAsynqRedisClientOpt() *asynq.RedisClientOpt {
|
||||
@@ -116,6 +117,9 @@ func RunAsynqServer(params AsynqTaskParams) *asynq.ServeMux {
|
||||
// Register data source sync handler
|
||||
mux.HandleFunc(types.TypeDataSourceSync, params.DataSourceService.ProcessSync)
|
||||
|
||||
// Register wiki ingest handler
|
||||
mux.HandleFunc(types.TypeWikiIngest, params.WikiIngest.Handle)
|
||||
|
||||
go func() {
|
||||
// Start the server
|
||||
if err := params.Server.Run(mux); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user