feat: Refactor knowledge base service and router for improved wiki handling

- Updated the knowledge base service to ensure WikiConfig is created when wiki indexing is enabled, enhancing backward compatibility.
- Removed legacy syncing of WikiConfig.Enabled to IndexingStrategy.WikiEnabled, streamlining the logic for wiki enablement.
- Introduced a custom retry delay function for asynq tasks to handle wiki ingest lock conflicts more effectively, improving task management.
- Cleaned up the container file by removing unnecessary whitespace, contributing to better code readability.
This commit is contained in:
wizardchen
2026-04-22 20:25:08 +08:00
parent b3484592e7
commit da8ba98622
4 changed files with 33 additions and 23 deletions
@@ -297,17 +297,16 @@ func (s *knowledgeBaseService) UpdateKnowledgeBase(ctx context.Context,
if config.WikiConfig != nil {
kb.WikiConfig = config.WikiConfig
}
// Update indexing strategy — syncs to WikiConfig and ExtractConfig for backward compat
// Update indexing strategy — syncs to ExtractConfig for backward compat
if config.IndexingStrategy != nil {
if !config.IndexingStrategy.HasAnyIndexing() {
return nil, errors.New("at least one indexing strategy must be enabled")
}
kb.IndexingStrategy = *config.IndexingStrategy
// Sync WikiEnabled → WikiConfig
if kb.WikiConfig != nil {
kb.WikiConfig.Enabled = config.IndexingStrategy.WikiEnabled
} else if config.IndexingStrategy.WikiEnabled {
kb.WikiConfig = &types.WikiConfig{Enabled: true, AutoIngest: true}
// Ensure WikiConfig exists when wiki indexing is enabled so that
// wiki-specific tunables (synthesis model, granularity, …) have a home.
if kb.WikiConfig == nil && config.IndexingStrategy.WikiEnabled {
kb.WikiConfig = &types.WikiConfig{}
}
// Sync GraphEnabled → ExtractConfig
if kb.ExtractConfig != nil {