From 47532c3c7e1f4922bb1ae471565e42e722cd4988 Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Fri, 28 Nov 2025 12:13:56 +0100 Subject: [PATCH 1/4] :recycle: add missing text_context active option return param --- mindee/parsing/v2/inference_active_options.py | 7 +++++++ tests/data | 2 +- tests/v2/parsing/test_inference_response.py | 18 ++++++++++++++++++ tests/v2/test_client_integration.py | 7 +++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/mindee/parsing/v2/inference_active_options.py b/mindee/parsing/v2/inference_active_options.py index 6a2d4656..129b47e7 100644 --- a/mindee/parsing/v2/inference_active_options.py +++ b/mindee/parsing/v2/inference_active_options.py @@ -5,15 +5,22 @@ class InferenceActiveOptions: """Active options for the inference.""" raw_text: bool + """Whether raw text extraction is active or not.""" polygon: bool + """Whether polygon extraction is active or not.""" confidence: bool + """Whether confidence scores are active or not.""" rag: bool + """Whether RAG is active or not.""" + text_context: bool + """Whether text context is active or not.""" def __init__(self, raw_response: StringDict): self.raw_text = raw_response["raw_text"] self.polygon = raw_response["polygon"] self.confidence = raw_response["confidence"] self.rag = raw_response["rag"] + self.text_context = raw_response["text_context"] def __str__(self) -> str: return ( diff --git a/tests/data b/tests/data index 932b387e..f86f3eaf 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit 932b387e48d909202d7b69ccf9230531dee3f036 +Subproject commit f86f3eaf540f0babeb3d4f1a458d764856a2170b diff --git a/tests/v2/parsing/test_inference_response.py b/tests/v2/parsing/test_inference_response.py index 9a5f9b9d..f494bb48 100644 --- a/tests/v2/parsing/test_inference_response.py +++ b/tests/v2/parsing/test_inference_response.py @@ -5,6 +5,7 @@ import pytest from mindee import InferenceResponse +from mindee.parsing.v2 import InferenceActiveOptions from mindee.parsing.v2.field import FieldConfidence, ListField, ObjectField, SimpleField from mindee.parsing.v2.field.inference_fields import InferenceFields from mindee.parsing.v2.inference import Inference @@ -298,3 +299,20 @@ def test_field_locations_and_confidence() -> None: assert date_field.confidence > FieldConfidence.LOW assert date_field.confidence <= FieldConfidence.HIGH assert date_field.confidence < FieldConfidence.HIGH + + +@pytest.mark.v2 +def test_text_context_field_is_false() -> None: + json_sample, _ = _get_product_samples("financial_document", "complete") + inference_result = InferenceResponse(json_sample) + assert isinstance(inference_result.inference.active_options, InferenceActiveOptions) + assert inference_result.inference.active_options.text_context is False + + +@pytest.mark.v2 +def test_text_context_field_is_true() -> None: + with open(V2_DATA_DIR / "inference" / "text_context_enabled.json", "r") as file: + json_sample = json.load(file) + inference_result = InferenceResponse(json_sample) + assert isinstance(inference_result.inference.active_options, InferenceActiveOptions) + assert inference_result.inference.active_options.text_context is True diff --git a/tests/v2/test_client_integration.py b/tests/v2/test_client_integration.py index 3330f7fb..3203cebf 100644 --- a/tests/v2/test_client_integration.py +++ b/tests/v2/test_client_integration.py @@ -5,6 +5,7 @@ from mindee import ClientV2, InferenceParameters, PathInput, UrlInputSource from mindee.error.mindee_http_error_v2 import MindeeHTTPErrorV2 +from mindee.parsing.v2 import InferenceActiveOptions from mindee.parsing.v2.inference_response import InferenceResponse from tests.utils import FILE_TYPES_DIR, V2_PRODUCT_DATA_DIR @@ -59,11 +60,13 @@ def test_parse_file_empty_multiple_pages_must_succeed( assert response.inference.model is not None assert response.inference.model.id == findoc_model_id + assert isinstance(response.inference.active_options, InferenceActiveOptions) assert response.inference.active_options is not None assert response.inference.active_options.rag is False assert response.inference.active_options.raw_text is True assert response.inference.active_options.polygon is False assert response.inference.active_options.confidence is False + assert response.inference.active_options.text_context is False assert response.inference.result is not None @@ -103,11 +106,13 @@ def test_parse_file_empty_single_page_options_must_succeed( assert response.inference.file.name == "blank_1.pdf" assert response.inference.file.page_count == 1 + assert isinstance(response.inference.active_options, InferenceActiveOptions) assert response.inference.active_options is not None assert response.inference.active_options.rag is True assert response.inference.active_options.raw_text is True assert response.inference.active_options.polygon is True assert response.inference.active_options.confidence is True + assert response.inference.active_options.text_context is False assert response.inference.result is not None @@ -148,11 +153,13 @@ def test_parse_file_filled_single_page_must_succeed( assert response.inference.model is not None assert response.inference.model.id == findoc_model_id + assert isinstance(response.inference.active_options, InferenceActiveOptions) assert response.inference.active_options is not None assert response.inference.active_options.rag is False assert response.inference.active_options.raw_text is False assert response.inference.active_options.polygon is False assert response.inference.active_options.confidence is False + assert response.inference.active_options.text_context is True assert response.inference.result.raw_text is None From dd30f0920637bebaf47ad5181776f34898f2a02f Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Fri, 28 Nov 2025 15:08:21 +0100 Subject: [PATCH 2/4] fix docstrings --- mindee/parsing/v2/inference_active_options.py | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/mindee/parsing/v2/inference_active_options.py b/mindee/parsing/v2/inference_active_options.py index 129b47e7..2891173c 100644 --- a/mindee/parsing/v2/inference_active_options.py +++ b/mindee/parsing/v2/inference_active_options.py @@ -5,15 +5,30 @@ class InferenceActiveOptions: """Active options for the inference.""" raw_text: bool - """Whether raw text extraction is active or not.""" + """ + Whether the Raw Text feature was activated. + When this feature is activated, the raw text extracted from the document is returned in the result. + """ polygon: bool - """Whether polygon extraction is active or not.""" + """ + Whether the polygon feature was activated. + When this feature is activated, the bounding-box polygon(s) for each field is returned in the result. + """ confidence: bool - """Whether confidence scores are active or not.""" + """ + Whether the confidence feature was activated. + When this feature is activated, a confidence score for each field is returned in the result. + """ rag: bool - """Whether RAG is active or not.""" + """ + Whether the Retrieval-Augmented Generation feature was activated. + When this feature is activated, the RAG pipeline is used to increase result accuracy. + """ text_context: bool - """Whether text context is active or not.""" + """ + Whether the text context feature was activated. + When this feature is activated, the provided context is used to improve the accuracy of the inference. + """ def __init__(self, raw_response: StringDict): self.raw_text = raw_response["raw_text"] From ad5e9e860617abf46f01fef03c9c922b1ade63ac Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Mon, 1 Dec 2025 16:51:37 +0100 Subject: [PATCH 3/4] fix tests --- tests/v2/input/test_local_response.py | 2 +- tests/v2/test_client.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/v2/input/test_local_response.py b/tests/v2/input/test_local_response.py index 82654579..e86d7877 100644 --- a/tests/v2/input/test_local_response.py +++ b/tests/v2/input/test_local_response.py @@ -14,7 +14,7 @@ def file_path() -> Path: def _assert_local_response(local_response): fake_hmac_signing = "ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH" - signature = "b9c2dfc67c2ba457603dd9880d45f089ae79b95bf6389b4a4387ef255c924fe7" + signature = "b82a515c832fd2c4f4ce3a7e6f53c12e8d10e19223f6cf0e3a9809a7a3da26be" assert local_response._file is not None assert not local_response.is_valid_hmac_signature( diff --git a/tests/v2/test_client.py b/tests/v2/test_client.py index 7ae18db4..a8ce422f 100644 --- a/tests/v2/test_client.py +++ b/tests/v2/test_client.py @@ -100,8 +100,13 @@ def _fake_ok_get_inference(*args, **kwargs): return ClientV2("dummy") +@pytest.fixture +def env_no_key(monkeypatch): + monkeypatch.delenv("MINDEE_V2_API_KEY") + + @pytest.mark.v2 -def test_parse_path_without_token(): +def test_parse_path_without_token(env_no_key): with pytest.raises(MindeeApiV2Error): ClientV2() From cd7ce57160c3ac251539a70e4ada792f44025065 Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Mon, 1 Dec 2025 16:56:36 +0100 Subject: [PATCH 4/4] fix tests, again --- tests/v2/test_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/v2/test_client.py b/tests/v2/test_client.py index a8ce422f..15d4f583 100644 --- a/tests/v2/test_client.py +++ b/tests/v2/test_client.py @@ -1,4 +1,5 @@ import json +import os import pytest @@ -102,7 +103,8 @@ def _fake_ok_get_inference(*args, **kwargs): @pytest.fixture def env_no_key(monkeypatch): - monkeypatch.delenv("MINDEE_V2_API_KEY") + if os.getenv("MINDEE_V2_API_KEY"): + monkeypatch.delenv("MINDEE_V2_API_KEY") @pytest.mark.v2