fix(agent): relax rerank model requirement for custom agents

Previously the custom agent editor hid the rerank model field when no
RAG-type knowledge base existed in the configured scope, but the
not-ready check and runtime hard-failed whenever knowledge_search was
in allowed_tools. Users with wiki-only or empty scopes saw "Rerank
Model required" warnings they could not resolve, and "All knowledge
bases" agents broke later if a RAG-type KB was added.

- Backend: when knowledge_search is enabled, fall back to the tenant
  default rerank model (ConversationConfig.RerankModelID) before
  erroring out, matching the built-in agent behaviour.
- Editor: always show the rerank field once a KB scope is selected;
  only mark it required (red *) when the scope contains a RAG KB, with
  a hint explaining the tenant-default fallback.
- Editor: only render rerank top_k / threshold sliders when a rerank
  model is actually selected.
- Input field: drop the eager "missing rerank" not-ready reason; the
  backend is now the single source of truth for rerank availability.
- i18n: add agent.editor.rerankModelOptionalHint across all locales.
This commit is contained in:
wizardchen
2026-05-12 16:41:36 +08:00
committed by lyingbug
parent 4ed7b90eac
commit 5949be739f
7 changed files with 43 additions and 18 deletions
+21 -8
View File
@@ -988,11 +988,20 @@
</div>
</div>
<!-- ReRank 模型(当配置了知识库时显示) -->
<div v-if="needsRerankModel" class="setting-row">
<!-- ReRank 模型(关联知识库时常驻显示,仅在作用域内存在 RAG 类型 KB 时必填) -->
<div v-if="hasKnowledgeBase" class="setting-row">
<div class="setting-info">
<label>{{ $t('agent.editor.rerankModel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('agent.editor.rerankModelDesc') }}</p>
<label>
{{ $t('agent.editor.rerankModel') }}
<span v-if="needsRerankModel" class="required">*</span>
</label>
<p class="desc">
{{ $t('agent.editor.rerankModelDesc') }}
<template v-if="!needsRerankModel">
<br />
<span class="hint">{{ $t('agent.editor.rerankModelOptionalHint') }}</span>
</template>
</p>
</div>
<div class="setting-control">
<ModelSelector
@@ -1202,8 +1211,8 @@
</div>
</div>
<!-- 重排TopK -->
<div class="setting-row">
<!-- 重排TopK(仅在配置了 Rerank 模型时展示) -->
<div v-if="formData.config.rerank_model_id" class="setting-row">
<div class="setting-info">
<label>{{ $t('agent.editor.rerankTopK') }}</label>
<p class="desc">{{ $t('agentEditor.desc.rerankTopK') }}</p>
@@ -1213,8 +1222,8 @@
</div>
</div>
<!-- 重排阈值 -->
<div class="setting-row">
<!-- 重排阈值(仅在配置了 Rerank 模型时展示) -->
<div v-if="formData.config.rerank_model_id" class="setting-row">
<div class="setting-info">
<label>{{ $t('agent.editor.rerankThreshold') }}</label>
<p class="desc">{{ $t('agentEditor.desc.rerankThreshold') }}</p>
@@ -3826,6 +3835,10 @@ const handleSave = async () => {
color: var(--td-text-color-secondary);
margin: 0;
line-height: 1.5;
.hint {
color: var(--td-warning-color, var(--td-text-color-placeholder));
}
}
}