import { CheckCircleFilled, QuestionCircleOutlined, SaveOutlined } from '@ant-design/icons'; import { Button, Card, Checkbox, Descriptions, Divider, InputNumber, Select, Slider, Spin, Tag, Tooltip } from 'antd'; import { useDatasetSettings, type SearchMethod } from '~/hooks/dify-dataset-manager/dataset-settings'; import type { DatasetSettingsProps } from '~/types/dify-dataset-manager/dataset-settings'; import { usePermission } from '~/hooks/usePermission'; // 检索方式选项 const SEARCH_METHOD_OPTIONS: { label: string; value: SearchMethod; description: string }[] = [ { label: '向量检索', value: 'semantic_search', description: '基于语义理解的智能检索,适合需要理解上下文的场景' }, { label: '全文检索', value: 'full_text_search', description: '基于关键词匹配的传统检索方式' }, { label: '混合检索', value: 'hybrid_search', description: '结合向量和全文检索,综合效果最佳' }, { label: '关键字检索', value: 'keyword_search', description: '精确关键字匹配' }, ]; /** * 知识库设置组件 * 使用 Descriptions 展示只读的知识库基本信息,提供可编辑的检索设置 * 注:Dify API 不支持修改知识库名称和描述,故这些字段仅作只读展示 */ export default function DatasetSettings({ dataset, onDatasetUpdated, canEditDataset = true, }: DatasetSettingsProps) { const { saving, hasChanges, retrievalSettings, handleSave, handleReset, updateRetrievalSettings, } = useDatasetSettings(dataset, onDatasetUpdated); const { hasPermission } = usePermission(); const canWrite = hasPermission('dify:settings:write') && canEditDataset; // 是否需要显示 Reranking 提示(语义检索和混合检索需要,且强制开启) const showRerankingInfo = retrievalSettings.searchMethod === 'semantic_search' || retrievalSettings.searchMethod === 'hybrid_search'; // 权重设置:由于 Reranking 强制开启,混合检索时由 Reranking 模型决定排序,不需要手动设置权重 // 所以这里始终不显示权重设置 const showWeightsOption = false; if (!dataset) { return (
管理知识库的基本信息和检索配置