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
1 change: 1 addition & 0 deletions .github/workflows/_test-code-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}

jobs:
test_sample_code:
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ on:
workflow_call:
workflow_dispatch:

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_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}

jobs:
integration_tests:
name: Run Integration Tests
Expand Down Expand Up @@ -31,11 +42,5 @@ jobs:
cache: "maven"

- name: Verify with Maven
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_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 }}
run: |
mvn clean test-compile failsafe:integration-test failsafe:verify
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ src-lomboked

# test jshell file
_test.jsh
SimpleMindeeClient.java
SimpleMindeeClientV*

# Compiled class file
*.class
Expand Down
46 changes: 46 additions & 0 deletions docs/code_samples/v2_classification.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import com.mindee.MindeeClientV2;
import com.mindee.input.LocalInputSource;
import com.mindee.v2.product.classification.ClassificationClassifier;
import com.mindee.v2.product.classification.ClassificationResponse;
import com.mindee.v2.product.classification.ClassificationResult;
import com.mindee.v2.product.classification.params.ClassificationParameters;
import java.io.File;
import java.io.IOException;

public class SimpleMindeeClientV2 {

public static void main(String[] args)
throws IOException, InterruptedException
{
String apiKey = "MY_API_KEY";
String filePath = "/path/to/the/file.ext";
String modelId = "MY_MODEL_ID";

// Init a new client
MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);

// Set inference parameters
// Note: modelId is mandatory.
ClassificationParameters classificationParams = ClassificationParameters
// ID of the model, required.
.builder(modelId)
.build();

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

// Send for processing
ClassificationResponse response = mindeeClient.enqueueAndGetResult(
ClassificationResponse.class,
inputSource,
classificationParams
);

// Print a summary of the response
System.out.println(response.getInference().toString());

// Access the classification result
ClassificationResult result = response.getInference().getResult();
ClassificationClassifier classification = result.getClassification();
}
}
44 changes: 44 additions & 0 deletions docs/code_samples/v2_crop.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import com.mindee.MindeeClientV2;
import com.mindee.input.LocalInputSource;
import com.mindee.v2.product.crop.CropResponse;
import com.mindee.v2.product.crop.CropResult;
import com.mindee.v2.product.crop.params.CropParameters;
import java.io.File;
import java.io.IOException;

public class SimpleMindeeClientV2 {

public static void main(String[] args)
throws IOException, InterruptedException
{
String apiKey = "MY_API_KEY";
String filePath = "/path/to/the/file.ext";
String modelId = "MY_MODEL_ID";

// Init a new client
MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);

// Set inference parameters
// Note: modelId is mandatory.
CropParameters cropParams = CropParameters
// ID of the model, required.
.builder(modelId)
.build();

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

// Send for processing
CropResponse response = mindeeClient.enqueueAndGetResult(
CropResponse.class,
inputSource,
cropParams
);

// Print a summary of the response
System.out.println(response.getInference().toString());

// Access the crop results
CropResult result = response.getInference().getResult();
}
}
16 changes: 9 additions & 7 deletions docs/code_samples/v2_extraction.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import com.mindee.MindeeClientV2;
import com.mindee.InferenceParameters;
import com.mindee.input.LocalInputSource;
import com.mindee.parsing.v2.InferenceResponse;
import java.io.File;
import com.mindee.parsing.v2.InferenceResult;
import java.io.IOException;

public class SimpleMindeeClientV2 {
Expand All @@ -19,7 +19,7 @@ public class SimpleMindeeClientV2 {

// Set inference parameters
// Note: modelId is mandatory.
InferenceParameters inferenceParams = InferenceParameters
InferenceParameters extractionParams = InferenceParameters
// ID of the model, required.
.builder(modelId)

Expand All @@ -38,17 +38,19 @@ public class SimpleMindeeClientV2 {
.build();

// Load a file from disk
LocalInputSource inputSource = new LocalInputSource(
new File(filePath)
);
LocalInputSource inputSource = new LocalInputSource(filePath);

// Send for processing
InferenceResponse response = mindeeClient.enqueueAndGetInference(
InferenceResponse response = mindeeClient.enqueueAndGetResult(
InferenceResponse.class,
inputSource,
inferenceParams
extractionParams
);

// Print a summary of the response
System.out.println(response.getInference().toString());

// Access the result fields
InferenceResult result = response.getInference().getResult();
}
}
44 changes: 44 additions & 0 deletions docs/code_samples/v2_ocr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import com.mindee.MindeeClientV2;
import com.mindee.input.LocalInputSource;
import com.mindee.v2.product.ocr.OcrResponse;
import com.mindee.v2.product.ocr.OcrResult;
import com.mindee.v2.product.ocr.params.OcrParameters;
import java.io.File;
import java.io.IOException;

public class SimpleMindeeClientV2 {

public static void main(String[] args)
throws IOException, InterruptedException
{
String apiKey = "MY_API_KEY";
String filePath = "/path/to/the/file.ext";
String modelId = "MY_MODEL_ID";

// Init a new client
MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);

// Set inference parameters
// Note: modelId is mandatory.
OcrParameters ocrParams = OcrParameters
// ID of the model, required.
.builder(modelId)
.build();

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

// Send for processing
OcrResponse response = mindeeClient.enqueueAndGetResult(
OcrResponse.class,
inputSource,
ocrParams
);

// Print a summary of the response
System.out.println(response.getInference().toString());

// Access the result OCR pages
OcrResult result = response.getInference().getResult();
}
}
44 changes: 44 additions & 0 deletions docs/code_samples/v2_split.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import com.mindee.MindeeClientV2;
import com.mindee.input.LocalInputSource;
import com.mindee.v2.product.split.SplitResponse;
import com.mindee.v2.product.split.SplitResult;
import com.mindee.v2.product.split.params.SplitParameters;
import java.io.File;
import java.io.IOException;

public class SimpleMindeeClientV2 {

public static void main(String[] args)
throws IOException, InterruptedException
{
String apiKey = "MY_API_KEY";
String filePath = "/path/to/the/file.ext";
String modelId = "MY_MODEL_ID";

// Init a new client
MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);

// Set inference parameters
// Note: modelId is mandatory.
SplitParameters splitParams = SplitParameters
// ID of the model, required.
.builder(modelId)
.build();

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

// Send for processing
SplitResponse response = mindeeClient.enqueueAndGetResult(
SplitResponse.class,
inputSource,
splitParams
);

// Print a summary of the response
System.out.println(response.getInference().toString());

// Access the split result
SplitResult result = response.getInference().getResult();
}
}
32 changes: 5 additions & 27 deletions src/main/java/com/mindee/InferenceParameters.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mindee;

import com.mindee.v2.clientOptions.BaseParameters;
import java.util.Objects;
import com.mindee.v2.http.ProductInfo;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
Expand All @@ -11,6 +11,7 @@
*/
@Getter
@EqualsAndHashCode(callSuper = true)
@ProductInfo(slug = "extraction")
public final class InferenceParameters extends BaseParameters {
/**
* Enhance extraction accuracy with Retrieval-Augmented Generation.
Expand Down Expand Up @@ -96,21 +97,16 @@ public static Builder builder(String modelId) {
/**
* Fluent builder for {@link InferenceParameters}.
*/
public static final class Builder {

private final String modelId;
public static final class Builder extends BaseParameters.BaseBuilder<Builder> {
private Boolean rag = null;
private Boolean rawText = null;
private Boolean polygon = null;
private Boolean confidence = null;
private String alias;
private String[] webhookIds = new String[] {};
private String textContext;
private String dataSchema;
private AsyncPollingOptions pollingOptions = AsyncPollingOptions.builder().build();

private Builder(String modelId) {
this.modelId = Objects.requireNonNull(modelId, "modelId must not be null");
Builder(String modelId) {
super(modelId);
}

/** Enhance extraction accuracy with Retrieval-Augmented Generation. */
Expand Down Expand Up @@ -140,18 +136,6 @@ public Builder confidence(Boolean confidence) {
return this;
}

/** Set an alias for the uploaded document. */
public Builder alias(String alias) {
this.alias = alias;
return this;
}

/** Provide IDs of webhooks to forward the API response to. */
public Builder webhookIds(String[] webhookIds) {
this.webhookIds = webhookIds;
return this;
}

/** Provide additional text context used by the model during inference. */
public Builder textContext(String textContext) {
this.textContext = textContext;
Expand All @@ -164,12 +148,6 @@ public Builder dataSchema(String dataSchema) {
return this;
}

/** Set polling options. */
public Builder pollingOptions(AsyncPollingOptions pollingOptions) {
this.pollingOptions = pollingOptions;
return this;
}

/** Build an immutable {@link InferenceParameters} instance. */
public InferenceParameters build() {
return new InferenceParameters(
Expand Down
Loading
Loading