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
22 changes: 20 additions & 2 deletions .github/workflows/_test-code-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ on:
workflow_call:
workflow_dispatch:

env:
MINDEE_ENDPOINT_SE_TESTS: ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}
MINDEE_ACCOUNT_SE_TESTS: ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }}
MINDEE_API_KEY_SE_TESTS: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_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_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}

jobs:
test:
name: Run Tests
Expand All @@ -28,8 +40,14 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Tests code samples
- name: Tests V1 code samples
env:
MINDEE_LOG_LEVEL: DEBUG
run: |
./spec/test_code_samples_v1.sh

- name: Tests V2 code samples
env:
MINDEE_LOG_LEVEL: DEBUG
run: |
./spec/test_code_samples.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }} ${{ secrets.MINDEE_API_KEY_SE_TESTS }} ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }} ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
./spec/test_code_samples_v2.sh
6 changes: 5 additions & 1 deletion .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- "macos-latest"
ruby:
- "3.0"
- "3.4"
- "4.0"
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -56,6 +56,10 @@ jobs:
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_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_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
MINDEE_LOG_LEVEL: DEBUG
run: |
bundle exec rake integration
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- "3.2"
- "3.3"
- "3.4"
- "4.0"
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
/test/version_tmp/
/tmp/
_test.rb
_test_v1.rb
_test_v2.rb
/vendor
/mindee-*/
local-test
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AllCops:
- 'tmp/**/*'
- '.git/**/*'
- 'bin/*'
- _test.rb
- _test*.rb
- local_test/*
- Steepfile

Expand Down
30 changes: 30 additions & 0 deletions docs/code_samples/v2_classification.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require 'mindee'
require 'mindee/v2/product'

input_path = '/path/to/the/file.ext'
api_key = 'MY_API_KEY'
model_id = 'MY_MODEL_ID'

# Init a new client
mindee_client = Mindee::ClientV2.new(api_key: api_key)

# Set inference parameters
classification_params = {
# ID of the model, required.
model_id: model_id,
}

# Load a file from disk
input_source = Mindee::Input::Source::PathInputSource.new(input_path)

# Send for processing
response = mindee_client.enqueue_and_get_result(
Mindee::V2::Product::Classification::Classification,
input_source,
classification_params
)

# Access the classification result
puts response.inference.result.classification
30 changes: 30 additions & 0 deletions docs/code_samples/v2_crop.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require 'mindee'
require 'mindee/v2/product'

input_path = '/path/to/the/file.ext'
api_key = 'MY_API_KEY'
model_id = 'MY_MODEL_ID'

# Init a new client
mindee_client = Mindee::ClientV2.new(api_key: api_key)

# Set inference parameters
crop_params = {
# ID of the model, required.
model_id: model_id,
}

# Load a file from disk
input_source = Mindee::Input::Source::PathInputSource.new(input_path)

# Send for processing
response = mindee_client.enqueue_and_get_result(
Mindee::V2::Product::Crop::Crop,
input_source,
crop_params
)

# Access the result crops
puts response.inference.result.crops
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'mindee'
require 'mindee/v2/product'

input_path = '/path/to/the/file.ext'
api_key = 'MY_API_KEY'
Expand All @@ -10,9 +11,9 @@ model_id = 'MY_MODEL_ID'
mindee_client = Mindee::ClientV2.new(api_key: api_key)

# Set inference parameters
inference_params = Mindee::Input::InferenceParameters.new(
inference_params = {
# ID of the model, required.
model_id,
model_id: model_id,

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

Expand All @@ -25,15 +26,16 @@ inference_params = Mindee::Input::InferenceParameters.new(
# Boost the precision and accuracy of all extractions.
# Calculate confidence scores for all fields.
confidence: nil
)
}

# Load a file from disk
input_source = Mindee::Input::Source::PathInputSource.new(input_path)

# Send for processing
response = mindee_client.enqueue_and_get_inference(
response = mindee_client.enqueue_and_get_result(
Mindee::V2::Product::Extraction::Extraction,
input_source,
inference_params # This parameter can also be provided as a Hash.
inference_params
)

# Print a brief summary of the parsed data
Expand Down
45 changes: 45 additions & 0 deletions docs/code_samples/v2_extraction_webhook.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: true

require 'mindee'
require 'mindee/v2/product'

input_path = '/path/to/the/file.ext'
api_key = 'MY_API_KEY'
model_id = 'MY_MODEL_ID'

# Init a new client
mindee_client = Mindee::ClientV2.new(api_key: api_key)

inference_params = {
# ID of the model, required.
model_id: model_id,
# Add any number of webhook IDs here.
webhook_ids: ['MY_WEBHOOK_ID'],

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

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

# Load a file from disk
input_source = Mindee::Input::Source::PathInputSource.new(input_path)

# Send for processing
response = mindee_client.enqueue(
Mindee::V2::Product::Extraction::Extraction,
input_source,
inference_params
)

# Print the job ID
job_id = response.job.id

puts job_id
30 changes: 30 additions & 0 deletions docs/code_samples/v2_ocr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require 'mindee'
require 'mindee/v2/product'

input_path = '/path/to/the/file.ext'
api_key = 'MY_API_KEY'
model_id = 'MY_MODEL_ID'

# Init a new client
mindee_client = Mindee::ClientV2.new(api_key: api_key)

# Set inference parameters
ocr_params = {
# ID of the model, required.
model_id: model_id,
}

# Load a file from disk
input_source = Mindee::Input::Source::PathInputSource.new(input_path)

# Send for processing
response = mindee_client.enqueue_and_get_result(
Mindee::V2::Product::Ocr::Ocr,
input_source,
ocr_params
)

# Access the result OCR pages
puts response.inference.result.pages
30 changes: 30 additions & 0 deletions docs/code_samples/v2_split.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

require 'mindee'
require 'mindee/v2/product'

input_path = '/path/to/the/file.ext'
api_key = 'MY_API_KEY'
model_id = 'MY_MODEL_ID'

# Init a new client
mindee_client = Mindee::ClientV2.new(api_key: api_key)

# Set inference parameters
split_params = {
# ID of the model, required.
model_id: model_id,
}

# Load a file from disk
input_source = Mindee::Input::Source::PathInputSource.new(input_path)

# Send for processing
response = mindee_client.enqueue_and_get_result(
Mindee::V2::Product::Split::Split,
input_source,
split_params
)

# Access the result splits
puts response.inference.result.splits
7 changes: 7 additions & 0 deletions lib/mindee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ module IND
module US
end
end

# V2-specific module.
module V2
# Product-specific module.
module Product
end
end
end

# Shorthand to call the logger from anywhere.
Expand Down
Loading