Skip to content

Commit 83b538b

Browse files
authored
(retriever) follow up markdown review (#1553)
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
1 parent 2b93c78 commit 83b538b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

nemo_retriever/src/nemo_retriever/io/markdown.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ def to_markdown_by_page(results: object) -> dict[int, str]:
5959
return rendered
6060

6161

62-
def to_markdown(results: object) -> str:
62+
def to_markdown(results: object) -> str | None:
6363
"""Render a single document result as one markdown document."""
6464
pages = to_markdown_by_page(results)
6565
if not pages:
66-
return f"# {_DOCUMENT_TITLE}\n\n_No content found._"
66+
return None
6767
return f"# {_DOCUMENT_TITLE}\n\n" + "\n\n".join(pages.values())
6868

6969

@@ -110,6 +110,9 @@ def _records_from_mapping(results: Mapping[str, Any]) -> list[dict[str, Any]]:
110110
return [dict(results)]
111111
raise ValueError("Markdown rendering expects a document row, row list, or saved results payload.")
112112

113+
# TODO(jioffe): Centralize retriever result-shape detection so helpers and
114+
# actor outputs do not rely on duplicated key-based heuristics.
115+
113116

114117
def _looks_like_record(record: Mapping[str, Any]) -> bool:
115118
return any(

nemo_retriever/tests/test_io_markdown.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def test_to_markdown_reads_saved_records_wrapper(tmp_path: Path) -> None:
120120
assert "### Table 1" in markdown
121121

122122

123-
def test_to_markdown_empty_results_returns_placeholder() -> None:
124-
assert to_markdown([]) == "# Extracted Content\n\n_No content found._"
123+
def test_to_markdown_empty_results_returns_none() -> None:
124+
assert to_markdown([]) is None
125125

126126

127127
def test_to_markdown_rejects_multi_document_results() -> None:

0 commit comments

Comments
 (0)