Skip to content

Commit 2094fdf

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 954cf3d + 13d31cf commit 2094fdf

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/knowledge/utils/kb_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def split_text_into_chunks(text: str, file_id: str, filename: str, params: dict
9090
chunks.append(
9191
{
9292
"id": f"{file_id}_chunk_{chunk_index}",
93-
"content": chunk_content.strip(),
93+
"content": chunk_content, # .strip(),
9494
"file_id": file_id,
9595
"filename": filename,
9696
"chunk_index": chunk_index,

web/src/utils/chunkUtils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function findOverlap(str1, str2) {
1616
let overlap = '';
1717

1818
// 从最长可能的重叠开始检查
19-
for (let i = maxOverlap; i > 0; i--) {
19+
for (let i = maxOverlap; i > 10; i--) {
2020
const endStr1 = str1.slice(-i);
2121
const startStr2 = str2.slice(0, i);
2222

@@ -63,7 +63,11 @@ export function mergeChunks(chunks) {
6363

6464
if (newContent.length > 0) {
6565
const startOffset = currentContent.length;
66-
currentContent += newContent;
66+
if (overlap.length > 0) {
67+
currentContent += newContent;
68+
} else {
69+
currentContent += `\n${newContent}`;
70+
}
6771
merged.push({
6872
...chunk,
6973
startOffset,

0 commit comments

Comments
 (0)