Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(retrieval): skip KB retrieval for summarize intent
AstonKrss0d39af1214ff
diff --git a/internal/types/chat_manage.go b/internal/types/chat_manage.goindex 474040981..4f827a11d 100644--- a/internal/types/chat_manage.go+++ b/internal/types/chat_manage.go@@ -109,7 +109,7 @@ const (// which also considers the WebSearchEnabled flag.func (i QueryIntent) NeedsKBRetrieval() bool {switch i {- case IntentKBSearch, IntentClarification, IntentSummarize, "":+ case IntentKBSearch, IntentClarification, "":return truedefault:return falsediff --git a/internal/types/chat_manage_test.go b/internal/types/chat_manage_test.gonew file mode 100644index 000000000..e75d4ad29--- /dev/null+++ b/internal/types/chat_manage_test.go@@ -0,0 +1,56 @@+package types++import "testing"++func TestQueryIntentNeedsKBRetrieval(t *testing.T) {+ tests := []struct {+ name string+ intent QueryIntent+ want bool+ }{+ {name: "knowledge base search", intent: IntentKBSearch, want: true},+ {name: "clarification", intent: IntentClarification, want: true},+ {name: "summarize", intent: IntentSummarize, want: false},+ {name: "web search is handled by ChatManage", intent: IntentWebSearch, want: false},+ {name: "greeting", intent: IntentGreeting, want: false},+ {name: "chitchat", intent: IntentChitchat, want: false},+ {name: "image only", intent: IntentImageOnly, want: false},+ {name: "document only", intent: IntentDocOnly, want: false},+ {name: "empty intent defaults to retrieval", intent: "", want: true},+ {name: "unknown intent", intent: QueryIntent("unknown"), want: false},+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ if got := tt.intent.NeedsKBRetrieval(); got != tt.want {+ t.Errorf("NeedsKBRetrieval() = %t, want %t", got, tt.want)+ }+ })+ }+}++func TestChatManageNeedsRetrieval(t *testing.T) {+ tests := []struct {+ name string+ intent QueryIntent+ webSearchEnabled bool+ want bool+ }{+ {name: "knowledge base search", intent: IntentKBSearch, want: true},+ {name: "summarize", intent: IntentSummarize, want: false},+ {name: "web search enabled", intent: IntentWebSearch, webSearchEnabled: true, want: true},+ {name: "web search disabled", intent: IntentWebSearch, webSearchEnabled: false, want: false},+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ chat := &ChatManage{+ PipelineRequest: PipelineRequest{WebSearchEnabled: tt.webSearchEnabled},+ PipelineState: PipelineState{Intent: tt.intent},+ }+ if got := chat.NeedsRetrieval(); got != tt.want {+ t.Errorf("NeedsRetrieval() = %t, want %t", got, tt.want)+ }+ })+ }+}