def chunk_text(text, chunk_size=400, overlap=80): chunks = [] start = 0 text_length = len(text) while start < text_length: end = min(start + chunk_size, text_length) chunks.append(text[start:end]) start += chunk_size - overlap return chunks