fix(pipeline): make data-analysis stage opt-in per agent (#1244)
The legacy in-pipeline DuckDB SQL data-analysis stage used to run on every quick-answer RAG request whose retrieved chunks included a CSV/Excel file, adding one extra LLM round-trip (~3s) to generate a SQL query that most plain Q&A users never wanted. There was no way to disable it. Introduce a per-agent DataAnalysisEnabled flag (default off), wire it through PipelineRequest, and gate the DATA_ANALYSIS stage on it. Surface the toggle in the agent editor for quick-answer agents with at least one knowledge base attached. Refs: https://github.com/Tencent/WeKnora/issues/1244
This commit is contained in:
@@ -179,7 +179,7 @@ func (s *sessionService) KnowledgeQA(
|
||||
AddIf(req.WebSearchEnabled, types.WEB_FETCH).
|
||||
Add(types.CHUNK_MERGE).
|
||||
Add(types.FILTER_TOP_K).
|
||||
Add(types.DATA_ANALYSIS).
|
||||
AddIf(chatManage.DataAnalysisEnabled, types.DATA_ANALYSIS).
|
||||
Add(types.INTO_CHAT_MESSAGE).
|
||||
Add(types.CHAT_COMPLETION_STREAM).
|
||||
Build()
|
||||
|
||||
@@ -199,6 +199,12 @@ func (s *sessionService) applyAgentOverridesToChatManage(
|
||||
logger.Infof(ctx, "FAQ priority enabled: threshold=%.2f, boost=%.2f",
|
||||
cm.FAQDirectAnswerThreshold, cm.FAQScoreBoost)
|
||||
}
|
||||
|
||||
// Data-analysis pipeline stage (opt-in, default off).
|
||||
cm.DataAnalysisEnabled = customAgent.Config.DataAnalysisEnabled
|
||||
if cm.DataAnalysisEnabled {
|
||||
logger.Infof(ctx, "Data analysis pipeline stage enabled by custom agent")
|
||||
}
|
||||
}
|
||||
|
||||
// restrictMentionsToAgentScope filters user-provided @mention targets (KB IDs
|
||||
|
||||
@@ -42,6 +42,11 @@ type PipelineRequest struct {
|
||||
FAQDirectAnswerThreshold float64 `json:"-"`
|
||||
FAQScoreBoost float64 `json:"-"`
|
||||
|
||||
// DataAnalysisEnabled controls whether the in-pipeline DuckDB SQL
|
||||
// data-analysis stage runs. Off by default to avoid an extra LLM call on
|
||||
// every RAG request that happens to retrieve CSV/Excel chunks.
|
||||
DataAnalysisEnabled bool `json:"-"`
|
||||
|
||||
// Image / multimodal support
|
||||
Images []string `json:"-"`
|
||||
VLMModelID string `json:"-"`
|
||||
@@ -199,6 +204,7 @@ func (c *ChatManage) Clone() *ChatManage {
|
||||
FAQPriorityEnabled: c.FAQPriorityEnabled,
|
||||
FAQDirectAnswerThreshold: c.FAQDirectAnswerThreshold,
|
||||
FAQScoreBoost: c.FAQScoreBoost,
|
||||
DataAnalysisEnabled: c.DataAnalysisEnabled,
|
||||
Images: append([]string(nil), c.Images...),
|
||||
VLMModelID: c.VLMModelID,
|
||||
ChatModelSupportsVision: c.ChatModelSupportsVision,
|
||||
|
||||
@@ -168,6 +168,13 @@ type CustomAgentConfig struct {
|
||||
// When set, only files with matching extensions can be used with this agent
|
||||
SupportedFileTypes []string `yaml:"supported_file_types" json:"supported_file_types"`
|
||||
|
||||
// ===== Data Analysis Settings =====
|
||||
// Whether to run the legacy in-pipeline DuckDB SQL data-analysis stage when
|
||||
// the retrieved chunks include CSV/Excel files. This issues an extra LLM
|
||||
// call to generate a SQL query and is disabled by default because most
|
||||
// quick-answer / RAG-style agents do not want the added latency.
|
||||
DataAnalysisEnabled bool `yaml:"data_analysis_enabled" json:"data_analysis_enabled"`
|
||||
|
||||
// ===== FAQ Strategy Settings =====
|
||||
// Whether FAQ priority strategy is enabled (FAQ answers prioritized over document chunks)
|
||||
FAQPriorityEnabled bool `yaml:"faq_priority_enabled" json:"faq_priority_enabled"`
|
||||
|
||||
Reference in New Issue
Block a user