feat: Implement wiki_config updates in knowledge base management
Added functionality to enable updates for the `wiki_config` field in the `KnowledgeBaseConfig` struct. This includes: 1. **Type Definition Update**: Added `WikiConfig` field to `KnowledgeBaseConfig` to allow JSON unmarshaling during update requests. 2. **Service Layer Enhancement**: Updated the `UpdateKnowledgeBase` method to persist changes to `wiki_config` when provided in the request. 3. **Frontend TypeScript Adjustments**: Enhanced type definitions in the frontend to support `wiki_config`, improving IDE autocomplete and type checking. This fix addresses the critical issue where `wiki_config` was not being updated due to its absence in the `KnowledgeBaseConfig` struct, ensuring proper handling of wiki configurations during knowledge base updates.
This commit is contained in:
@@ -138,11 +138,17 @@ func (r *wikiPageRepository) ListByType(ctx context.Context, kbID string, pageTy
|
||||
return pages, nil
|
||||
}
|
||||
|
||||
// ListBySourceRef retrieves all wiki pages that reference a given source knowledge ID
|
||||
// ListBySourceRef retrieves all wiki pages that reference a given source knowledge ID.
|
||||
// Handles both old format ("knowledgeID") and new format ("knowledgeID|title") in source_refs JSON array.
|
||||
func (r *wikiPageRepository) ListBySourceRef(ctx context.Context, kbID string, sourceKnowledgeID string) ([]*types.WikiPage, error) {
|
||||
var pages []*types.WikiPage
|
||||
// Match either exact "knowledgeID" or "knowledgeID|..." prefix in the JSON array
|
||||
if err := r.db.WithContext(ctx).
|
||||
Where("knowledge_base_id = ? AND source_refs @> ?", kbID, fmt.Sprintf(`["%s"]`, sourceKnowledgeID)).
|
||||
Where("knowledge_base_id = ? AND (source_refs @> ? OR source_refs::text LIKE ?)",
|
||||
kbID,
|
||||
fmt.Sprintf(`["%s"]`, sourceKnowledgeID),
|
||||
fmt.Sprintf(`%%"%s|%%`, sourceKnowledgeID),
|
||||
).
|
||||
Find(&pages).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user