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
33 changes: 0 additions & 33 deletions .github/workflows/_test-code-samples.yml

This file was deleted.

11 changes: 8 additions & 3 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ env:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
MINDEE_V2_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID }}
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
MINDEE_V2_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
MINDEE_V2_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
MINDEE_V2_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
MINDEE_V2_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}

jobs:
integration-tests-ubuntu:
Expand All @@ -25,7 +30,7 @@ jobs:
matrix:
php-version:
- 8.1
- 8.4
- 8.5
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -60,7 +65,7 @@ jobs:
# matrix:
# php-version:
# - 8.1
# - 8.4
# - 8.5
# runs-on: "macos-latest"
# steps:
# - uses: actions/checkout@v4
Expand Down Expand Up @@ -91,7 +96,7 @@ jobs:
matrix:
php-version:
- 8.1
- 8.4
- 8.5
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v4
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/_test-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Smoke tests

on:
workflow_call:
workflow_dispatch:

env:
MINDEE_ACCOUNT_SE_TESTS: ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }}
MINDEE_ENDPOINT_SE_TESTS: ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
MINDEE_V2_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
MINDEE_V2_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
MINDEE_V2_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
MINDEE_V2_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}

jobs:
test:
name: Run Smoke Tests
timeout-minutes: 30
strategy:
max-parallel: 2
matrix:
php-version:
- "8.1"
- "8.5"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Php ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- uses: ramsey/composer-install@v2

- name: Tests V2 code samples
run: |
./tests/test_code_samples_v2.sh

- name: Tests V1 code samples
run: |
./tests/test_code_samples_v1.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}
1 change: 1 addition & 0 deletions .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- 8.2
- 8.3
- 8.4
- 8.5
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ on:
- cron: '42 0 * * *'

jobs:
test-code-samples:
uses: mindee/mindee-api-php/.github/workflows/_test-code-samples.yml@main
smoke-test:
uses: mindee/mindee-api-php/.github/workflows/_test-smoke.yml@main
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: ./.github/workflows/_test-integrations.yml
needs: test-units
secrets: inherit
test-code-samples:
uses: ./.github/workflows/_test-code-samples.yml
smoke-test:
uses: ./.github/workflows/_test-smoke.yml
needs: test-units
secrets: inherit
36 changes: 36 additions & 0 deletions docs/code_samples/v2_classification.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Mindee\ClientV2;
use Mindee\V2\Product\Classification\Params\ClassificationParameters;
use Mindee\V2\Product\Classification\ClassificationResponse;
use Mindee\Input\PathInput;

$apiKey = "MY_API_KEY";
$filePath = "/path/to/the/file.ext";
$modelId = "MY_MODEL_ID";

// Init a new client
$mindeeClient = new ClientV2($apiKey);

// Set classification parameters
// Note: modelId is mandatory.
$classificationParams = new ClassificationParameters(
// ID of the model, required.
$modelId,
);

// Load a file from disk
$inputSource = new PathInput($filePath);

// Upload the file
$response = $mindeeClient->enqueueAndGetResult(
ClassificationResponse::class,
$inputSource,
$classificationParams
);

// Print a summary of the response
echo strval($response->inference);

// Access the classification results
$classification = $response->inference->result->classification;
36 changes: 36 additions & 0 deletions docs/code_samples/v2_crop.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Mindee\ClientV2;
use Mindee\V2\Product\Crop\Params\CropParameters;
use Mindee\V2\Product\Crop\CropResponse;
use Mindee\Input\PathInput;

$apiKey = "MY_API_KEY";
$filePath = "/path/to/the/file.ext";
$modelId = "MY_MODEL_ID";

// Init a new client
$mindeeClient = new ClientV2($apiKey);

// Set crop parameters
// Note: modelId is mandatory.
$cropParams = new CropParameters(
// ID of the model, required.
$modelId,
);

// Load a file from disk
$inputSource = new PathInput($filePath);

// Upload the file
$response = $mindeeClient->enqueueAndGetResult(
CropResponse::class,
$inputSource,
$cropParams
);

// Print a summary of the response
echo strval($response->inference);

// Access the crop results
$crops = $response->inference->result->crops;
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ $response = $mindeeClient->enqueueAndGetInference(

// Print a summary of the response
echo strval($response->inference);

// Access the extracted fields
$fields = $response->inference->result->fields;
46 changes: 46 additions & 0 deletions docs/code_samples/v2_extraction_webhook.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use Mindee\ClientV2;
use Mindee\Input\InferenceParameters;
use Mindee\Input\PathInput;

$apiKey = "MY_API_KEY";
$filePath = "/path/to/the/file.ext";
$modelId = "MY_MODEL_ID";

// Init a new client
$mindeeClient = new ClientV2($apiKey);

// Set inference parameters
// Note: modelId is mandatory.
$inferenceParams = new InferenceParameters(
// ID of the model, required.
$modelId,
webhooksIds: ["MY_WEBHOOK_ID"],

// Options: set to `true` or `false` to override defaults

// Enhance extraction accuracy with Retrieval-Augmented Generation.
rag: null,
// Extract the full text content from the document as strings.
rawText: null,
// Calculate bounding box polygons for all fields.
polygon: null,
// Boost the precision and accuracy of all extractions.
// Calculate confidence scores for all fields.
confidence: null
);

// Load a file from disk
$inputSource = new PathInput($filePath);

// Upload the file
$response = $mindeeClient->enqueue(
$inputSource,
$inferenceParams
);

// Print the job ID
echo $response->job->id;

// IMPORTANT: save a record of which job ID corresponds to which file.
36 changes: 36 additions & 0 deletions docs/code_samples/v2_ocr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Mindee\ClientV2;
use Mindee\V2\Product\Ocr\Params\OcrParameters;
use Mindee\V2\Product\Ocr\OcrResponse;
use Mindee\Input\PathInput;

$apiKey = "MY_API_KEY";
$filePath = "/path/to/the/file.ext";
$modelId = "MY_MODEL_ID";

// Init a new client
$mindeeClient = new ClientV2($apiKey);

// Set ocr parameters
// Note: modelId is mandatory.
$ocrParams = new OcrParameters(
// ID of the model, required.
$modelId,
);

// Load a file from disk
$inputSource = new PathInput($filePath);

// Upload the file
$response = $mindeeClient->enqueueAndGetResult(
OcrResponse::class,
$inputSource,
$ocrParams
);

// Print a summary of the response
echo strval($response->inference);

// Access the ocr results
$pages = $response->inference->result->pages;
36 changes: 36 additions & 0 deletions docs/code_samples/v2_split.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Mindee\ClientV2;
use Mindee\V2\Product\Split\Params\SplitParameters;
use Mindee\V2\Product\Split\SplitResponse;
use Mindee\Input\PathInput;

$apiKey = "MY_API_KEY";
$filePath = "/path/to/the/file.ext";
$modelId = "MY_MODEL_ID";

// Init a new client
$mindeeClient = new ClientV2($apiKey);

// Set split parameters
// Note: modelId is mandatory.
$splitParams = new SplitParameters(
// ID of the model, required.
$modelId,
);

// Load a file from disk
$inputSource = new PathInput($filePath);

// Upload the file
$response = $mindeeClient->enqueueAndGetResult(
SplitResponse::class,
$inputSource,
$splitParams
);

// Print a summary of the response
echo strval($response->inference);

// Access the split results
$splits = $response->inference->result->splits;
Loading
Loading