Skip to content

Commit ec65e1b

Browse files
✨ add support for new V2 products (#172)
1 parent 521024e commit ec65e1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2133
-254
lines changed

.github/workflows/_test-code-samples.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/_test-integrations.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ env:
1313
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
1414
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
1515
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
16+
MINDEE_V2_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID }}
1617
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
1718
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
19+
MINDEE_V2_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
20+
MINDEE_V2_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
21+
MINDEE_V2_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
22+
MINDEE_V2_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
1823

1924
jobs:
2025
integration-tests-ubuntu:
@@ -25,7 +30,7 @@ jobs:
2530
matrix:
2631
php-version:
2732
- 8.1
28-
- 8.4
33+
- 8.5
2934
runs-on: "ubuntu-latest"
3035
steps:
3136
- uses: actions/checkout@v4
@@ -60,7 +65,7 @@ jobs:
6065
# matrix:
6166
# php-version:
6267
# - 8.1
63-
# - 8.4
68+
# - 8.5
6469
# runs-on: "macos-latest"
6570
# steps:
6671
# - uses: actions/checkout@v4
@@ -91,7 +96,7 @@ jobs:
9196
matrix:
9297
php-version:
9398
- 8.1
94-
- 8.4
99+
- 8.5
95100
runs-on: "windows-latest"
96101
steps:
97102
- uses: actions/checkout@v4

.github/workflows/_test-smoke.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Smoke tests
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
env:
8+
MINDEE_ACCOUNT_SE_TESTS: ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }}
9+
MINDEE_ENDPOINT_SE_TESTS: ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}
10+
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
11+
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
12+
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
13+
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
14+
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
15+
MINDEE_V2_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
16+
MINDEE_V2_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
17+
MINDEE_V2_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
18+
MINDEE_V2_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
19+
20+
jobs:
21+
test:
22+
name: Run Smoke Tests
23+
timeout-minutes: 30
24+
strategy:
25+
max-parallel: 2
26+
matrix:
27+
php-version:
28+
- "8.1"
29+
- "8.5"
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
submodules: recursive
35+
36+
- name: Set up Php ${{ matrix.php-version }}
37+
uses: shivammathur/setup-php@v2
38+
with:
39+
php-version: ${{ matrix.php-version }}
40+
- uses: ramsey/composer-install@v2
41+
42+
- name: Tests V2 code samples
43+
run: |
44+
./tests/test_code_samples_v2.sh
45+
46+
- name: Tests V1 code samples
47+
run: |
48+
./tests/test_code_samples_v1.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}

.github/workflows/_test-units.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
- 8.2
1515
- 8.3
1616
- 8.4
17+
- 8.5
1718
runs-on: "ubuntu-latest"
1819
steps:
1920
- uses: actions/checkout@v4

.github/workflows/cron.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ on:
55
- cron: '42 0 * * *'
66

77
jobs:
8-
test-code-samples:
9-
uses: mindee/mindee-api-php/.github/workflows/_test-code-samples.yml@main
8+
smoke-test:
9+
uses: mindee/mindee-api-php/.github/workflows/_test-smoke.yml@main
1010
secrets: inherit

.github/workflows/pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: ./.github/workflows/_test-integrations.yml
2222
needs: test-units
2323
secrets: inherit
24-
test-code-samples:
25-
uses: ./.github/workflows/_test-code-samples.yml
24+
smoke-test:
25+
uses: ./.github/workflows/_test-smoke.yml
2626
needs: test-units
2727
secrets: inherit
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Mindee\ClientV2;
4+
use Mindee\V2\Product\Classification\Params\ClassificationParameters;
5+
use Mindee\V2\Product\Classification\ClassificationResponse;
6+
use Mindee\Input\PathInput;
7+
8+
$apiKey = "MY_API_KEY";
9+
$filePath = "/path/to/the/file.ext";
10+
$modelId = "MY_MODEL_ID";
11+
12+
// Init a new client
13+
$mindeeClient = new ClientV2($apiKey);
14+
15+
// Set classification parameters
16+
// Note: modelId is mandatory.
17+
$classificationParams = new ClassificationParameters(
18+
// ID of the model, required.
19+
$modelId,
20+
);
21+
22+
// Load a file from disk
23+
$inputSource = new PathInput($filePath);
24+
25+
// Upload the file
26+
$response = $mindeeClient->enqueueAndGetResult(
27+
ClassificationResponse::class,
28+
$inputSource,
29+
$classificationParams
30+
);
31+
32+
// Print a summary of the response
33+
echo strval($response->inference);
34+
35+
// Access the classification results
36+
$classification = $response->inference->result->classification;

docs/code_samples/v2_crop.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Mindee\ClientV2;
4+
use Mindee\V2\Product\Crop\Params\CropParameters;
5+
use Mindee\V2\Product\Crop\CropResponse;
6+
use Mindee\Input\PathInput;
7+
8+
$apiKey = "MY_API_KEY";
9+
$filePath = "/path/to/the/file.ext";
10+
$modelId = "MY_MODEL_ID";
11+
12+
// Init a new client
13+
$mindeeClient = new ClientV2($apiKey);
14+
15+
// Set crop parameters
16+
// Note: modelId is mandatory.
17+
$cropParams = new CropParameters(
18+
// ID of the model, required.
19+
$modelId,
20+
);
21+
22+
// Load a file from disk
23+
$inputSource = new PathInput($filePath);
24+
25+
// Upload the file
26+
$response = $mindeeClient->enqueueAndGetResult(
27+
CropResponse::class,
28+
$inputSource,
29+
$cropParams
30+
);
31+
32+
// Print a summary of the response
33+
echo strval($response->inference);
34+
35+
// Access the crop results
36+
$crops = $response->inference->result->crops;

docs/code_samples/default_v2.txt renamed to docs/code_samples/v2_extraction_polling.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ $response = $mindeeClient->enqueueAndGetInference(
4141

4242
// Print a summary of the response
4343
echo strval($response->inference);
44+
45+
// Access the extracted fields
46+
$fields = $response->inference->result->fields;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
use Mindee\ClientV2;
4+
use Mindee\Input\InferenceParameters;
5+
use Mindee\Input\PathInput;
6+
7+
$apiKey = "MY_API_KEY";
8+
$filePath = "/path/to/the/file.ext";
9+
$modelId = "MY_MODEL_ID";
10+
11+
// Init a new client
12+
$mindeeClient = new ClientV2($apiKey);
13+
14+
// Set inference parameters
15+
// Note: modelId is mandatory.
16+
$inferenceParams = new InferenceParameters(
17+
// ID of the model, required.
18+
$modelId,
19+
webhooksIds: ["MY_WEBHOOK_ID"],
20+
21+
// Options: set to `true` or `false` to override defaults
22+
23+
// Enhance extraction accuracy with Retrieval-Augmented Generation.
24+
rag: null,
25+
// Extract the full text content from the document as strings.
26+
rawText: null,
27+
// Calculate bounding box polygons for all fields.
28+
polygon: null,
29+
// Boost the precision and accuracy of all extractions.
30+
// Calculate confidence scores for all fields.
31+
confidence: null
32+
);
33+
34+
// Load a file from disk
35+
$inputSource = new PathInput($filePath);
36+
37+
// Upload the file
38+
$response = $mindeeClient->enqueue(
39+
$inputSource,
40+
$inferenceParams
41+
);
42+
43+
// Print the job ID
44+
echo $response->job->id;
45+
46+
// IMPORTANT: save a record of which job ID corresponds to which file.

0 commit comments

Comments
 (0)