Repository navigation
Conversation
|
Issue was reproduced. Have 0 questions for PR. Ready to QA. |
|
Thanks for picking this up so quickly. I ran this branch's It does what it says:
And it loses nothing: the whitespace-normalised text of every file's chunks is identical to One thing it introduces. The run produces 40 chunks under 20 characters, where Counting the separator removes them: if chunk_text and len(chunk_text) + 2 + len(p) > MAX_CHUNK_CHARS:
A unit test is unlikely to hit this by accident, because it needs two paragraphs landing within two a = " ".join(["word"] * 600) # 2,999 chars
b = " ".join(["word"] * 600) + "s" # 3,000 chars
chunks = _chunk_markdown("# H\n\n" + a + "\n\n" + b, "t.md")
print([len(c["text"]) for c in chunks])
# as is: [5995, 5]
# with + 2: [2999, 3000]Separately, while checking for lost text I found that |
|
Thanks — confirmed both. The I folded #378 in. with this PR a heading-less file is indexed in full, but a file with one stray Both are covered by tests in tests/test_rag_chunking.py. |
|
A small heads-up: the push on 7 October contains only the merge from
|
|
Pushed now. The description was ahead of the branch; the fixes are in 52ae97b. Sorry about that. |
|
Thanks, confirmed at |
Description
Fixes #369.
Fixes #378.
_chunk_markdownreturned a heading-less file as one chunk and skippedMAX_CHUNK_CHARS. A file with headings could still exceed the cap when a single paragraph was longer than the limit, because the splitter only cuts on blank lines.#heading is now one section and goes through the same size pass as headed files.MAX_CHUNK_CHARSafter the paragraph split is cut on a newline or space, or mid-token when there is no whitespace."\n\n"join against the cap. Without this it built chunks of 6001–6002 characters, and the character-level cut then left a 1–13 character fragment that was embedded as its own chunk.HEADING_REmatches[ \t]+instead of\s+so a lone#on its own line is no longer read as a heading (_chunk_markdowndrops all text before the first#heading #378).How Has This Been Tested?
python3 -m pytest tests/test_rag_chunking.pyMAX_CHUNK_CHARSis split, and every chunk stays within the cap.Top,Top > Nested,Second) are unchanged.[2999, 3000], not[5995, 5].#line is not treated as a heading.Checklist