Merge plain-text content parts in encoding_k3.py to align tokenization

#20

Join text-only content parts before tokenization so BPE merges can cross part boundaries. Skip merging if either reasoning_content or reasoning is a non-empty string, including whitespace-only strings. This rule is independent of thinking. Content containing other part types keeps its existing behavior.

For example, these messages produce identical token IDs with the same encoding options:

{"role": "user", "content": [{"type": "text", "text": "hel"}, {"type": "text", "text": "lo"}]}
{"role": "user", "content": "hello"}
bigmoyan changed pull request status to merged

Sign up or log in to comment