Skip to content
Merged
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
9 changes: 9 additions & 0 deletions specs/llmwhisperer.json
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,15 @@
},
"x-internal": true
},
{
"in": "query",
"name": "include_cell_borders",
"required": false,
"schema": {
"default": true,
"type": "boolean"
}
},
{
"in": "query",
"name": "include_line_confidence",
Expand Down
15 changes: 15 additions & 0 deletions src/unstract/llmwhisperer/_sdk_llmwhisperer/api/whisper/extract.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/unstract/llmwhisperer/client_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"derotate_threshold",
"checkbox_confidence_threshold",
"min_table_width",
"include_cell_borders",
# In URL mode the URL travels in the body; it is not also a query
# parameter, so `url` is deliberately absent here.
"url_in_post",
Expand Down Expand Up @@ -703,6 +704,7 @@ def whisper( # noqa: C901
derotate_threshold: float | None = None,
checkbox_confidence_threshold: float | None = None,
min_table_width: float | None = None,
include_cell_borders: bool | None = None,
) -> Any:
"""Sends a request to the LLMWhisperer API to process a document.
Refer to https://docs.unstract.com/llm_whisperer/apis/llm_whisperer_text_extraction_api.
Expand Down Expand Up @@ -770,6 +772,12 @@ def whisper( # noqa: C901
[0.0, 1.0]. Defaults to 0.3.
min_table_width (float, optional): The minimum width a table must span, as a
fraction of the page width, to be extracted as a table. Defaults to 0.
include_cell_borders (bool, optional): Whether an Excel workbook's own cell borders
are drawn into the extracted text as box-drawing characters. Turning it off drops
every border, leaving columns aligned and no cell value lost, which costs fewer
tokens downstream. This keys off the uploaded file type, not the mode: it applies
to any XLS or XLSX upload whatever mode was requested, the default "form" mode
included, and is ignored for every other kind of document. Defaults to True.

Returns:
Dict[Any, Any]: The response from the API as a dictionary.
Expand Down Expand Up @@ -834,6 +842,7 @@ def whisper( # noqa: C901
("derotate_threshold", derotate_threshold),
("checkbox_confidence_threshold", checkbox_confidence_threshold),
("min_table_width", min_table_width),
("include_cell_borders", include_cell_borders),
)
if value is not None
}
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/client_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,27 @@ def test_whisper_rejects_both_spellings(
_whisper_query(mocker, client_v2, **{deprecated_name: "x", name: "y"})


# --- include_cell_borders tests ---


def test_whisper_omits_include_cell_borders_by_default(mocker: MockerFixture, client_v2: LLMWhispererClientV2) -> None:
"""Unset means absent, so the service picks, and a deployment that predates
the parameter is unaffected."""
query = _whisper_query(mocker, client_v2)

assert "include_cell_borders" not in query


@pytest.mark.parametrize(("value", "expected"), [(False, "False"), (True, "True")])
def test_whisper_sends_include_cell_borders_when_set(
mocker: MockerFixture, client_v2: LLMWhispererClientV2, value: bool, expected: str
) -> None:
"""Either value reaches the query string once the caller asks for it."""
query = _whisper_query(mocker, client_v2, include_cell_borders=value)

assert query["include_cell_borders"] == [expected]


# --- Retry behavior tests ---


Expand Down
2 changes: 1 addition & 1 deletion tools/gen_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# here, so the next refresher can tell what they are replacing.
SPEC_SOURCE_REPO="Zipstack/unstract-llm-whisperer"
SPEC_SOURCE_PATH="specs/llmwhisperer.json"
SPEC_SOURCE_REV="c4cc7f1426612a5489f40c5948bb198f89f19c9f"
SPEC_SOURCE_REV="9fe7085b44da6ca37e635fba3ab082c725ef8aef"

VENV="$REPO/.gen-venv"
# The generator shells out to ruff for its own post-processing. Without this it
Expand Down
Loading