feat: Add tag management and FAQ management APIs, enhance knowledge base functionality with keyword search and custom file naming support

This commit is contained in:
wizardchen
2025-12-02 20:39:59 +08:00
parent cdf576eb18
commit 845d990a48
29 changed files with 1471 additions and 394 deletions
+1
View File
@@ -25,6 +25,7 @@ type ChunkRepository interface {
page *types.Pagination,
chunkType []types.ChunkType,
tagID string,
keyword string,
) ([]*types.Chunk, int64, error)
ListChunkByParentID(ctx context.Context, tenantID uint64, parentID string) ([]*types.Chunk, error)
// UpdateChunk updates a chunk
+7 -1
View File
@@ -69,7 +69,13 @@ type KnowledgeService interface {
UpdateImageInfo(ctx context.Context, knowledgeID string, chunkID string, imageInfo string) error
// ListFAQEntries lists FAQ entries under a FAQ knowledge base.
// When tagID is non-empty, results are filtered by tag_id on FAQ chunks.
ListFAQEntries(ctx context.Context, kbID string, page *types.Pagination, tagID string) (*types.PageResult, error)
ListFAQEntries(
ctx context.Context,
kbID string,
page *types.Pagination,
tagID string,
keyword string,
) (*types.PageResult, error)
// UpsertFAQEntries imports or appends FAQ entries asynchronously.
// Returns task ID (Knowledge ID) for tracking import progress.
UpsertFAQEntries(ctx context.Context, kbID string, payload *types.FAQBatchUpsertPayload) (string, error)
+8 -2
View File
@@ -9,7 +9,7 @@ import (
// KnowledgeTagService defines operations on knowledge base scoped tags.
type KnowledgeTagService interface {
// ListTags lists all tags under a knowledge base with associated statistics.
ListTags(ctx context.Context, kbID string) ([]*types.KnowledgeTagWithStats, error)
ListTags(ctx context.Context, kbID string, page *types.Pagination, keyword string) (*types.PageResult, error)
// CreateTag creates a new tag under a knowledge base.
CreateTag(ctx context.Context, kbID string, name string, color string, sortOrder int) (*types.KnowledgeTag, error)
// UpdateTag updates tag basic information.
@@ -23,7 +23,13 @@ type KnowledgeTagRepository interface {
Create(ctx context.Context, tag *types.KnowledgeTag) error
Update(ctx context.Context, tag *types.KnowledgeTag) error
GetByID(ctx context.Context, tenantID uint64, id string) (*types.KnowledgeTag, error)
ListByKB(ctx context.Context, tenantID uint64, kbID string) ([]*types.KnowledgeTag, error)
ListByKB(
ctx context.Context,
tenantID uint64,
kbID string,
page *types.Pagination,
keyword string,
) ([]*types.KnowledgeTag, int64, error)
Delete(ctx context.Context, tenantID uint64, id string) error
// CountReferences returns number of knowledges and chunks that reference the tag.
CountReferences(