GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: v0.5.0 chunks 도구에 include_furniture 파라미터 추가 · DanMeon/rhwp-python@44b558b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs
    • roadmap/v0.5.0
      • mcp.md
    • traces
      • coverage.md
  • python/rhwp/mcp
    • tools.py
  • tests
    • test_mcp_server.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/roadmap/v0.5.0/mcp.md‎

Copy file name to clipboardExpand all lines: docs/roadmap/v0.5.0/mcp.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ v0.5.0 시점이 sweet spot 인 이유:
5454
| `iter_blocks(path, kind, scope, limit)` | `path: str`, `kind: Literal["paragraph", "table", "picture", ...]`, `scope: Literal["body", "furniture", "all"]`, `limit: int \| None` | `list[dict]` | core |
5555
| `to_markdown(path)` | `path: str` | `str` | **v0.4.0 view 의존** |
5656
| `to_html(path, include_css: bool)` | `path: str`, `include_css: bool = False` | `str` | **v0.4.0 view 의존** |
57-
| `chunks(path, mode, size, overlap)` | `path: str`, `mode: Literal["single", "paragraph", "ir-blocks"]`, `size: int = 500`, `overlap: int = 50` | `list[{page_content, metadata}]` | langchain-text-splitters |
57+
| `chunks(path, mode, size, overlap, include_furniture)` | `path: str`, `mode: Literal["single", "paragraph", "ir-blocks"]`, `size: int = 500`, `overlap: int = 50`, `include_furniture: bool = False` (`mode="ir-blocks"` 에서만 의미 — page_headers / page_footers / footnotes / endnotes 도 chunked Document 로 yield, metadata `scope="furniture"`. 다른 mode 에서는 무시) | `list[{page_content, metadata}]` | langchain-text-splitters |
5858

5959
**도구 명명 규칙**:
6060

Collapse file

‎docs/traces/coverage.md‎

Copy file name to clipboardExpand all lines: docs/traces/coverage.md
+2Lines changed: 2 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ v0.4.0+ 신규 spec 의 인수조건 ↔ 테스트 매핑. 기존 v0.1.0 ~ v0.3.
535535
| v0.4.0/view-renderer | AC-9 | `tests/test_view_html.py::test_to_html_include_css_real_fixture_well_formed` |
536536
| v0.4.0/view-renderer | AC-9 | `tests/test_view_html.py::test_to_html_include_css_true_has_exactly_one_style_in_head` |
537537
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestChunks::test_default_paragraph_mode` |
538+
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestChunks::test_include_furniture_appends_furniture_chunks` |
539+
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestChunks::test_include_furniture_ignored_outside_ir_blocks` |
538540
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestChunks::test_missing_extras_does_not_break_other_tools` |
539541
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestChunks::test_missing_extras_raises_tool_error` |
540542
| v0.5.0/mcp | — | `tests/test_mcp_server.py::TestChunks::test_modes_all_supported` |
Collapse file

‎python/rhwp/mcp/tools.py‎

Copy file name to clipboardExpand all lines: python/rhwp/mcp/tools.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def chunks(
150150
mode: ChunksMode = "paragraph",
151151
size: int = 500,
152152
overlap: int = 50,
153+
include_furniture: bool = False,
153154
) -> list[dict[str, Any]]:
154155
"""HWP/HWPX 를 RAG 청크 리스트로 변환 (LangChain ``RecursiveCharacterTextSplitter``).
155156
@@ -165,10 +166,15 @@ def chunks(
165166
166167
- ``"single"``: 전체 문서를 단일 Document
167168
- ``"paragraph"``: 문단 텍스트별 Document (기본)
168-
- ``"ir-blocks"``: IR Block 단위 (표 구조 보존 + Provenance metadata,
169-
본문만 — page_headers / footnotes / endnotes 제외)
169+
- ``"ir-blocks"``: IR Block 단위 (표 구조 보존 + Provenance metadata)
170170
size: ``RecursiveCharacterTextSplitter`` 의 ``chunk_size`` (문자 수).
171171
overlap: 청크 간 오버랩 문자 수.
172+
include_furniture: ``mode="ir-blocks"`` 에서만 의미. True 면 본문 청크
173+
다음에 furniture (page_headers / page_footers / footnotes / endnotes)
174+
도 chunked Document 로 yield 하며, 각 chunk 의 ``metadata`` 에
175+
``scope="furniture"`` 가 부여돼 RAG 가 body/furniture 를 분리 색인.
176+
다른 mode 에서는 무시 (``HwpLoader`` 와 동일 의미). 기본 False —
177+
RAG body 검색 오염 회피.
172178
173179
Returns:
174180
``[{"page_content": str, "metadata": dict}]`` — LangChain Document 의
@@ -186,7 +192,7 @@ def chunks(
186192
# transitive 로 끌어오므로 위 try/except 이 통과하면 같이 import 가능.
187193
from rhwp.integrations.langchain import HwpLoader
188194

189-
loader = HwpLoader(path, mode=mode)
195+
loader = HwpLoader(path, mode=mode, include_furniture=include_furniture)
190196
docs = loader.load()
191197
splitter = RecursiveCharacterTextSplitter(chunk_size=size, chunk_overlap=overlap)
192198
split_docs = splitter.split_documents(docs)
Collapse file

‎tests/test_mcp_server.py‎

Copy file name to clipboardExpand all lines: tests/test_mcp_server.py
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,36 @@ def test_size_overlap_pass_through(self, hwp_sample: Path) -> None:
263263
# ^ 작은 청크 사이즈가 더 많은 청크를 생성 (또는 같음 — 짧은 문서 한계)
264264
assert len(small) >= len(large)
265265

266+
def test_include_furniture_appends_furniture_chunks(self, hwp_sample: Path) -> None:
267+
"""``mode="ir-blocks"`` + ``include_furniture=True`` 가 furniture chunked Document 추가."""
268+
pytest.importorskip("langchain_text_splitters")
269+
body_only = tools.chunks(str(hwp_sample), mode="ir-blocks", include_furniture=False)
270+
with_furniture = tools.chunks(str(hwp_sample), mode="ir-blocks", include_furniture=True)
271+
# ^ furniture 가 추가되므로 청크 수가 증가하거나 같음 (샘플에 furniture 가 없으면 같음)
272+
assert len(with_furniture) >= len(body_only)
273+
# ^ aift.hwp 샘플은 page_headers 를 보유 —
274+
# 한 개 이상 추가 청크가 ``scope="furniture"`` 메타로 yield
275+
furniture_chunks = [c for c in with_furniture if c["metadata"].get("scope") == "furniture"]
276+
assert furniture_chunks, (
277+
"aift.hwp 는 page_headers 를 보유 — include_furniture=True 가 "
278+
"'scope=furniture' 메타로 청크를 yield 해야 함"
279+
)
280+
281+
def test_include_furniture_ignored_outside_ir_blocks(self, hwp_sample: Path) -> None:
282+
"""``mode="single"`` / ``"paragraph"`` 에서 ``include_furniture`` 는 silently 무시."""
283+
pytest.importorskip("langchain_text_splitters")
284+
for mode in ("single", "paragraph"):
285+
without = tools.chunks(str(hwp_sample), mode=mode) # type: ignore[arg-type]
286+
with_flag = tools.chunks(
287+
str(hwp_sample),
288+
mode=mode,
289+
include_furniture=True, # type: ignore[arg-type]
290+
)
291+
# ^ ir-blocks 외 모드에서는 HwpLoader 가 include_furniture 를 무시 — 결과 동일
292+
assert len(without) == len(with_flag), (
293+
f"mode={mode!r} should ignore include_furniture (HwpLoader 동일 의미)"
294+
)
295+
266296
@pytest.mark.spec("v0.5.0/mcp#AC-7")
267297
def test_missing_extras_raises_tool_error(
268298
self, hwp_sample: Path, monkeypatch: pytest.MonkeyPatch

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.