Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions prepline_general/api/models/form_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ def as_form(
] = False,
# -- chunking options --
chunking_strategy: Annotated[
Optional[Literal["by_title"]],
Optional[Literal["by_title", "basic"]],
Form(
title="Chunking Strategy",
description="Use one of the supported strategies to chunk the returned elements. Currently supports: by_title",
examples=["by_title"],
description="Use one of the supported strategies to chunk the returned elements. Currently supports: by_title and basic. Default: None",
examples=["by_title", "basic"],
),
] = None,
combine_under_n_chars: Annotated[
Expand Down
27 changes: 27 additions & 0 deletions test_general/api/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,3 +1155,30 @@ def test_include_slide_notes(monkeypatch, test_default, include_slide_notes, tes
assert "Here are important notes" == df["text"][0]
else:
assert "Here are important notes" != df["text"][0]

def test_basic_chunking_strategy():
"""
Verify that basic chunking strategy works as expected
"""
client = TestClient(app)
test_file = Path("sample-docs") / "layout-parser-paper-fast.pdf"
response = client.post(
MAIN_API_ROUTE,
files=[("files", (str(test_file), open(test_file, "rb")))],
data={"strategy": "hi_res"},
)
assert response.status_code == 200
response_without_chunking = response.json()

# chunking
response = client.post(
MAIN_API_ROUTE,
files=[("files", (str(test_file), open(test_file, "rb")))],
data={"chunking_strategy": "basic"},
)
assert response.status_code == 200

response_with_chunking = response.json()
assert len(response_with_chunking) != len(response_without_chunking)
assert "CompositeElement" in [element.get("type") for element in response_with_chunking]

Loading