Skip to content

Commit 3ccc1c7

Browse files
authored
Merge pull request #615 from sugarforever/feature/chunk-setting
Feature/chunk setting
2 parents 6595e9b + e1496fe commit 3ccc1c7

File tree

15 files changed

+8998
-7028
lines changed

15 files changed

+8998
-7028
lines changed

components/KnowledgeBaseForm.vue

+41-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ const props = defineProps<{
99
title: string
1010
type: OperateType
1111
data?: KnowledgeBase
12-
embeddings: string[]
12+
embeddings: string[],
13+
chunking: {
14+
parentChunkSize: number,
15+
parentChunkOverlap: number,
16+
childChunkSize: number,
17+
childChunkOverlap: number,
18+
parentK: number,
19+
childK: number,
20+
}
1321
onSuccess: () => void
1422
onClose: () => void
1523
}>()
@@ -28,6 +36,14 @@ const state = reactive({
2836
pageParser: 'default' as PageParser,
2937
maxDepth: 0,
3038
excludeGlobs: '',
39+
chunking: {
40+
parentChunkSize: props.chunking.parentChunkSize,
41+
parentChunkOverlap: props.chunking.parentChunkOverlap,
42+
childChunkSize: props.chunking.childChunkSize,
43+
childChunkOverlap: props.chunking.childChunkOverlap,
44+
parentK: props.chunking.parentK,
45+
childK: props.chunking.childK,
46+
}
3147
})
3248
const loading = ref(false)
3349
const isModify = computed(() => props.type === 'update')
@@ -81,6 +97,7 @@ async function onSubmit() {
8197
formData.append("pageParser", state.pageParser)
8298
formData.append("maxDepth", String(state.maxDepth))
8399
formData.append("excludeGlobs", state.excludeGlobs)
100+
formData.append("chunking", JSON.stringify(state.chunking))
84101
85102
if (isModify.value) {
86103
formData.append('knowledgeBaseId', String(props.data!.id))
@@ -168,6 +185,29 @@ function generateEmbeddingData(groupName: string, list: string[], slotName: stri
168185
<UTextarea autoresize :maxrows="4" v-model="state.description" />
169186
</UFormGroup>
170187

188+
<UFormGroup :label="t('knowledgeBases.chunking')" name="chunking" class="mb-4">
189+
<div class="grid grid-cols-2 gap-4">
190+
<UFormGroup label="Parent Chunk Size" name="parentChunkSize">
191+
<UInput v-model="state.chunking.parentChunkSize" type="number" />
192+
</UFormGroup>
193+
<UFormGroup label="Parent Chunk Overlap" name="parentChunkOverlap">
194+
<UInput v-model="state.chunking.parentChunkOverlap" type="number" />
195+
</UFormGroup>
196+
<UFormGroup label="Child Chunk Size" name="childChunkSize">
197+
<UInput v-model="state.chunking.childChunkSize" type="number" />
198+
</UFormGroup>
199+
<UFormGroup label="Child Chunk Overlap" name="childChunkOverlap">
200+
<UInput v-model="state.chunking.childChunkOverlap" type="number" />
201+
</UFormGroup>
202+
<UFormGroup label="Parent K" name="parentK">
203+
<UInput v-model="state.chunking.parentK" type="number" />
204+
</UFormGroup>
205+
<UFormGroup label="Child K" name="childK">
206+
<UInput v-model="state.chunking.childK" type="number" />
207+
</UFormGroup>
208+
</div>
209+
</UFormGroup>
210+
171211
<UFormGroup :label="t('knowledgeBases.publicAccessible')" name="public" class="mb-4">
172212
<p class="text-xs mb-2 text-pink-600 dark:text-pink-300">{{ t("knowledgeBases.publicAccessibleTip") }}</p>
173213
<UToggle v-model="state.isPublic" />

locales/en-US.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
"NoOfFiles": "No. Of Files",
4949
"description": "Description",
5050
"embedding": "Embedding",
51+
"chunking": "Chunking",
52+
"parentChunkSize": "Parent Chunk Size",
53+
"parentChunkOverlap": "Parent Chunk Overlap",
54+
"childChunkSize": "Child Chunk Size",
55+
"childChunkOverlap": "Child Chunk Overlap",
56+
"parentK": "Parent K",
57+
"childK": "Child K",
5158
"deleteConfirm": "Are you sure deleting knowledge base {0} ?",
5259
"deleteTitle": "Delete Knowledge Base",
5360
"createTitle": "Create a New Knowledge Base",
@@ -186,4 +193,4 @@
186193
"add": "Add",
187194
"invalidUrl": "Invalid URL"
188195
}
189-
}
196+
}

locales/zh-CN.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
"NoOfFiles": "文件数量",
4949
"description": "描述",
5050
"embedding": "嵌入模型",
51+
"chunking": "分块",
52+
"parentChunkSize": "父级分块大小",
53+
"parentChunkOverlap": "父级分块重叠",
54+
"childChunkSize": "子级分块大小",
55+
"childChunkOverlap": "子级分块重叠",
56+
"parentK": "父级K",
57+
"childK": "子级K",
5158
"deleteConfirm": "是否删除知识库:{0}",
5259
"deleteTitle": "删除知识库",
5360
"createTitle": "创建新知识库",
@@ -185,4 +192,4 @@
185192
"selectModels": "选择模型",
186193
"invalidUrl": "无效的URL"
187194
}
188-
}
195+
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@langchain/azure-openai": "^0.0.4",
4444
"@langchain/cohere": "^0.0.6",
4545
"@langchain/community": "^0.3.19",
46-
"@langchain/core": "^0.3.23",
46+
"@langchain/core": "^0.3.37",
4747
"@langchain/google-genai": "^0.1.5",
4848
"@langchain/groq": "^0.0.5",
4949
"@langchain/ollama": "^0.1.3",

pages/knowledgebases/index.vue

+16
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ function onShowCreate() {
6363
type: 'create',
6464
title: t('knowledgeBases.createTitle'),
6565
embeddings: embeddings.value,
66+
chunking: {
67+
parentChunkSize: 3000,
68+
parentChunkOverlap: 200,
69+
childChunkSize: 1000,
70+
childChunkOverlap: 50,
71+
parentK: 5,
72+
childK: 10,
73+
},
6674
onClose: () => modal.close(),
6775
onSuccess: () => refresh()
6876
})
@@ -74,6 +82,14 @@ function onShowUpdate(data: KnowledgeBase) {
7482
title: t('knowledgeBases.updateTitle'),
7583
data,
7684
embeddings: embeddings.value,
85+
chunking: {
86+
parentChunkSize: data.parentChunkSize || 3000,
87+
parentChunkOverlap: data.parentChunkOverlap || 200,
88+
childChunkSize: data.childChunkSize || 1000,
89+
childChunkOverlap: data.childChunkOverlap || 50,
90+
parentK: data.parentK || 5,
91+
childK: data.childK || 10,
92+
},
7793
onClose: () => modal.close(),
7894
onSuccess: () => refresh()
7995
})

0 commit comments

Comments
 (0)