feat(agent): support dedicated model for query understanding step

Quick-answer (RAG) agents can now configure a separate chat model for
the query-understanding stage (rewrite + intent classification),
decoupling it from the main conversation model so users can route the
lightweight rewrite call to a cheaper / faster model.

- Add CustomAgentConfig.QueryUnderstandModelID and plumb it through
  PipelineRequest and ChatManage.Clone.
- query_understand plugin prefers QueryUnderstandModelID on the
  text-only path; falls back to ChatModelID if the configured model
  cannot be resolved (with a warn log). Multimodal path is unchanged
  to keep vision-capable model selection intact.
- AgentEditorModal exposes a ModelSelector under the existing Query
  Rewrite block; empty means reuse the main chat model.
- Add i18n strings (queryUnderstandModel / placeholder / desc) for
  zh-CN, en-US, ko-KR, ru-RU.
- Extend Go SDK AgentConfig with the new field.
This commit is contained in:
wizardchen
2026-05-12 20:05:31 +08:00
committed by lyingbug
parent 1f60d19f1b
commit 64b20a2d87
10 changed files with 63 additions and 2 deletions
@@ -497,6 +497,24 @@
</div>
</div>
<!-- 问题理解模型(独立模型,留空则复用主对话模型) -->
<div v-if="formData.config.multi_turn_enabled && !isAgentMode && formData.config.enable_rewrite" class="setting-row">
<div class="setting-info">
<label>{{ $t('agent.editor.queryUnderstandModel') }}</label>
<p class="desc">{{ $t('agentEditor.desc.queryUnderstandModel') }}</p>
</div>
<div class="setting-control">
<ModelSelector
model-type="KnowledgeQA"
:selected-model-id="formData.config.query_understand_model_id"
:all-models="allModels"
@update:selected-model-id="(val: string) => formData.config.query_understand_model_id = val"
@add-model="handleAddModel('llm')"
:placeholder="$t('agent.editor.queryUnderstandModelPlaceholder')"
/>
</div>
</div>
<!-- 改写系统提示词 -->
<div v-if="formData.config.multi_turn_enabled && !isAgentMode && formData.config.enable_rewrite" class="setting-row setting-row-vertical">
<div class="setting-info">
@@ -1883,6 +1901,7 @@ const defaultFormData = {
// 高级设置(普通模式)
enable_query_expansion: true,
enable_rewrite: true,
query_understand_model_id: '',
rewrite_prompt_system: '',
rewrite_prompt_user: '',
fallback_strategy: 'model' as 'fixed' | 'model',