This commit is contained in:
+13
-1
@@ -186,7 +186,7 @@ func (s *Service) Process(ctx context.Context, id int64) error {
|
||||
}
|
||||
run.CategoryBeforeName = categoryName(categories, t.CategoryID)
|
||||
promptCats := shortlistCategories(t, categories, s.cfg.CategoryPromptLimit)
|
||||
hits, err := s.knowledge.Search(ctx, t.Name+"\n"+stripHTML(t.Content), s.cfg.KnowledgeTopK)
|
||||
hits, err := s.knowledge.Search(ctx, t.Name+"\n"+stripHTML(t.Content), s.cfg.KnowledgeTopK, categories)
|
||||
if err != nil {
|
||||
run.Reason = "knowledge_search_failed"
|
||||
finish(err)
|
||||
@@ -196,6 +196,15 @@ func (s *Service) Process(ctx context.Context, id int64) error {
|
||||
run.KnowledgeTopID = hits[0].Doc.ID
|
||||
run.KnowledgeTopTitle = hits[0].Doc.Title
|
||||
run.KnowledgeScore = hits[0].Score
|
||||
run.KnowledgeSemanticScore = hits[0].SemanticScore
|
||||
run.KnowledgeTitleScore = hits[0].TitleScore
|
||||
run.KnowledgeKeywordScore = hits[0].KeywordScore
|
||||
run.KnowledgeCategoryScore = hits[0].CategoryScore
|
||||
run.KnowledgeBestChunk = hits[0].BestChunkExcerpt
|
||||
run.KnowledgeThreshold = s.cfg.KnowledgeMinScore
|
||||
if hits[0].Doc.MinScore > run.KnowledgeThreshold {
|
||||
run.KnowledgeThreshold = hits[0].Doc.MinScore
|
||||
}
|
||||
}
|
||||
contextData := model.ContextSnapshot{}
|
||||
if s.context != nil && s.cfg.ContextEnabled {
|
||||
@@ -238,6 +247,9 @@ func (s *Service) Process(ctx context.Context, id int64) error {
|
||||
run.ReplyDecision = result.ReplyDecision
|
||||
run.ReplyProposed = result.Reply
|
||||
run.KnowledgeID = result.KnowledgeID
|
||||
if result.KnowledgeThreshold > 0 {
|
||||
run.KnowledgeThreshold = result.KnowledgeThreshold
|
||||
}
|
||||
run.PolicyReason = result.CategoryDecision + "; " + result.ReplyDecision
|
||||
if !canReply && result.Reply {
|
||||
run.ReplyProposed = false
|
||||
|
||||
@@ -133,6 +133,7 @@ func (p Policy) Evaluate(t model.Ticket, d model.Decision, categories []model.Ca
|
||||
if hit.Doc.MinScore > threshold {
|
||||
threshold = hit.Doc.MinScore
|
||||
}
|
||||
res.KnowledgeThreshold = threshold
|
||||
if !hit.Doc.AutoReply {
|
||||
res.ReplyDecision = "reply_knowledge_auto_reply_disabled"
|
||||
return res, nil
|
||||
|
||||
Reference in New Issue
Block a user