feat(knowledge): enhance FAQ entry filtering and tagging
- Updated the listFAQEntries function to support multiple tag IDs for filtering. - Modified the frontend components to accommodate the new tag_ids parameter. - Enhanced the KbTagManageDrawer and FAQEntryManager components to reflect changes in tag handling. - Improved API documentation to clarify the new tag filtering capabilities. This commit enhances the flexibility of FAQ entry retrieval, allowing users to filter by multiple tags for more precise results.
This commit is contained in:
@@ -158,7 +158,7 @@ func (r *chunkRepository) ListPagedChunksByKnowledgeID(
|
||||
knowledgeID string,
|
||||
page *types.Pagination,
|
||||
chunkType []types.ChunkType,
|
||||
tagID string,
|
||||
tagIDs []string,
|
||||
keyword string,
|
||||
searchField string,
|
||||
sortOrder string,
|
||||
@@ -171,8 +171,8 @@ func (r *chunkRepository) ListPagedChunksByKnowledgeID(
|
||||
baseFilter := func(db *gorm.DB) *gorm.DB {
|
||||
db = db.Where("tenant_id = ? AND knowledge_id = ? AND chunk_type IN (?) AND status in (?)",
|
||||
tenantID, knowledgeID, chunkType, []int{int(types.ChunkStatusIndexed), int(types.ChunkStatusDefault)})
|
||||
if tagID != "" {
|
||||
db = db.Where("tag_id = ?", tagID)
|
||||
if len(tagIDs) > 0 {
|
||||
db = db.Where("tag_id IN ?", tagIDs)
|
||||
}
|
||||
if keyword != "" {
|
||||
like := "%" + keyword + "%"
|
||||
|
||||
@@ -726,7 +726,7 @@ func (s *agentService) getKnowledgeBaseInfos(ctx context.Context, kbIDs []string
|
||||
pageResult, err := s.knowledgeService.ListFAQEntries(ctx, kbID, &types.Pagination{
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
}, 0, "", "", "")
|
||||
}, nil, 0, "", "", "")
|
||||
if err == nil && pageResult != nil {
|
||||
docCount = int(pageResult.Total)
|
||||
if entries, ok := pageResult.Data.([]*types.FAQEntry); ok {
|
||||
|
||||
@@ -168,7 +168,7 @@ func (s *chunkService) ListPagedChunksByKnowledgeID(ctx context.Context,
|
||||
knowledgeID,
|
||||
page,
|
||||
chunkType,
|
||||
"",
|
||||
nil,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
|
||||
@@ -317,7 +317,7 @@ func (s *knowledgeService) CloneChunk(ctx context.Context, src, dst *types.Knowl
|
||||
PageSize: chunkPageSize,
|
||||
},
|
||||
chunkType,
|
||||
"",
|
||||
nil,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
// ListFAQEntries lists FAQ entries under a FAQ knowledge base.
|
||||
func (s *knowledgeService) ListFAQEntries(ctx context.Context,
|
||||
kbID string, page *types.Pagination, tagSeqID int64, keyword string, searchField string, sortOrder string,
|
||||
kbID string, page *types.Pagination, tagUUIDs []string, legacyTagSeqID int64, keyword string, searchField string, sortOrder string,
|
||||
) (*types.PageResult, error) {
|
||||
if page == nil {
|
||||
page = &types.Pagination{}
|
||||
@@ -68,19 +68,17 @@ func (s *knowledgeService) ListFAQEntries(ctx context.Context,
|
||||
return types.NewPageResult(0, page, []*types.FAQEntry{}), nil
|
||||
}
|
||||
|
||||
// Convert tagSeqID to tagID (UUID)
|
||||
var tagID string
|
||||
if tagSeqID > 0 {
|
||||
tag, err := s.tagRepo.GetBySeqID(ctx, effectiveTenantID, tagSeqID)
|
||||
if len(tagUUIDs) == 0 && legacyTagSeqID > 0 {
|
||||
tag, err := s.tagRepo.GetBySeqID(ctx, effectiveTenantID, legacyTagSeqID)
|
||||
if err != nil {
|
||||
return nil, werrors.NewNotFoundError("标签不存在")
|
||||
}
|
||||
tagID = tag.ID
|
||||
tagUUIDs = []string{tag.ID}
|
||||
}
|
||||
|
||||
chunkType := []types.ChunkType{types.ChunkTypeFAQ}
|
||||
chunks, total, err := s.chunkRepo.ListPagedChunksByKnowledgeID(
|
||||
ctx, effectiveTenantID, faqKnowledge.ID, page, chunkType, tagID, keyword, searchField, sortOrder, types.KnowledgeTypeFAQ,
|
||||
ctx, effectiveTenantID, faqKnowledge.ID, page, chunkType, tagUUIDs, keyword, searchField, sortOrder, types.KnowledgeTypeFAQ,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user