Calculates the optimal length for the next text chunk.
Splits at the last separator within max_length, considering only separators in the latter half to avoid tiny chunks.
max_length
The text to split.
Maximum chunk length (positive safe integer).
Split points in order of preference (default: ['\n', ' ', '.']).
['\n', ' ', '.']
The calculated chunk length.
If max_length is not a positive safe integer.
Calculates the optimal length for the next text chunk.
Splits at the last separator within
max_length, considering only separators in the latter half to avoid tiny chunks.