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
3 changes: 3 additions & 0 deletions src/Http/MindeeApiV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ private function documentEnqueuePost(
if (isset($params->alias)) {
$postFields['alias'] = $params->alias;
}
if (isset($params->textContext)) {
$postFields['text_context'] = $params->textContext;
}

$url = $this->baseUrl . '/inferences/enqueue';
curl_setopt($ch, CURLOPT_URL, $url);
Expand Down
11 changes: 11 additions & 0 deletions src/Input/InferenceParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class InferenceParameters
*/
public array $webhooksIds;

/**
* @var string|null Additional text context used by the model during inference.
* Not recommended, for specific use only.
*/
public ?string $textContext;

/**
* @var PollingOptions Polling options.
*/
Expand All @@ -56,6 +62,7 @@ class InferenceParameters
* @param boolean|null $confidence Whether to calculate confidence scores for all fields.
* @param string|null $alias Optional file alias.
* @param array<string>|null $webhooksIds List of webhook IDs.
* @param string|null $textContext Additional text context used by the model during inference.
* @param PollingOptions|null $pollingOptions Polling options.
*/
public function __construct(
Expand All @@ -66,6 +73,7 @@ public function __construct(
?bool $confidence = null,
?string $alias = null,
?array $webhooksIds = null,
?string $textContext = null,
?PollingOptions $pollingOptions = null,
) {
$this->modelId = $modelId;
Expand All @@ -81,6 +89,9 @@ public function __construct(
if (isset($alias)) {
$this->alias = $alias;
}
if (isset($textContext)) {
$this->textContext = $textContext;
}
if (isset($webhooksIds)) {
$this->webhooksIds = $webhooksIds;
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/V2/ClientV2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testEnqueuePostAsync(): void
$mindeeClient = self::makeClientWithMockedApi($predictable);

$input = new PathInput(\TestingUtilities::getFileTypesDir() . '/pdf/blank_1.pdf');
$params = new InferenceParameters('dummy-model-id');
$params = new InferenceParameters('dummy-model-id', textContext: 'dummy text context');

$response = $mindeeClient->enqueueInference($input, $params);

Expand Down
7 changes: 4 additions & 3 deletions tests/V2/ClientV2TestFunctional.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testParseFileFilledSinglePageMustSucceed(): void
\TestingUtilities::getV1DataDir() . '/products/financial_document/default_sample.jpg'
);

$inferenceParams = new InferenceParameters($this->modelId, rag: false);
$inferenceParams = new InferenceParameters($this->modelId, rag: false, textContext: 'this is an invoice');

$response = $this->mindeeClient->enqueueAndGetInference($source, $inferenceParams);
$this->assertNotNull($response);
Expand Down Expand Up @@ -111,7 +111,7 @@ public function testUnknownModelMustThrowError(): void
{
$source = new PathInput(\TestingUtilities::getFileTypesDir() . '/pdf/multipage_cut-2.pdf');

$inferenceParams = new InferenceParameters('fc405e37-4ba4-4d03-aeba-533a8d1f0f21');
$inferenceParams = new InferenceParameters('fc405e37-4ba4-4d03-aeba-533a8d1f0f21', textContext: 'this is invalid');

try {
$this->mindeeClient->enqueueInference($source, $inferenceParams);
Expand Down Expand Up @@ -145,7 +145,8 @@ public function testInvalidWebhookIDsMustThrowError()
null,
null,
null,
['fc405e37-4ba4-4d03-aeba-533a8d1f0f21', 'fc405e37-4ba4-4d03-aeba-533a8d1f0f21']
['fc405e37-4ba4-4d03-aeba-533a8d1f0f21', 'fc405e37-4ba4-4d03-aeba-533a8d1f0f21'],
null
);

try {
Expand Down