diff --git a/web/src/api/knowledgeBase.ts b/web/src/api/knowledgeBase.ts index 52384d06..6816beb9 100644 --- a/web/src/api/knowledgeBase.ts +++ b/web/src/api/knowledgeBase.ts @@ -154,6 +154,19 @@ export const uploadFile = async (data: FormData, options?: UploadFileOptions) => }); return response as UploadFileResponse; }; +// 上传 QA 文件 +export const uploadQaFile = async (data: FormData, options?: UploadFileOptions) => { + const { kb_id, parent_id, onUploadProgress, signal } = options || {}; + const params: Record = {}; + if (kb_id) params.kb_id = kb_id; + if (parent_id) params.parent_id = parent_id; + const response = await request.uploadFile(`/chunks/${kb_id}/import_qa`, data, { + params, + onUploadProgress, + signal, + }); + return response as UploadFileResponse; +}; // 下载文件 export const downloadFile = async (fileId: string, fileName?: string) => { @@ -293,7 +306,10 @@ export const updateDocumentChunk = async (kb_id:string, document_id:string, doc_ const response = await request.put(`${apiPrefix}/chunks/${kb_id}/${document_id}/${doc_id}`, data); return response as any; }; - +export const deleteDocumentChunk = async (kb_id: string, document_id: string, doc_id: string) => { + const response = await request.delete(`${apiPrefix}/chunks/${kb_id}/${document_id}/${doc_id}`); + return response as any; +}; // 文档块儿创建 export const createDocumentChunk = async (kb_id:string, document_id:string, data: any) => { const response = await request.post(`${apiPrefix}/chunks/${kb_id}/${document_id}/chunk`, data); diff --git a/web/src/components/Tag/index.tsx b/web/src/components/Tag/index.tsx index e7307843..3601b984 100644 --- a/web/src/components/Tag/index.tsx +++ b/web/src/components/Tag/index.tsx @@ -24,6 +24,7 @@ export interface TagProps { /** Additional CSS classes */ className?: string; variant?: 'outline' | 'borderless' + onClick?: () => void; } /** Color theme mappings with text, border, and background colors */ @@ -38,9 +39,9 @@ const colors = { } /** Custom tag component with color themes */ -const Tag: FC = ({ color = 'processing', children, className, variant = 'outline' }) => { +const Tag: FC = ({ color = 'processing', children, className, variant = 'outline', onClick }) => { return ( - + {children} ) diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index 3a03fbc6..4b53403e 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -709,6 +709,8 @@ export const en = { localFile: 'Local File', uploadFileTypes: 'Upload PDF, TXT, DOCX, IMAGE, MEDIA and other format files', webLink: 'Web Link', + csvFile: 'Tabular Dataset', + csvUploadFileTypes: 'Upload files in CSV format', webLinkPlaceholder:'Please enter', webLinkDesc: 'Only static links are supported. If the uploaded data shows as empty, the link may not be readable. One per line, with a maximum of {{count}} links at a time', selectorTutorial: 'Selector Usage Tutorial', @@ -1281,13 +1283,13 @@ export const en = { hybrid: 'Hybrid Retrieval', graph: 'Graph Retrieval', - similarity_threshold: 'Semantic similarity threshold', - similarity_threshold_desc: 'Only return results with semantic similarity higher than this threshold', - similarity_threshold_desc1: 'The minimum similarity threshold for semantic retrieval', + vector_similarity_weight: 'Semantic similarity threshold', + vector_similarity_weight_desc: 'Only return results with semantic similarity higher than this threshold', + vector_similarity_weight_desc1: 'The minimum similarity threshold for semantic retrieval', - vector_similarity_weight: 'Vector Similarity Weight', - vector_similarity_weight_desc: 'Only return results with BM25 scores above this threshold', - vector_similarity_weight_desc1: 'The minimum BM25 score threshold for word segmentation retrieval', + similarity_threshold: 'Vector Similarity Weight', + similarity_threshold_desc: 'Only return results with BM25 scores above this threshold', + similarity_threshold_desc1: 'The minimum BM25 score threshold for word segmentation retrieval', description: 'Description', shareVersion: 'Share Version', diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index c7b24eb4..9ec419ca 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -194,6 +194,8 @@ export const zh = { localFile: '本地文件', uploadFileTypes: '上传 PDF、 TXT、 DOCX、 IMAGE、 MEDIA 等格式的文件', webLink: '网页链接', + csvFile: '表格数据集', + csvUploadFileTypes: '上传 CSV 格式的文件', webLinkPlaceholder: '请输入', webLinkDesc: '仅支持静态链接。如果上传的数据显示为空,则该链接可能无法读取。每行一个,一次最多{{count}}个链接', selectorTutorial: '选择器使用教程', @@ -283,6 +285,7 @@ export const zh = { qaExtract: '问答对提取', default: '默认', customize: '自定义', + qaPrompt: 'QA 拆分引导词', defaultSettings: '使用系统默认的参数和规则', customSettings: '自定义设置数据处理规则', fileName: '文件名称', @@ -663,13 +666,13 @@ export const zh = { hybrid: '混合检索', graph: '图谱检索', - similarity_threshold: '语义相似度阈值', - similarity_threshold_desc: '仅返回语义相似度高于此阈值的结果', - similarity_threshold_desc1: '语义检索的最小相似度阈值', + similarity_threshold: '向量相似度权重', + similarity_threshold_desc: '仅返回BM25分数高于此阈值的结果', + similarity_threshold_desc1: '分词检索的最小BM25分数阈值', - vector_similarity_weight: '向量相似度权重', - vector_similarity_weight_desc: '仅返回BM25分数高于此阈值的结果', - vector_similarity_weight_desc1: '分词检索的最小BM25分数阈值', + vector_similarity_weight: '语义相似度阈值', + vector_similarity_weight_desc: '仅返回语义相似度高于此阈值的结果', + vector_similarity_weight_desc1: '语义检索的最小相似度阈值', description: '描述', shareVersion: '分享版本', diff --git a/web/src/views/ApplicationConfig/components/Knowledge/KnowledgeConfigModal.tsx b/web/src/views/ApplicationConfig/components/Knowledge/KnowledgeConfigModal.tsx index d84151aa..052ebf16 100644 --- a/web/src/views/ApplicationConfig/components/Knowledge/KnowledgeConfigModal.tsx +++ b/web/src/views/ApplicationConfig/components/Knowledge/KnowledgeConfigModal.tsx @@ -131,7 +131,7 @@ const KnowledgeConfigModal = forwardRef - + ({ label: t(`application.${key}`), value: key, }))} - // onChange={handleChange} /> {/* Top K */} @@ -128,34 +127,18 @@ const KnowledgeConfigModal = forwardRef form.setFieldValue('top_k', value)} + onChange={(value) => form.setFieldValue('top_k', value)} /> - {/* 语义相似度阈值 similarity_threshold */} + {/* Vector similarity weight */} {values?.retrieve_type === 'semantic' && ( - - - - )} - {/* 分词匹配度阈值 vector_similarity_weight */} - {values?.retrieve_type === 'participle' && ( - )} - {/* 混合检索权重 */} + {/* similarity threshold */} + {values?.retrieve_type === 'participle' && ( + + + + )} + {/* Hybrid retrieval weight */} {values?.retrieve_type === 'hybrid' && ( <> - - { - const kb_config = vo.config || { similarity_threshold: vo.similarity_threshold, retrieve_type: vo.retrieve_type, top_k: vo.top_k, weight: vo.weight } + const kb_config = vo.config || vo return { kb_id: vo.kb_id || vo.id, ...kb_config, } }) }