Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

refactor: Refactor rune handling for correct chunk merging

begoniezhao5f7c23a1b949
diff --git a/internal/application/service/chat_pipline/merge.go b/internal/application/service/chat_pipline/merge.go
index 68d1b77c5..c1ed13ee8 100644
--- a/internal/application/service/chat_pipline/merge.go
+++ b/internal/application/service/chat_pipline/merge.go
@@ -101,9 +101,9 @@ func (p *PluginMerge) OnEvent(ctx context.Context,
}
// Merge overlapping chunks
if chunks[i].EndAt > lastChunk.EndAt {
- content := string([]rune(chunks[i].Content))
- offset := len(content) - (chunks[i].EndAt - lastChunk.EndAt)
- lastChunk.Content = lastChunk.Content + content[offset:]
+ contentRunes := []rune(chunks[i].Content)
+ offset := len(contentRunes) - (chunks[i].EndAt - lastChunk.EndAt)
+ lastChunk.Content = lastChunk.Content + string(contentRunes[offset:])
lastChunk.EndAt = chunks[i].EndAt
lastChunk.SubChunkID = append(lastChunk.SubChunkID, chunks[i].ID)