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
2 changes: 2 additions & 0 deletions mindee/input/inference_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ class InferenceParameters:
"""Options for polling. Set only if having timeout issues."""
close_file: bool = True
"""Whether to close the file after parsing."""
text_context: Optional[str] = None
"""Additional text context used by the model during inference. Not recommended, for specific use only."""
2 changes: 2 additions & 0 deletions mindee/mindee_http/mindee_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def req_post_inference_enqueue(
data["webhook_ids"] = params.webhook_ids
if params.alias and len(params.alias):
data["alias"] = params.alias
if params.text_context and (params.text_context):
data["text_context"] = params.text_context

if isinstance(input_source, LocalInputSource):
files = {"file": input_source.read_contents(params.close_file)}
Expand Down
5 changes: 3 additions & 2 deletions tests/v2/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ def test_enqueue_and_parse_path_with_env_token(custom_base_url_client):
)
with pytest.raises(MindeeHTTPErrorV2):
custom_base_url_client.enqueue_and_get_inference(
input_doc, InferenceParameters("dummy-model")
input_doc,
InferenceParameters("dummy-model", text_context="ignore this message"),
)


Expand Down Expand Up @@ -176,7 +177,7 @@ def test_error_handling(custom_base_url_client):


@pytest.mark.v2
def test_enqueue(custom_base_url_client):
def test_queue_get(custom_base_url_client):
response = custom_base_url_client.get_job("12345678-1234-1234-1234-123456789ABC")
assert isinstance(response, JobResponse)
assert isinstance(response.job, Job)
Expand Down
5 changes: 4 additions & 1 deletion tests/v2/test_client_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def test_parse_file_filled_single_page_must_succeed(
polygon=None,
confidence=None,
alias="py_integration_filled_single",
text_context="this is an invoice.",
)

response: InferenceResponse = v2_client.enqueue_and_get_inference(
Expand Down Expand Up @@ -172,7 +173,9 @@ def test_invalid_uuid_must_throw_error(v2_client: ClientV2) -> None:
input_path: Path = FILE_TYPES_DIR / "pdf" / "blank_1.pdf"

input_source = PathInput(input_path)
params = InferenceParameters(model_id="INVALID MODEL ID")
params = InferenceParameters(
model_id="INVALID MODEL ID", text_context="ignore this message"
)

with pytest.raises(MindeeHTTPErrorV2) as exc_info:
v2_client.enqueue_inference(input_source, params)
Expand Down
Loading