fix(search): apply tag filters to knowledge search
This commit is contained in:
@@ -168,11 +168,12 @@ func (c *ChatManage) Clone() *ChatManage {
|
||||
tagIDsCopy := make([]string, len(t.TagIDs))
|
||||
copy(tagIDsCopy, t.TagIDs)
|
||||
searchTargets[i] = &SearchTarget{
|
||||
Type: t.Type,
|
||||
KnowledgeBaseID: t.KnowledgeBaseID,
|
||||
TenantID: t.TenantID,
|
||||
KnowledgeIDs: kidsCopy,
|
||||
TagIDs: tagIDsCopy,
|
||||
Type: t.Type,
|
||||
KnowledgeBaseID: t.KnowledgeBaseID,
|
||||
TenantID: t.TenantID,
|
||||
KnowledgeIDs: kidsCopy,
|
||||
TagIDs: tagIDsCopy,
|
||||
DisableDirectLoad: t.DisableDirectLoad,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,9 @@ type KnowledgeService interface {
|
||||
GetKnowledgeBatch(ctx context.Context, tenantID uint64, ids []string) ([]*types.Knowledge, error)
|
||||
// GetKnowledgeBatchWithSharedAccess retrieves knowledge by IDs including items from shared KBs the user has access to.
|
||||
GetKnowledgeBatchWithSharedAccess(ctx context.Context, tenantID uint64, ids []string) ([]*types.Knowledge, error)
|
||||
// ListKnowledgeIDsByTagIDs returns document knowledge IDs carrying any of
|
||||
// the specified KB-local tags.
|
||||
ListKnowledgeIDsByTagIDs(ctx context.Context, tenantID uint64, kbID string, tagIDs []string) ([]string, error)
|
||||
// ListKnowledgeByKnowledgeBaseID lists all knowledge under a knowledge base.
|
||||
ListKnowledgeByKnowledgeBaseID(ctx context.Context, kbID string) ([]*types.Knowledge, error)
|
||||
// ListPagedKnowledgeByKnowledgeBaseID lists all knowledge under a knowledge base
|
||||
|
||||
@@ -54,7 +54,7 @@ type SessionService interface {
|
||||
// SearchKnowledge performs knowledge-based search, without summarization
|
||||
// knowledgeBaseIDs: list of knowledge base IDs to search (supports multi-KB)
|
||||
// knowledgeIDs: list of specific knowledge (file) IDs to search
|
||||
SearchKnowledge(ctx context.Context, knowledgeBaseIDs []string, knowledgeIDs []string, query string) ([]*types.SearchResult, error)
|
||||
SearchKnowledge(ctx context.Context, knowledgeBaseIDs []string, knowledgeIDs []string, tagScopes []types.TagScope, query string) ([]*types.SearchResult, error)
|
||||
// AgentQA performs agent-based question answering with conversation history and streaming support.
|
||||
AgentQA(ctx context.Context, req *types.QARequest, eventBus *event.EventBus) error
|
||||
}
|
||||
|
||||
@@ -36,6 +36,11 @@ type SearchTarget struct {
|
||||
KnowledgeIDs []string `json:"knowledge_ids,omitempty"`
|
||||
// TagIDs limits retrieval to chunks/documents carrying any of these KB-local tags.
|
||||
TagIDs []string `json:"tag_ids,omitempty"`
|
||||
// DisableDirectLoad forces the target through retrieval even when it is
|
||||
// represented as specific knowledge IDs. Tag-derived document scopes need
|
||||
// this so tag filtering limits the candidate documents without loading every
|
||||
// matching document chunk as context.
|
||||
DisableDirectLoad bool `json:"disable_direct_load,omitempty"`
|
||||
}
|
||||
|
||||
// SearchTargets is a list of search targets, pre-computed at request entry point
|
||||
|
||||
Reference in New Issue
Block a user