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:
wizardchen
2026-05-12 19:36:28 +08:00
committed by lyingbug
parent 86b05d923e
commit 3f9b09e306
9 changed files with 49 additions and 1 deletions
@@ -1064,6 +1064,17 @@
</div>
</div>
</div>
<!-- 数据分析阶段开关(quick-answer 模式下,针对 CSV/Excel 文件触发额外 SQL 生成) -->
<div v-if="!isAgentMode && hasKnowledgeBase" class="setting-row">
<div class="setting-info">
<label>{{ $t('agentEditor.dataAnalysis.enableLabel') }}</label>
<p class="desc">{{ $t('agentEditor.dataAnalysis.enableDesc') }}</p>
</div>
<div class="setting-control">
<t-switch v-model="formData.config.data_analysis_enabled" />
</div>
</div>
</div>
</div>
@@ -1850,6 +1861,8 @@ const defaultFormData = {
image_storage_provider: '',
// 文件类型限制
supported_file_types: [] as string[],
// 数据分析阶段开关(默认关闭,避免在普通问答上多一次 LLM 调用生成 SQL)
data_analysis_enabled: false,
// FAQ 策略设置
faq_priority_enabled: true, // 是否启用 FAQ 优先策略
faq_direct_answer_threshold: 0.9, // FAQ 直接回答阈值(相似度高于此值直接使用 FAQ 答案)