Add inline text ingestion support - #2384
Conversation
Greptile SummaryThis PR adds
|
| Filename | Overview |
|---|---|
| nemo_retriever/src/nemo_retriever/common/inline_text.py | New module providing shared inline-text identity utilities. Well-typed, correctly handles scalars/sequences, but silently accepts bytes through the Sequence duck-type check, producing a confusing 'got int' error instead of 'got bytes'. |
| nemo_retriever/src/nemo_retriever/common/modality/txt/split.py | Refactored to extract text_to_chunks_df as the canonical single-pass splitter; txt_file_to_chunks_df and txt_bytes_to_chunks_df now delegate to it. Adds empty_text_chunks_df() to unify the empty-result schema (now includes the previously-missing content column). Well-documented. |
| nemo_retriever/src/nemo_retriever/ingestor/graph_ingestor.py | Core implementation of texts() for library mode. Blank-only early-exit, mixed-source branch detection, and inline dataset construction look correct. The _has_mixed_inline_sources() check treats _inline_texts=[] as active, which may surprise callers who pass a dynamically empty list. |
| nemo_retriever/src/nemo_retriever/ingestor/branch_extraction.py | Cleanly extended to split branch inputs into file paths and inline rows. Batch path creates two datasets per branch when both are present; they share the same output schema after TxtSplitCPUActor so union is safe. |
| nemo_retriever/src/nemo_retriever/service/service_ingestor.py | Service-mode inline text support via InMemoryUpload, blank-only short-circuit, and auto-mode routing for mixed sources. _collect_inputs return type is now list[UploadInput] (was list[Path]). Early-exit return tuples for return_failures/return_traces correctly match the normal-path contract. |
| nemo_retriever/src/nemo_retriever/service/client.py | Introduces InMemoryUpload NamedTuple and UploadInput union type; _upload_one / ingest_documents / aingest_documents_stream updated uniformly. Backward-compatible (existing Path usage unchanged). |
| nemo_retriever/src/nemo_retriever/operators/extract/txt/ray_data.py | Adds the text_to_chunks_df branch for inline-text rows alongside the existing bytes branch. Exception handler now logs source path with exc_info=True (previously flagged in prior review, now addressed). preprocess returns empty_text_chunks_df() for schema consistency. |
| nemo_retriever/src/nemo_retriever/service/routers/ingest.py | Routing change: TEXT and HTML file categories now fast-path to REALTIME pool (same as IMAGE), avoiding unnecessary PDF page-count parsing. Comment updated to match. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["User calls .texts(['a', 'b'])"] --> B{Any text strip?}
B -- "No (all blank,\nno files/buffers)" --> C["Short-circuit:\nreturn empty_text_chunks_df()"]
B -- "Yes or mixed\nwith files" --> D{Has mixed\ninline + files?}
D -- No --> E["_execute_single_graph\n(inline_text_dataframe\nor inline_text_dataset)"]
D -- Yes --> F["Build manifest\nplan_extraction_branches()"]
F --> G["ExtractionBranchExecutor\n_partition_branch_inputs()"]
G --> H["File paths -> build_dataset(paths)"]
G --> I["Inline rows -> build_dataset(ray.data.from_items)"]
H --> J["TxtSplitCPUActor\ntxt_bytes_to_chunks_df()"]
I --> K["TxtSplitCPUActor\ntext_to_chunks_df()"]
E --> K
J --> L["normalize_ray_branch_datasets\nunion + to_pandas()"]
K --> L
L --> M["Embed -> VDB -> result DataFrame"]
Reviews (10): Last reviewed commit: "Merge branch 'main' into jioffe502/inlin..." | Re-trigger Greptile
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
7888b78 to
57bc3e9
Compare
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Summary
texts()for ingesting raw Python strings without temporary filesCloses #2345.
Validation