feat(frontend): 更新三种切分模式与PDF定位
This commit is contained in:
@@ -470,8 +470,8 @@ assert.match(generationControlSource, /modelMeta\(model\)/, '模型下拉缺少
|
||||
assert.match(typesSource, /export interface UnstructuredProcessOptions/, '缺少非结构化处理选项类型')
|
||||
assert.match(
|
||||
typesSource,
|
||||
/export type ChunkMethod = 'structure' \| 'fixed' \| 'custom'/,
|
||||
'非结构化切分方式类型必须只保留 structure、fixed 和 custom',
|
||||
/export type ChunkMethod = 'layout_hybrid' \| 'semantic' \| 'fixed'/,
|
||||
'非结构化切分方式类型必须只保留 layout_hybrid、semantic 和 fixed',
|
||||
)
|
||||
for (const field of [
|
||||
'preprocessOptions',
|
||||
@@ -479,7 +479,7 @@ for (const field of [
|
||||
'chunkSize',
|
||||
'chunkOverlap',
|
||||
'minChunkSize',
|
||||
'customDelimiter',
|
||||
'semanticBreakpointPercentile',
|
||||
'preserveTables',
|
||||
'preserveCodeBlocks',
|
||||
'preserveLists',
|
||||
@@ -528,9 +528,9 @@ assert.match(unstructuredOptionsSource, /function updateDesensitize/, '脱敏开
|
||||
|
||||
assert.ok(unstructuredOptionsSource.includes('切分选项'), '非结构化配置缺少切分选项分类')
|
||||
const expectedChunkMethods = [
|
||||
['structure', '文档结构'],
|
||||
['fixed', '固定 Token'],
|
||||
['custom', '自定义分隔符'],
|
||||
['layout_hybrid', '版面结构混合切分'],
|
||||
['semantic', '语义切分'],
|
||||
['fixed', '固定 Token 切分'],
|
||||
]
|
||||
const chunkMethodsStart = unstructuredOptionsSource.indexOf('const CHUNK_METHODS')
|
||||
const chunkMethodsEnd = unstructuredOptionsSource.indexOf('const UNSTRUCTURED_NUMBER_LIMITS', chunkMethodsStart)
|
||||
@@ -540,10 +540,14 @@ assert.deepEqual(chunkMethodValues, expectedChunkMethods.map(([value]) => value)
|
||||
for (const [value, label] of expectedChunkMethods) {
|
||||
assert.ok(chunkMethodsSource.includes(`value: '${value}', label: '${label}'`), `切分方式缺少选项:${label}`)
|
||||
}
|
||||
for (const removedMethod of ['semantic', 'heading']) {
|
||||
for (const removedMethod of ['structure', 'custom', 'heading']) {
|
||||
assert.ok(!chunkMethodsSource.includes(`value: '${removedMethod}'`), `切分方式仍保留已移除值:${removedMethod}`)
|
||||
}
|
||||
assert.ok(unstructuredOptionsSource.includes('推荐使用文档结构'), '切分方式缺少文档结构默认推荐说明')
|
||||
assert.ok(unstructuredOptionsSource.includes('默认推荐,按标题、段落、列表和表格结构切分'), '版面结构混合切分缺少推荐说明')
|
||||
assert.ok(unstructuredOptionsSource.includes('根据相邻内容的语义变化寻找主题边界'), '语义切分缺少适用场景说明')
|
||||
assert.ok(unstructuredOptionsSource.includes('按句子边界控制固定 Token 长度'), '固定 Token 切分缺少稳定性说明')
|
||||
assert.doesNotMatch(unstructuredOptionsSource, /自定义分隔符/, '切分选项仍保留自定义分隔符')
|
||||
assert.doesNotMatch(taskSetupSource, /customDelimiter|自定义分隔符/, '任务配置仍校验已移除的自定义分隔符')
|
||||
for (const label of ['切片长度', '重叠长度', '最小切片长度', '保护表格、代码和列表']) {
|
||||
assert.ok(unstructuredOptionsSource.includes(label), `切分选项缺少配置:${label}`)
|
||||
}
|
||||
@@ -554,6 +558,8 @@ assert.match(unstructuredOptionsSource, /function updateSpecialContentProtection
|
||||
assert.match(unstructuredOptionsSource, /options\.chunkSize[\s\S]*?:min="200"[\s\S]*?:max="2000"/, '切片长度必须限制在 200 到 2000 Token')
|
||||
assert.match(unstructuredOptionsSource, /options\.chunkOverlap[\s\S]*?:min="0"[\s\S]*?:max="500"/, '重叠长度必须限制在 0 到 500 Token')
|
||||
assert.match(unstructuredOptionsSource, /options\.minChunkSize[\s\S]*?:min="20"[\s\S]*?:max="500"/, '最小切片长度必须限制在 20 到 500 Token')
|
||||
assert.match(unstructuredOptionsSource, /options\.semanticBreakpointPercentile[\s\S]*?:min="1"[\s\S]*?:max="99"/, '语义断点百分位必须限制在 1 到 99')
|
||||
assert.match(unstructuredOptionsSource, /v-if="options\.chunkMethod === 'semantic'"[\s\S]*?options\.semanticBreakpointPercentile/, '语义断点百分位必须仅在语义切分时显示')
|
||||
|
||||
for (const label of ['每个切片生成数量', '数据集划分']) {
|
||||
assert.ok(taskSetupFeatureSource.includes(label), `非结构化生成选项缺少:${label}`)
|
||||
@@ -568,10 +574,11 @@ assert.ok(unstructuredOptionsSource.includes('Token 数为轻量估算值'), '
|
||||
assert.match(unstructuredOptionsSource, /\.chunk-settings-grid\s*\{[\s\S]*?grid-template-columns:\s*repeat\(3,\s*minmax\(0,\s*1fr\)\)/, '核心切分参数没有收紧为三列布局')
|
||||
|
||||
assert.match(viewSource, /const unstructuredOptions = ref<UnstructuredProcessOptions>/, '父页面缺少非结构化配置状态')
|
||||
assert.match(stateSource, /chunkMethod:\s*'structure'/, '非结构化默认切分方式必须为文档结构')
|
||||
assert.match(stateSource, /chunkMethod:\s*'layout_hybrid'/, '非结构化默认切分方式必须为版面结构混合切分')
|
||||
assert.match(stateSource, /chunkSize:\s*800/, '默认切片长度必须为 800 Token')
|
||||
assert.match(stateSource, /chunkOverlap:\s*100/, '默认重叠长度必须为 100 Token')
|
||||
assert.match(stateSource, /minChunkSize:\s*100/, '默认最小切片长度必须为 100 Token')
|
||||
assert.match(stateSource, /semanticBreakpointPercentile:\s*95/, '默认语义断点百分位必须为 95')
|
||||
assert.match(stateSource, /qaPairsPerChunk:\s*1/, '默认每个切片必须生成 1 个问答对')
|
||||
assert.match(viewSource, /v-model:unstructured-options="unstructuredOptions"/, '父页面没有双向绑定非结构化配置')
|
||||
assert.match(viewSource, /JSON\.stringify\(previewAffectingOptions\(\)\)/, '影响切分的非结构化配置没有纳入预览失效判断')
|
||||
@@ -627,7 +634,7 @@ for (const [backendField, frontendField] of [
|
||||
['chunk_size', 'chunkSize'],
|
||||
['chunk_overlap', 'chunkOverlap'],
|
||||
['min_chunk_size', 'minChunkSize'],
|
||||
['custom_delimiter', 'customDelimiter'],
|
||||
['semantic_breakpoint_percentile', 'semanticBreakpointPercentile'],
|
||||
['preserve_tables', 'preserveTables'],
|
||||
['preserve_code_blocks', 'preserveCodeBlocks'],
|
||||
['preserve_lists', 'preserveLists'],
|
||||
@@ -659,7 +666,7 @@ for (const field of [
|
||||
'chunkSize',
|
||||
'chunkOverlap',
|
||||
'minChunkSize',
|
||||
'customDelimiter',
|
||||
'semanticBreakpointPercentile',
|
||||
'preserveTables',
|
||||
'preserveCodeBlocks',
|
||||
'preserveLists',
|
||||
|
||||
Reference in New Issue
Block a user