Merge branch 'master' into custom_agent

This commit is contained in:
wizardchen
2025-12-24 15:53:04 +08:00
47 changed files with 2574 additions and 2648 deletions
+16
View File
@@ -65,12 +65,27 @@ func (c *ChatManage) Clone() *ChatManage {
knowledgeIDs := make([]string, len(c.KnowledgeIDs))
copy(knowledgeIDs, c.KnowledgeIDs)
// Deep copy search targets slice
searchTargets := make(SearchTargets, len(c.SearchTargets))
for i, t := range c.SearchTargets {
if t != nil {
kidsCopy := make([]string, len(t.KnowledgeIDs))
copy(kidsCopy, t.KnowledgeIDs)
searchTargets[i] = &SearchTarget{
Type: t.Type,
KnowledgeBaseID: t.KnowledgeBaseID,
KnowledgeIDs: kidsCopy,
}
}
}
return &ChatManage{
Query: c.Query,
RewriteQuery: c.RewriteQuery,
SessionID: c.SessionID,
KnowledgeBaseIDs: knowledgeBaseIDs,
KnowledgeIDs: knowledgeIDs,
SearchTargets: searchTargets,
VectorThreshold: c.VectorThreshold,
KeywordThreshold: c.KeywordThreshold,
EmbeddingTopK: c.EmbeddingTopK,
@@ -101,6 +116,7 @@ func (c *ChatManage) Clone() *ChatManage {
RewritePromptUser: c.RewritePromptUser,
EnableRewrite: c.EnableRewrite,
EnableQueryExpansion: c.EnableQueryExpansion,
TenantID: c.TenantID,
}
}
+1
View File
@@ -180,6 +180,7 @@ type FAQEntry struct {
KnowledgeID string `json:"knowledge_id"`
KnowledgeBaseID string `json:"knowledge_base_id"`
TagID string `json:"tag_id"`
TagName string `json:"tag_name"`
IsEnabled bool `json:"is_enabled"`
IsRecommended bool `json:"is_recommended"`
StandardQuestion string `json:"standard_question"`
+4
View File
@@ -18,6 +18,8 @@ type ChunkRepository interface {
ListChunksByKnowledgeID(ctx context.Context, tenantID uint64, knowledgeID string) ([]*types.Chunk, error)
// ListPagedChunksByKnowledgeID lists paged chunks by knowledge id.
// When tagID is non-empty, results are filtered by tag_id.
// sortOrder: "asc" for time ascending (updated_at ASC), default is time descending (updated_at DESC)
// searchField: specifies which field to search in (for FAQ: "standard_question", "similar_questions", "answers", "" for all)
ListPagedChunksByKnowledgeID(
ctx context.Context,
tenantID uint64,
@@ -26,6 +28,8 @@ type ChunkRepository interface {
chunkType []types.ChunkType,
tagID string,
keyword string,
searchField string,
sortOrder string,
) ([]*types.Chunk, int64, error)
ListChunkByParentID(ctx context.Context, tenantID uint64, parentID string) ([]*types.Chunk, error)
// UpdateChunk updates a chunk
+4
View File
@@ -74,12 +74,16 @@ 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.
// searchField: specifies which field to search in ("standard_question", "similar_questions", "answers", "" for all)
// sortOrder: "asc" for time ascending (updated_at ASC), default is time descending (updated_at DESC)
ListFAQEntries(
ctx context.Context,
kbID string,
page *types.Pagination,
tagID string,
keyword string,
searchField string,
sortOrder string,
) (*types.PageResult, error)
// UpsertFAQEntries imports or appends FAQ entries asynchronously.
// Returns task ID (Knowledge ID) for tracking import progress.
+3 -1
View File
@@ -41,7 +41,9 @@ type SessionService interface {
// KnowledgeQAByEvent performs knowledge-based question answering by event
KnowledgeQAByEvent(ctx context.Context, chatManage *types.ChatManage, eventList []types.EventType) error
// SearchKnowledge performs knowledge-based search, without summarization
SearchKnowledge(ctx context.Context, knowledgeBaseID, query string) ([]*types.SearchResult, error)
// 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)
// AgentQA performs agent-based question answering with conversation history and streaming support
// eventBus is optional - if nil, uses service's default EventBus
// customAgent is optional - if provided, uses custom agent configuration instead of tenant defaults
+2
View File
@@ -26,6 +26,8 @@ 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)
// GetByIDs retrieves multiple tags by their IDs in a single query.
GetByIDs(ctx context.Context, tenantID uint64, ids []string) ([]*types.KnowledgeTag, error)
GetByName(ctx context.Context, tenantID uint64, kbID string, name string) (*types.KnowledgeTag, error)
ListByKB(
ctx context.Context,