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
feat(search): add RRF controls in a tabbed settings popover (#4300)
lyingbuga77d83fe0ee4
diff --git a/docs/assets/search-settings-rrf.png b/docs/assets/search-settings-rrf.pngnew file mode 100644index 000000000..ac525b76aBinary files /dev/null and b/docs/assets/search-settings-rrf.png differdiff --git a/frontend/src/api/retrieval.ts b/frontend/src/api/retrieval.tsindex 24598d11c..740599f9f 100644--- a/frontend/src/api/retrieval.ts+++ b/frontend/src/api/retrieval.ts@@ -9,6 +9,9 @@ export interface RetrievalConfig {rerank_top_k: numberrerank_threshold: numberrerank_model_id: string+ rrf_k?: number+ rrf_vector_weight?: number+ rrf_keyword_weight?: number}// Get tenant retrieval config via KV APIdiff --git a/frontend/src/components/GlobalCommandPalette.vue b/frontend/src/components/GlobalCommandPalette.vueindex e3b166084..891c402ba 100644--- a/frontend/src/components/GlobalCommandPalette.vue+++ b/frontend/src/components/GlobalCommandPalette.vue@@ -1,6 +1,6 @@<template><t-dialog v-model:visible="dialogVisible" :footer="false" :header="false" :close-btn="false" width="640px" top="10vh"- destroy-on-close class="cmdk-dialog" @close="handleClose" @opened="onDialogOpened">+ :close-on-esc="!settingsVisible" destroy-on-close class="cmdk-dialog" @close="handleClose" @opened="onDialogOpened"><div class="cmdk" @keydown="onKeyDown"><!-- Input row --><div class="cmdk__input-row">@@ -19,11 +19,24 @@<span v-if="loading" class="cmdk__input-spinner"><t-loading size="small" /></span>- <t-tooltip :content="t('commandPalette.retrieval')" placement="bottom">- <button type="button" class="cmdk__icon-btn" :class="{ active: drawerVisible }" @click="drawerVisible = true">+ <t-popup v-model:visible="settingsVisible" trigger="click" placement="bottom-right"+ overlay-class-name="cmdk-settings-popup" :overlay-inner-style="{ padding: '0' }" :z-index="3100">+ <button type="button" class="cmdk__icon-btn" :class="{ active: settingsVisible }"+ :title="t('commandPalette.retrieval')" :aria-label="t('retrievalSettings.title')"+ aria-haspopup="dialog" :aria-expanded="settingsVisible"><t-icon name="setting" size="16px" /></button>- </t-tooltip>+ <template #content>+ <div class="cmdk-settings-popover" role="dialog" :aria-label="t('retrievalSettings.title')"+ @keydown.stop @keydown.esc.prevent="settingsVisible = false">+ <button type="button" class="cmdk__icon-btn cmdk-settings-popover__close"+ :aria-label="t('commandPalette.hotkey.esc')" @click="settingsVisible = false">+ <t-icon name="close" size="16px" />+ </button>+ <RetrievalSettings />+ </div>+ </template>+ </t-popup><button type="button" class="cmdk__icon-btn" :aria-label="t('commandPalette.hotkey.esc')" @click="handleClose"><t-icon name="close" size="16px" /></button>@@ -130,7 +143,7 @@<template #icon><t-icon name="chat" size="14px" /></template>{{ t('commandPalette.empty.askAi') }}</t-button>- <t-button variant="outline" size="small" @click="drawerVisible = true">+ <t-button variant="outline" size="small" @click="settingsVisible = true"><template #icon><t-icon name="setting" size="14px" /></template>{{ t('commandPalette.empty.adjustRetrieval') }}</t-button>@@ -150,11 +163,6 @@</div></div>- <!-- Retrieval settings drawer (layered on top of the palette) -->- <t-drawer v-model:visible="drawerVisible" :header="t('retrievalSettings.title')" size="420px" :footer="false"- :close-on-overlay-click="true" class="cmdk-retrieval-drawer">- <RetrievalSettings />- </t-drawer></t-dialog></template>@@ -205,7 +213,7 @@ const {agentsEnabled: () => deploymentCapabilities.isSupported('agents'),})-const drawerVisible = ref(false)+const settingsVisible = ref(false)const inputRef = ref<HTMLInputElement | null>(null)const scrollRef = ref<HTMLElement | null>(null)@@ -499,6 +507,11 @@ const shortcutFor = (flatIndex: number): number | undefined => {}const onKeyDown = (e: KeyboardEvent) => {+ if (settingsVisible.value && e.key === 'Escape') {+ e.preventDefault()+ settingsVisible.value = false+ return+ }if (e.key === 'ArrowDown') {e.preventDefault()moveSelection(1)@@ -542,7 +555,7 @@ const onInputKeyDown = (e: KeyboardEvent) => {}const handleClose = () => {- drawerVisible.value = false+ settingsVisible.value = falsecommandPaletteStore.closePalette()}@@ -599,7 +612,7 @@ watch(open, (val) => {} else {clearResults()query.value = ''- drawerVisible.value = false+ settingsVisible.value = falseactiveKbScope.value = null}})@@ -860,9 +873,24 @@ onUnmounted(() => {}}-.cmdk-retrieval-drawer {- .section-header {- font-weight: 600;- }+.cmdk-settings-popover {+ position: relative;+ width: min(420px, calc(100vw - 32px));+ max-height: min(680px, calc(100dvh - 140px));+ overflow-y: auto;+ overscroll-behavior: contain;+ box-sizing: border-box;+ padding: 12px 14px 14px;+ &__close { position: absolute; top: 12px; right: 12px; }+}+</style>++<style lang="less">+.cmdk-settings-popup .t-popup__content {+ border-radius: var(--app-radius-xl);+ background: var(--td-bg-color-container);+ border: 0.5px solid var(--td-component-stroke);+ box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.03), 0 2px 4px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.1);+ overflow: hidden;}</style>diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex e70ee24be..e283b0e00 100755--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -2563,6 +2563,15 @@ export default {}},retrievalSettings: {+ recallTab: 'Recall',+ rerankTab: 'Reranking',+ rrfTitle: 'Result fusion (RRF)',+ rrfKLabel: 'RRF smoothing constant (K)',+ rrfKDescription: 'Larger values reduce the advantage of top-ranked results. Default: 60; 0 uses the default.',+ rrfVectorWeightLabel: 'RRF vector weight',+ rrfVectorWeightDescription: 'Controls the contribution of vector search to merged results. Default: 0.7; 0 uses the default. Weights do not need to sum to 1.',+ rrfKeywordWeightLabel: 'RRF keyword weight',+ rrfKeywordWeightDescription: 'Controls the contribution of keyword search to merged results. Default: 0.3; 0 uses the default. Weights do not need to sum to 1.',title: 'Search Settings',description: 'Configure global retrieval parameters for knowledge search and message search',embeddingTopKLabel: 'Vector Search Top K',diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.tsindex 9d6a2a340..91128ef43 100644--- a/frontend/src/i18n/locales/ja-JP.ts+++ b/frontend/src/i18n/locales/ja-JP.ts@@ -2563,6 +2563,15 @@ export default {}},retrievalSettings: {+ recallTab: '検索候補',+ rerankTab: '再ランキング',+ rrfTitle: '結果の統合(RRF)',+ rrfKLabel: 'RRF 平滑化定数 (K)',+ rrfKDescription: '値が大きいほど上位の検索結果の優位性が小さくなります。既定値は 60。0 は既定値を使用します。',+ rrfVectorWeightLabel: 'RRF ベクトル重み',+ rrfVectorWeightDescription: '統合結果に対するベクトル検索の影響を調整します。既定値は 0.7。0 は既定値を使用します。重みの合計を 1 にする必要はありません。',+ rrfKeywordWeightLabel: 'RRF キーワード重み',+ rrfKeywordWeightDescription: '統合結果に対するキーワード検索の影響を調整します。既定値は 0.3。0 は既定値を使用します。重みの合計を 1 にする必要はありません。',title: '検索設定',description: 'ナレッジベース検索とメッセージ検索に共通する検索パラメータを設定します',embeddingTopKLabel: 'ベクトル検索のTop K',diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.tsindex abb6ac765..60670f113 100755--- a/frontend/src/i18n/locales/ko-KR.ts+++ b/frontend/src/i18n/locales/ko-KR.ts@@ -5606,6 +5606,15 @@ export default {howToEnable: '지식 그래프를 활성화하는 방법?'},retrievalSettings: {+ recallTab: '검색 후보',+ rerankTab: '재순위 지정',+ rrfTitle: '결과 통합 (RRF)',+ rrfKLabel: 'RRF 평활 상수 (K)',+ rrfKDescription: '값이 클수록 상위 검색 결과의 우위가 줄어듭니다. 기본값은 60이며, 0은 기본값을 사용합니다.',+ rrfVectorWeightLabel: 'RRF 벡터 가중치',+ rrfVectorWeightDescription: '통합 결과에 대한 벡터 검색의 영향을 조정합니다. 기본값은 0.7이며, 0은 기본값을 사용합니다. 가중치의 합이 1일 필요는 없습니다.',+ rrfKeywordWeightLabel: 'RRF 키워드 가중치',+ rrfKeywordWeightDescription: '통합 결과에 대한 키워드 검색의 영향을 조정합니다. 기본값은 0.3이며, 0은 기본값을 사용합니다. 가중치의 합이 1일 필요는 없습니다.',title: '검색 설정',description: '전역 검색 파라미터를 설정합니다. 지식베이스 검색과 메시지 검색이 이 설정을 공유합니다',embeddingTopKLabel: '벡터 검색 Top K',diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.tsindex 591a063ad..c3aa7aeb9 100755--- a/frontend/src/i18n/locales/ru-RU.ts+++ b/frontend/src/i18n/locales/ru-RU.ts@@ -5606,6 +5606,15 @@ export default {howToEnable: 'Как включить граф знаний?'},retrievalSettings: {+ recallTab: 'Отбор',+ rerankTab: 'Переранжирование',+ rrfTitle: 'Объединение результатов (RRF)',+ rrfKLabel: 'Константа сглаживания RRF (K)',+ rrfKDescription: 'Чем больше значение, тем меньше преимущество первых результатов. По умолчанию: 60; 0 использует значение по умолчанию.',+ rrfVectorWeightLabel: 'Вес векторного поиска RRF',+ rrfVectorWeightDescription: 'Влияние векторного поиска на объединённые результаты. По умолчанию: 0.7; 0 использует значение по умолчанию. Сумма весов не обязана равняться 1.',+ rrfKeywordWeightLabel: 'Вес поиска по ключевым словам RRF',+ rrfKeywordWeightDescription: 'Влияние поиска по ключевым словам на объединённые результаты. По умолчанию: 0.3; 0 использует значение по умолчанию. Сумма весов не обязана равняться 1.',title: 'Настройки поиска',description: 'Настройте глобальные параметры поиска, общие для поиска по знаниям и сообщениям',embeddingTopKLabel: 'Векторный поиск Top K',diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex 79e7bbe76..38c5d3005 100755--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -5608,6 +5608,15 @@ export default {howToEnable: '如何启用知识图谱?'},retrievalSettings: {+ recallTab: '召回',+ rerankTab: '重排序',+ rrfTitle: '结果融合(RRF)',+ rrfKLabel: 'RRF 平滑常数 (K)',+ rrfKDescription: '值越大,排名靠前结果的优势越小。默认 60;设为 0 使用默认值。',+ rrfVectorWeightLabel: 'RRF 向量权重',+ rrfVectorWeightDescription: '控制向量检索对融合结果的影响。默认 0.7;设为 0 使用默认值。两项权重之和无需等于 1。',+ rrfKeywordWeightLabel: 'RRF 关键词权重',+ rrfKeywordWeightDescription: '控制关键词检索对融合结果的影响。默认 0.3;设为 0 使用默认值。两项权重之和无需等于 1。',title: '搜索设置',description: '配置知识库搜索和消息搜索的全局检索参数',embeddingTopKLabel: '向量检索数量 (Top K)',diff --git a/frontend/src/i18n/locales/zh-TW.ts b/frontend/src/i18n/locales/zh-TW.tsindex ca069c27c..c61831d69 100644--- a/frontend/src/i18n/locales/zh-TW.ts+++ b/frontend/src/i18n/locales/zh-TW.ts@@ -5608,6 +5608,15 @@ export default {howToEnable: '如何啟用知識圖譜?'},retrievalSettings: {+ recallTab: '召回',+ rerankTab: '重排序',+ rrfTitle: '結果融合(RRF)',+ rrfKLabel: 'RRF 平滑常數 (K)',+ rrfKDescription: '值越大,排名靠前結果的優勢越小。預設 60;設為 0 使用預設值。',+ rrfVectorWeightLabel: 'RRF 向量權重',+ rrfVectorWeightDescription: '控制向量檢索對融合結果的影響。預設 0.7;設為 0 使用預設值。兩項權重之和無需等於 1。',+ rrfKeywordWeightLabel: 'RRF 關鍵詞權重',+ rrfKeywordWeightDescription: '控制關鍵詞檢索對融合結果的影響。預設 0.3;設為 0 使用預設值。兩項權重之和無需等於 1。',title: '搜尋設定',description: '設定知識庫搜尋和訊息搜尋的全局檢索參數',embeddingTopKLabel: '向量檢索數量 (Top K)',diff --git a/frontend/src/views/settings/RetrievalSettings.test.ts b/frontend/src/views/settings/RetrievalSettings.test.tsnew file mode 100644index 000000000..11c484742--- /dev/null+++ b/frontend/src/views/settings/RetrievalSettings.test.ts@@ -0,0 +1,136 @@+import assert from 'node:assert/strict'+import { readFileSync } from 'node:fs'+import { test } from 'node:test'+import { runInNewContext } from 'node:vm'+import { compileScript, parse } from '@vue/compiler-sfc'+import ts from 'typescript'+import * as vue from 'vue'++const source = readFileSync(new URL('./RetrievalSettings.vue', import.meta.url), 'utf8')+const { descriptor } = parse(source)+const script = compileScript(descriptor, { id: 'retrieval-settings-test' }).content+const compiled = ts.transpileModule(script, {+ compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },+}).outputText++const baseConfig = {+ embedding_top_k: 50,+ vector_threshold: 0.15,+ keyword_threshold: 0.3,+ rerank_top_k: 10,+ rerank_threshold: 0.2,+ rerank_model_id: 'existing-model',+}++type RrfField = 'rrf_k' | 'rrf_vector_weight' | 'rrf_keyword_weight'+type SettingsState = {+ localConfig: Record<string, unknown>+ handleParamChange: () => void+ handleRrfChange: (field: RrfField, value: number | string) => void+}++async function editConfig(+ config: Record<string, unknown>,+ edit: (state: SettingsState) => void,+ canEdit = true,+) {+ let mounted: (() => Promise<void>) | undefined+ const timers = new Map<number, () => void>()+ let timerID = 0+ const setTimeout = (callback: () => void) => {+ timers.set(++timerID, callback)+ return timerID+ }+ const clearTimeout = (id: number) => timers.delete(id)+ const writes: Record<string, unknown>[] = []+ const mocks: Record<string, unknown> = {+ vue: { ...vue, onMounted: (callback: () => Promise<void>) => { mounted = callback } },+ 'tdesign-vue-next': { MessagePlugin: { success() {}, error() {} } },+ 'vue-i18n': { useI18n: () => ({ t: (key: string) => key }) },+ '@/components/ModelSelector.vue': {},+ '@/stores/auth': { useAuthStore: () => ({ hasRole: () => canEdit }) },+ '@/api/retrieval': {+ getTenantRetrievalConfig: async () => ({ data: config }),+ updateTenantRetrievalConfig: async (body: Record<string, unknown>) => {+ // Exercise the JSON serialization used for the PUT request.+ writes.push(JSON.parse(JSON.stringify(body)))+ return { data: body }+ },+ },+ }+ const sandbox = {+ exports: {} as { default: { setup: (props: object, ctx: object) => SettingsState } },+ require: (name: string) => {+ assert.ok(name in mocks, `Unexpected component import: ${name}`)+ return mocks[name]+ },+ console, setTimeout, clearTimeout, window: { setTimeout, clearTimeout },+ }+ runInNewContext(compiled, sandbox)+ const state = sandbox.exports.default.setup({}, { expose() {} })+ assert.ok(mounted)+ await mounted()+ assert.equal(writes.length, 0, 'loading the config must not save it')+ for (const [id, callback] of timers) {+ timers.delete(id)+ callback()+ }+ edit(state)+ for (const [id, callback] of timers) {+ timers.delete(id)+ callback()+ }+ await Promise.resolve()+ return writes+}++for (const [name, rrf] of [+ ['custom RRF parameters', { rrf_k: 90, rrf_vector_weight: 0.2, rrf_keyword_weight: 0.8 }],+ ['omitted RRF parameters', {}],+ ['explicit zero RRF parameters', { rrf_k: 0, rrf_vector_weight: 0, rrf_keyword_weight: 0 }],+] as const) {+ test(`editing Top K preserves ${name} in the serialized PUT body`, async () => {+ const config = { ...baseConfig, ...rrf }+ const writes = await editConfig(config, state => {+ state.localConfig.embedding_top_k = 25+ state.handleParamChange()+ })+ assert.equal(writes.length, 1)+ assert.deepEqual(writes[0], { ...config, embedding_top_k: 25 })+ })+}++for (const [field, value] of [+ ['rrf_k', 90],+ ['rrf_vector_weight', 1.25],+ ['rrf_keyword_weight', 0.45],+] as const) {+ test(`editing ${field} saves the new value and preserves the other settings`, async () => {+ const config = { ...baseConfig, rrf_k: 75, rrf_vector_weight: 0.85, rrf_keyword_weight: 0.15 }+ const writes = await editConfig(config, state => state.handleRrfChange(field, value))+ assert.deepEqual(writes, [{ ...config, [field]: value }])+ })+}++test('RRF edits coalesce into one save and zero selects the server default', async () => {+ const writes = await editConfig(baseConfig, state => {+ state.handleRrfChange('rrf_k', 80)+ state.handleRrfChange('rrf_k', 0)+ state.handleRrfChange('rrf_vector_weight', 0)+ state.handleRrfChange('rrf_keyword_weight', 0)+ })+ assert.deepEqual(writes, [{ ...baseConfig, rrf_k: 0, rrf_vector_weight: 0, rrf_keyword_weight: 0 }])+})++test('cleared, invalid and fractional K inputs do not overwrite saved values', async () => {+ const writes = await editConfig({ ...baseConfig, rrf_k: 75, rrf_vector_weight: 0.8 }, state => {+ for (const value of ['', -1, NaN, Infinity]) state.handleRrfChange('rrf_vector_weight', value)+ state.handleRrfChange('rrf_k', 1.5)+ })+ assert.deepEqual(writes, [])+})++test('non-admins cannot change RRF configuration', async () => {+ const writes = await editConfig(baseConfig, state => state.handleRrfChange('rrf_k', 90), false)+ assert.deepEqual(writes, [])+})diff --git a/frontend/src/views/settings/RetrievalSettings.vue b/frontend/src/views/settings/RetrievalSettings.vueindex 401d37654..c7de474dd 100644--- a/frontend/src/views/settings/RetrievalSettings.vue+++ b/frontend/src/views/settings/RetrievalSettings.vue@@ -1,115 +1,146 @@<template><div class="retrieval-settings">- <div class="section-header">- <h2>{{ t('retrievalSettings.title') }}</h2>- <p class="section-description">{{ t('retrievalSettings.description') }}</p>+ <h2 class="settings-title">{{ t('retrievalSettings.title') }}</h2>+ <div class="settings-tabs" role="tablist" :aria-label="t('retrievalSettings.title')">+ <button v-for="(tab, index) in tabs" :id="`retrieval-tab-${tab.key}`" :key="tab.key"+ type="button" class="settings-tab" :class="{ 'is-active': activeTab === tab.key }"+ role="tab" :aria-selected="activeTab === tab.key" :aria-controls="`retrieval-panel-${tab.key}`"+ :tabindex="activeTab === tab.key ? 0 : -1" @click="activeTab = tab.key"+ @keydown.right.prevent="moveTab(index, 1, $event)" @keydown.left.prevent="moveTab(index, -1, $event)">+ {{ tab.label }}+ </button></div>-- <div class="settings-group">- <!-- Rerank Model -->- <div class="setting-item">- <div class="setting-label">- <span>{{ t('retrievalSettings.rerankModelLabel') }} <span class="required-mark">*</span></span>- </div>- <p class="setting-desc">{{ t('retrievalSettings.rerankModelDescription') }}</p>- <p v-if="!localConfig.rerank_model_id" class="setting-desc warning-text">- {{ t('retrievalSettings.rerankModelRequired') }}- </p>- <div class="setting-control-full">- <ModelSelector- model-type="Rerank"- :selected-model-id="localConfig.rerank_model_id"+ <div v-show="activeTab === 'recall'" id="retrieval-panel-recall" role="tabpanel" aria-labelledby="retrieval-tab-recall">+ <div class="settings-group">+ <!-- Embedding Top K -->+ <div class="setting-item">+ <div class="setting-label-row">+ <span>{{ t('retrievalSettings.embeddingTopKLabel') }}</span>+ <span class="value-display">{{ localConfig.embedding_top_k }}</span>+ </div>+ <t-slider+ v-model="localConfig.embedding_top_k"+ :min="1"+ :max="100"+ :step="1":disabled="!canEdit"- @update:selected-model-id="handleModelChange"+ @change="handleParamChange"/></div>- </div>- <!-- Embedding Top K -->- <div class="setting-item">- <div class="setting-label-row">- <span>{{ t('retrievalSettings.embeddingTopKLabel') }}</span>- <span class="value-display">{{ localConfig.embedding_top_k }}</span>+ <!-- Vector Threshold -->+ <div class="setting-item">+ <div class="setting-label-row">+ <span>{{ t('retrievalSettings.vectorThresholdLabel') }}</span>+ <span class="value-display">{{ localConfig.vector_threshold.toFixed(2) }}</span>+ </div>+ <t-slider+ v-model="localConfig.vector_threshold"+ :min="0"+ :max="1"+ :step="0.05"+ :disabled="!canEdit"+ @change="handleParamChange"+ /></div>- <t-slider- v-model="localConfig.embedding_top_k"- :min="1"- :max="100"- :step="1"- :disabled="!canEdit"- @change="handleParamChange"- />- </div>- <!-- Vector Threshold -->- <div class="setting-item">- <div class="setting-label-row">- <span>{{ t('retrievalSettings.vectorThresholdLabel') }}</span>- <span class="value-display">{{ localConfig.vector_threshold.toFixed(2) }}</span>+ <!-- Keyword Threshold -->+ <div class="setting-item">+ <div class="setting-label-row">+ <span>{{ t('retrievalSettings.keywordThresholdLabel') }}</span>+ <span class="value-display">{{ localConfig.keyword_threshold.toFixed(2) }}</span>+ </div>+ <t-slider+ v-model="localConfig.keyword_threshold"+ :min="0"+ :max="1"+ :step="0.05"+ :disabled="!canEdit"+ @change="handleParamChange"+ /></div>- <t-slider- v-model="localConfig.vector_threshold"- :min="0"- :max="1"- :step="0.05"- :disabled="!canEdit"- @change="handleParamChange"- /></div>-- <!-- Keyword Threshold -->- <div class="setting-item">- <div class="setting-label-row">- <span>{{ t('retrievalSettings.keywordThresholdLabel') }}</span>- <span class="value-display">{{ localConfig.keyword_threshold.toFixed(2) }}</span>+ </div>+ <div v-show="activeTab === 'rrf'" id="retrieval-panel-rrf" role="tabpanel" aria-labelledby="retrieval-tab-rrf">+ <div class="settings-group rrf-settings">+ <div v-for="field in rrfFields" :key="field.key" class="rrf-row">+ <div class="rrf-label">+ <label :for="field.key">{{ field.label }}</label>+ <t-tooltip :content="field.description" placement="top" :overlay-style="{ maxWidth: '280px' }">+ <button type="button" class="rrf-help" :aria-label="field.description">+ <t-icon name="help-circle" size="14px" />+ </button>+ </t-tooltip>+ </div>+ <t-input-number+ theme="column"+ :value="localConfig[field.key] ?? field.defaultValue"+ :min="0" :step="field.step" :decimal-places="field.key === 'rrf_k' ? 0 : undefined"+ :disabled="!canEdit" :input-props="{ id: field.key, 'aria-label': field.label }"+ @change="handleRrfChange(field.key, $event)"+ /></div>- <t-slider- v-model="localConfig.keyword_threshold"- :min="0"- :max="1"- :step="0.05"- :disabled="!canEdit"- @change="handleParamChange"- /></div>+ </div>+ <div v-show="activeTab === 'rerank'" id="retrieval-panel-rerank" role="tabpanel" aria-labelledby="retrieval-tab-rerank">+ <div class="settings-group">+ <!-- Rerank Model -->+ <div class="setting-item">+ <div class="setting-label">+ <span>{{ t('retrievalSettings.rerankModelLabel') }} <span class="required-mark">*</span></span>+ </div>+ <p class="setting-desc">{{ t('retrievalSettings.rerankModelDescription') }}</p>+ <p v-if="!localConfig.rerank_model_id" class="setting-desc warning-text">+ {{ t('retrievalSettings.rerankModelRequired') }}+ </p>+ <div class="setting-control-full">+ <ModelSelector+ model-type="Rerank"+ :selected-model-id="localConfig.rerank_model_id"+ :disabled="!canEdit"+ @update:selected-model-id="handleModelChange"+ />+ </div>+ </div>- <!-- Rerank Top K -->- <div class="setting-item">- <div class="setting-label-row">- <span>{{ t('retrievalSettings.rerankTopKLabel') }}</span>- <span class="value-display">{{ localConfig.rerank_top_k }}</span>+ <!-- Rerank Top K -->+ <div class="setting-item">+ <div class="setting-label-row">+ <span>{{ t('retrievalSettings.rerankTopKLabel') }}</span>+ <span class="value-display">{{ localConfig.rerank_top_k }}</span>+ </div>+ <t-slider+ v-model="localConfig.rerank_top_k"+ :min="1"+ :max="100"+ :step="1"+ :disabled="!canEdit"+ @change="handleParamChange"+ /></div>- <t-slider- v-model="localConfig.rerank_top_k"- :min="1"- :max="100"- :step="1"- :disabled="!canEdit"- @change="handleParamChange"- />- </div>- <!-- Rerank Threshold -->- <div class="setting-item">- <div class="setting-label-row">- <span>{{ t('retrievalSettings.rerankThresholdLabel') }}</span>- <span class="value-display">{{ localConfig.rerank_threshold.toFixed(2) }}</span>+ <!-- Rerank Threshold -->+ <div class="setting-item">+ <div class="setting-label-row">+ <span>{{ t('retrievalSettings.rerankThresholdLabel') }}</span>+ <span class="value-display">{{ localConfig.rerank_threshold.toFixed(2) }}</span>+ </div>+ <t-slider+ v-model="localConfig.rerank_threshold"+ :min="-10"+ :max="10"+ :step="0.1"+ :disabled="!canEdit"+ @change="handleParamChange"+ /></div>- <t-slider- v-model="localConfig.rerank_threshold"- :min="-10"- :max="10"- :step="0.1"- :disabled="!canEdit"- @change="handleParamChange"- /></div></div></div></template><script setup lang="ts">-import { reactive, computed, onMounted, nextTick } from 'vue'+import { reactive, computed, onMounted, nextTick, ref } from 'vue'import { MessagePlugin } from 'tdesign-vue-next'import { useI18n } from 'vue-i18n'import ModelSelector from '@/components/ModelSelector.vue'@@ -122,6 +153,18 @@ import { useAuthStore } from '@/stores/auth'const { t } = useI18n()const authStore = useAuthStore()+const activeTab = ref('recall')+const tabs = computed(() => [+ { key: 'recall', label: t('retrievalSettings.recallTab') },+ { key: 'rrf', label: t('retrievalSettings.rrfTitle') },+ { key: 'rerank', label: t('retrievalSettings.rerankTab') },+])+const moveTab = (index: number, direction: number, event: KeyboardEvent) => {+ const next = (index + direction + tabs.value.length) % tabs.value.length+ activeTab.value = tabs.value[next]!.key+ const buttons = (event.currentTarget as HTMLElement).parentElement?.querySelectorAll('button')+ buttons?.[next]?.focus()+}// PUT /tenants/kv/retrieval-config requires Admin+ on the server. Hide the// banner + lock all controls for non-Admins so they can read the// configuration without tripping a 403 mid-edit.@@ -136,6 +179,13 @@ const defaultConfig: RetrievalConfig = {rerank_model_id: '',}+type RrfField = 'rrf_k' | 'rrf_vector_weight' | 'rrf_keyword_weight'+const rrfFields = computed<{ key: RrfField; label: string; description: string; defaultValue: number; step: number }[]>(() => [+ { key: 'rrf_k', label: t('retrievalSettings.rrfKLabel'), description: t('retrievalSettings.rrfKDescription'), defaultValue: 60, step: 1 },+ { key: 'rrf_vector_weight', label: t('retrievalSettings.rrfVectorWeightLabel'), description: t('retrievalSettings.rrfVectorWeightDescription'), defaultValue: 0.7, step: 0.1 },+ { key: 'rrf_keyword_weight', label: t('retrievalSettings.rrfKeywordWeightLabel'), description: t('retrievalSettings.rrfKeywordWeightDescription'), defaultValue: 0.3, step: 0.1 },+])+const localConfig = reactive<RetrievalConfig>({ ...defaultConfig })let initialConfig: RetrievalConfig = { ...defaultConfig }let isInitializing = true@@ -152,6 +202,9 @@ const loadConfig = async () => {rerank_top_k: cfg.rerank_top_k || defaultConfig.rerank_top_k,rerank_threshold: cfg.rerank_threshold ?? defaultConfig.rerank_threshold,rerank_model_id: cfg.rerank_model_id || '',+ rrf_k: cfg.rrf_k,+ rrf_vector_weight: cfg.rrf_vector_weight,+ rrf_keyword_weight: cfg.rrf_keyword_weight,})initialConfig = { ...localConfig }}@@ -193,6 +246,13 @@ const debouncedSave = () => {}const handleParamChange = () => debouncedSave()+const handleRrfChange = (field: RrfField, value: number | string) => {+ // Ignore cleared inputs; zero explicitly selects the server default.+ if (!canEdit.value || typeof value !== 'number' || !Number.isFinite(value) || value < 0) return+ if (field === 'rrf_k' && !Number.isSafeInteger(value)) return+ localConfig[field] = value+ debouncedSave()+}const handleModelChange = (modelId: string) => {localConfig.rerank_model_id = modelIddebouncedSave()@@ -211,14 +271,48 @@ onMounted(async () => {width: 100%;}-.section-header {- .settings-section-header();+.settings-title {+ margin: 0 28px 12px 0;+ font-size: var(--app-text-lg);+ font-weight: 600;+ line-height: 24px;+ color: var(--td-text-color-primary);+}++.settings-tabs {+ display: inline-flex;+ gap: 2px;+ padding: 2px;+ margin-right: 24px;+ border-radius: var(--app-radius-md);+ background: var(--td-bg-color-secondarycontainer);+}+.settings-tab {+ height: 24px;+ padding: 0 10px;+ border: 0;+ border-radius: var(--app-radius-sm);+ background: transparent;+ font: inherit;+ font-size: var(--app-text-sm);+ color: var(--td-text-color-secondary);+ cursor: pointer;+ &:hover { color: var(--td-text-color-primary); }+ &:focus-visible { outline: 2px solid var(--td-brand-color); outline-offset: 2px; }+ &.is-active {+ color: var(--td-text-color-primary);+ font-weight: 500;+ background: var(--td-bg-color-container);+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);+ }}.settings-group {display: flex;flex-direction: column;gap: 0;+ margin-top: 4px;+ :deep(.t-input) { border-radius: var(--app-radius-md); }}.setting-item {@@ -231,7 +325,7 @@ onMounted(async () => {}.setting-label {- font-size: var(--app-text-base);+ font-size: var(--app-text-md);font-weight: 500;color: var(--td-text-color-primary);margin-bottom: 4px;@@ -241,7 +335,7 @@ onMounted(async () => {display: flex;align-items: center;justify-content: space-between;- font-size: var(--app-text-base);+ font-size: var(--app-text-md);font-weight: 500;color: var(--td-text-color-primary);margin-bottom: 10px;@@ -268,8 +362,21 @@ onMounted(async () => {.value-display {font-size: var(--app-text-md);- font-weight: 600;- color: var(--td-brand-color);- font-family: var(--app-font-family-mono);+ font-weight: 500;+ color: var(--td-text-color-primary);+ font-variant-numeric: tabular-nums;+}+.rrf-row {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 12px;+ padding: 16px 0;+ border-bottom: 1px solid var(--td-component-stroke);+ &:last-child { border-bottom: none; }+ :deep(.t-input-number) { width: 112px; flex-shrink: 0; }+ :deep(input) { font-variant-numeric: tabular-nums; }}+.rrf-label { display: flex; align-items: center; gap: 4px; font-size: var(--app-text-md); font-weight: 500; }+.rrf-help { .settings-title-help(); }</style>