feat: 完善文档分块参数配置

- 支持自定义正则匹配内容保留开关及配置持久化

- 约束分块重叠长度始终小于分块长度

- 补充中英文交互文案
This commit is contained in:
2026-08-10 23:57:56 +08:00
parent 742a4b1647
commit 6c491bd893
4 changed files with 48 additions and 1 deletions

View File

@@ -159,6 +159,9 @@
"chunkSize": "SegmentLength",
"overlapSize": "SegmentOverlap",
"regex": "RegularExpression",
"regexMatchHandling": "Matched content",
"retainRegexMatch": "Keep in next chunk",
"discardRegexMatch": "Discard",
"document": "Document",
"simpleDocumentSplitter": "SimpleDocumentSplitter",
"simpleTokenizeSplitter": "SimpleTokenizeSplitter",

View File

@@ -159,6 +159,9 @@
"chunkSize": "分段长度",
"overlapSize": "分段重叠",
"regex": "正则表达式",
"regexMatchHandling": "匹配内容处理",
"retainRegexMatch": "保留到下一分块",
"discardRegexMatch": "不保留",
"document": "文档",
"simpleDocumentSplitter": "简单文档分割器",
"simpleTokenizeSplitter": "简单分词器",

View File

@@ -13,6 +13,7 @@ import {
ElOption,
ElSelect,
ElSlider,
ElSwitch,
} from 'element-plus';
import { api } from '#/api/request';
@@ -88,6 +89,7 @@ const createDefaultFormState = () => ({
mdSplitterLevel: 2,
overlapSize: 128,
regex: '',
retainRegexMatch: false,
rowsPerChunk: 10,
strategyCode: 'AUTO',
});
@@ -154,6 +156,10 @@ const showLengthSettings = (strategyCode?: string) =>
const showOverlapSettings = (strategyCode?: string) =>
['AUTO', 'PARAGRAPH_LENGTH'].includes(strategyCode || '');
const maxOverlapSize = computed(() =>
Math.max(0, Number(formState.chunkSize || 0) - 1),
);
const clearPreviewTimer = () => {
if (!previewDebounceTimer) {
return;
@@ -388,6 +394,15 @@ watch(
{ immediate: true },
);
watch(
() => formState.chunkSize,
() => {
if (formState.overlapSize > maxOverlapSize.value) {
formState.overlapSize = maxOverlapSize.value;
}
},
);
watch(
formState,
() => {
@@ -456,7 +471,7 @@ watch(
>
<ElSlider
v-model="formState.overlapSize"
:max="512"
:max="Math.min(512, maxOverlapSize)"
:min="0"
show-input
/>
@@ -484,6 +499,20 @@ watch(
>
<ElInput v-model="formState.regex" />
</ElFormItem>
<ElFormItem
v-if="formState.strategyCode === 'CUSTOM_REGEX'"
:label="$t('documentCollection.splitterDoc.regexMatchHandling')"
class="workbench__form-full"
>
<ElSwitch
v-model="formState.retainRegexMatch"
:active-text="$t('documentCollection.splitterDoc.retainRegexMatch')"
:inactive-text="
$t('documentCollection.splitterDoc.discardRegexMatch')
"
/>
</ElFormItem>
</div>
</ElForm>