Repository navigation
fix(chunker): keep the CSV two-cell QA contract on the JSON item path - #19635
devYRPauli wants to merge 1 commit into
Conversation
Python qa.py:365 reads a CSV row as a Q&A pair only when the row holds exactly two fields. infiniflow#19008 ported that rule into extractQATable as the strictPairs flag, reached through the PayloadFormatHTML branch of the QA chunker. infiniflow#19467 changed csv_parser.go to return OutputFormat "json". No parser in internal/parser/parser emits "html" any more, so CSV now lands in the default branch, which called extractQAJSON. That function hardcoded strictPairs false, so the rule stopped running and a row like "question,,extra" produced a pair again. Pass the flag down. extractQAJSON takes strictPairs and hands it to extractQATable. The call site derives it with the existing isCSV helper, which had no live caller left. The workbook path is unchanged. Python's Excel class takes the first two non-empty cells of a row, so xlsx and xls keep strictPairs false. Co-Authored-By: Claude Opus 5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe QA chunker now passes the source format into JSON table extraction. CSV inputs use strict two-field pairing, while XLSX inputs retain lenient pairing. Tests cover both behaviors. ChangesCSV QA pairing
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The CSV-specific pairing change and XLSX compatibility coverage do not show an unresolved merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. I twitch my nose at pairs in line Comment |
|
One more defect in the same function, found while measuring this change. It sits on
Measured end to end through
At
|
|
pls check #19467 -- all output from parser will be in "JSON" format and decide if any changes needed for this PR. |
|
Closing this. #19611 landed the change while it was open.
I ran @xugangqiang this also answers your question on #19235. #19235 is now the only open PR that touches |
Summary
Fixes #19006 again. The fix from #19008 stopped running on
main.Python
rag/app/qa.py:365reads a CSV row as a Q&A pair only when the row holds exactly two fields. #19008 ported that rule intoextractQATableas thestrictPairsflag. The QA chunker set it fromisCSV(upstream.Name)on thePayloadFormatHTMLbranch.#19467 changed
csv_parser.goto returnOutputFormat: spreadsheetOutputFormat, which is"json". I checked all 30OutputFormat:sites ininternal/parser/parserand none of them is"html"now. CSV therefore lands in thedefaultbranch, which calledextractQAJSON. That function hardcodedextractQATable(txt, false), so the rule stopped running andisCSVwas left with no live caller.The change passes the flag down.
extractQAJSONtakesstrictPairsand hands it toextractQATable. The call site derives it with the existingisCSVhelper.The workbook path does not change. Python's
Excelclass takes the first two non-empty cells of a row, soxlsxandxlskeepstrictPairsfalse. The second new test pins that.Measurement
CGO_ENABLED=0 go test ./internal/ingestion/component/chunker/...withTIKTOKEN_CACHE_DIRpointed at a directory holdingcl100k_base. macOS arm64, Go 1.27.1.bash build.sh --testcannot run on this host becauseoffice_oxideships a Linux x86_64 static library only, and this package is pure Go.mainat58035bdfe, unmodifiedmainplus the two new tests, fix revertedmainplus the whole changeThe middle row is the mutation test. With the fix reverted,
TestQAChunker_CSVJSONItemsKeepStrictPairsfails and reports two chunks:The second chunk is the defect #19006 reported. The row is
question,,extra, which has three fields.TestQAChunker_XLSXJSONItemsStayLenientpasses in every row of the table, so the failure is CSV only.gofmt -landgo vetare clean on the package.Note on #19611
#19611 rewrites this file. It re-adds the contract on its new typed row path, and its HTML fallback still calls
extractQATable(txt, false). This change is two lines on the currentmain, so it is easy to drop or rebase when that lands.