feat: 知识库设置页面增加 retrieval_model 检索配置功能

1. 召回测试页面增加 Score 阈值参数配置
2. 知识库设置页面新增检索模型配置:
   - 检索方式 (向量/全文/混合/关键字检索)
   - Reranking 模型 (默认开启,不可关闭)
   - Top K 返回数量
   - Score 阈值 (默认开启,可调节数值)
3. 修复 Dify API 字段名问题 (retrieval_model_dict)
4. 优化数据加载流程,使用详情接口获取完整配置

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-05 22:07:16 +08:00
parent 5f9ce2fe9f
commit d53742948d
9 changed files with 477 additions and 65 deletions
@@ -1,5 +1,5 @@
import { SearchOutlined, FileSearchOutlined } from '@ant-design/icons';
import { Button, Tag, Input, Slider, Spin, Select, Flex } from 'antd';
import { Button, Tag, Input, Slider, Spin, Select, Flex, Switch, InputNumber, Tooltip } from 'antd';
import type { RetrieveRecord } from '~/api/dify-dataset/type';
import { useRetrieveTest } from '~/hooks/dify-dataset-manager/retrieve-test';
import type { RetrieveTestProps } from '~/types/dify-dataset-manager/retrieve-test';
@@ -97,6 +97,10 @@ export default function RetrieveTest({ datasetId }: RetrieveTestProps) {
setSearchMethod,
topK,
setTopK,
scoreThresholdEnabled,
setScoreThresholdEnabled,
scoreThreshold,
setScoreThreshold,
handleRetrieve,
} = useRetrieveTest(datasetId);
@@ -229,6 +233,46 @@ export default function RetrieveTest({ datasetId }: RetrieveTestProps) {
{topK}
</span>
</Flex>
{/* Score 阈值设置 */}
<Flex align="center" gap={12}>
<Tooltip title="开启后,只返回相似度分数高于阈值的结果">
<span style={{
fontSize: 13,
color: colors.textSecondary,
whiteSpace: 'nowrap',
cursor: 'help',
}}>
Score :
</span>
</Tooltip>
<Switch
size="small"
checked={scoreThresholdEnabled}
onChange={setScoreThresholdEnabled}
/>
{scoreThresholdEnabled && (
<>
<Slider
value={scoreThreshold}
onChange={setScoreThreshold}
min={0}
max={1}
step={0.01}
style={{ flex: 1 }}
/>
<InputNumber
value={scoreThreshold}
onChange={(value) => setScoreThreshold(value ?? 0.5)}
min={0}
max={1}
step={0.01}
size="small"
style={{ width: 70 }}
/>
</>
)}
</Flex>
</Flex>
</Flex>