litellm/tests/test_litellm_rust/ocr
saruar-dev e4bc52a83d
feat(nace): add NDI document parse as an OCR provider (#52519)
* feat(nace): add NDI document parse as an OCR provider

Add a Rust OCR adapter for Nace Document Intelligence (NDI) Parse with
the models nace/parse-low, nace/parse-medium and nace/parse-high.

A public https link goes to Nace as a link. Any other document is
uploaded with a one-time grant, parsed, and deleted after the call.
The cost map bills each processed page at the price of the effort.

* fix(nace): clean the job error before the OCR response hooks see it

The copy of a Nace job that goes to the response hooks now has its
error code and message cleaned and the deployment API key masked. The
copy keeps the key order of the job. The password texts now say that
the logging callbacks mask it.

* fix(nace): accept include_image_base64 and never send it to Nace

Clients that use the Mistral OCR request shape send the top-level
include_image_base64 option. A host that passes every body field on
sent it to Nace, which refuses an unknown field with a 422. The option
is now accepted with any value and left out of the parse request, since
Nace returns images as links (output.include_images), not base64.

* fix(nace): map the pages option to Nace page_ranges

Clients that use the Mistral OCR request shape select pages with the
top-level pages option (0-based page indexes). The Python host dropped
it, so Nace parsed and billed the whole document, and a host that
passes every body field on sent it to Nace, which refuses it with a
422. The option is now sorted, deduplicated, shifted to 1-based pages
and merged into page_ranges runs. An empty list parses the whole
document. Values that are not non-negative integers, or pages together
with page_ranges, are refused with a 400 before the upload.

* test(nace): assert request headers without loops and drop a redundant doc line

* fix(nace): refuse include_image_base64 true unless drop_params is on

Nace returns images as links, never as base64, so a request asking for
base64 images now gets the unsupported-param 400 that other OCR
providers give for output they cannot return. drop_params drops it
instead, and false or null are still accepted and never sent, which
keeps Open WebUI's Mistral loader working

* fix(nace): refuse output.include_images unless drop_params is on

Nace returns image crops only as links that need the operator's Nace key and
stop working once cleanup deletes the job, so image requests now get the same
unsupported-param 400 as include_image_base64 and every job is deleted

* fix(nace): bill only the requested pages when Nace omits billed units

With page_ranges, the page count Nace reports covers the whole document, so a
job without units now bills the requested pages that exist in the document
instead of every page

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-24 05:50:07 +00:00
..
__init__.py
conftest.py test(rust-bridge): select native routes per test without LITELLM_RUST (#46620) 2026-10-15 09:12:08 -07:00
data.py test(rust-bridge): pin Messages and Responses callback contracts on the native path (#46443) 2026-10-14 17:07:20 -07:00
test_callbacks.py fix(logging)!: fire one CustomLogger failure hook per async call outside the async flag list (#47124) 2026-10-20 15:19:14 -07:00
test_dispatch.py refactor(rust-bridge): decide native routing in the catalog, drop the bypass predicates (#46750) 2026-10-20 15:06:24 -07:00
test_failures.py feat(ocr)!: support outputContentFormat=markdown for Azure Document Intelligence (#48926) 2026-10-28 20:38:23 -07:00
test_guardrails.py test(rust-bridge): pin Messages and Responses callback contracts on the native path (#46443) 2026-10-14 17:07:20 -07:00
test_lifecycle.py fix(messages): log native messages success once, after the proxy releases it (#50420) 2026-11-09 16:06:53 -08:00
test_passthrough.py refactor: expose core private helpers under public names (#44871) 2026-10-07 00:05:27 +00:00
test_requests.py feat(nace): add NDI document parse as an OCR provider (#52519) 2026-11-24 05:50:07 +00:00
test_settings.py fix(proxy): resolve admin oidc api_key references on batch cancel, fine-tuning listing, OCR, /v1/messages and cache prediction (#53678) 2026-11-23 10:11:10 -08:00