fix: Optimize the header start position
This commit is contained in:
@@ -263,14 +263,11 @@ class TextSplitter(BaseModel, Generic[T]):
|
|||||||
and split_len + cur_headers_len < self.chunk_size
|
and split_len + cur_headers_len < self.chunk_size
|
||||||
and cur_headers not in split
|
and cur_headers not in split
|
||||||
):
|
):
|
||||||
cur_chunk.insert(
|
next_start = cur_chunk[0][0] if cur_chunk else cur_start
|
||||||
0,
|
header_start = max(0, next_start - cur_headers_len)
|
||||||
(
|
header_end = cur_end
|
||||||
cur_chunk[0][0] if cur_chunk else cur_start,
|
|
||||||
cur_chunk[0][1] if cur_chunk else cur_end,
|
cur_chunk.insert(0, (header_start, header_end, cur_headers))
|
||||||
cur_headers,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
cur_len += cur_headers_len
|
cur_len += cur_headers_len
|
||||||
|
|
||||||
# Add current split to the chunk
|
# Add current split to the chunk
|
||||||
|
|||||||
Reference in New Issue
Block a user