mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-21 16:04:21 +01:00
fix chunk creation
the last chunk wasn't correctly created, this commit fix that issue.
This commit is contained in:
@@ -38,11 +38,12 @@ def split_file(content, max_length=4000, overlap=0):
|
|||||||
chunk = content[start:end]
|
chunk = content[start:end]
|
||||||
yield chunk
|
yield chunk
|
||||||
start += max_length - overlap
|
start += max_length - overlap
|
||||||
if start + max_length - overlap >= content_length:
|
if start + max_length > content_length:
|
||||||
break
|
|
||||||
if end + overlap > content_length:
|
|
||||||
start = content_length - max_length
|
start = content_length - max_length
|
||||||
|
end = content_length
|
||||||
|
chunk = content[start:end]
|
||||||
|
yield chunk
|
||||||
|
break
|
||||||
|
|
||||||
def read_file(filename):
|
def read_file(filename):
|
||||||
"""Read a file and return the contents"""
|
"""Read a file and return the contents"""
|
||||||
|
|||||||
Reference in New Issue
Block a user