mindee 5.1.0 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/mindee/dependencies.rb +5 -0
- data/lib/mindee/image/image_compressor.rb +1 -1
- data/lib/mindee/input/base_parameters.rb +8 -1
- data/lib/mindee/input/sources/local_input_source.rb +4 -2
- data/lib/mindee/v2/client.rb +11 -3
- data/lib/mindee/v2/parsing/search/model_webhook.rb +38 -0
- data/lib/mindee/v2/parsing/search/search_model.rb +7 -0
- data/lib/mindee/v2/parsing/search/search_models.rb +1 -0
- data/lib/mindee/v2/parsing/search/search_response.rb +2 -2
- data/lib/mindee/v2/parsing/search.rb +1 -0
- data/lib/mindee/v2/product/classification/params/classification_parameters.rb +1 -1
- data/lib/mindee/v2/product/crop/params/crop_parameters.rb +1 -1
- data/lib/mindee/v2/product/extraction/params/data_schema.rb +1 -1
- data/lib/mindee/v2/product/extraction/params/extraction_parameters.rb +1 -1
- data/lib/mindee/v2/product/ocr/params/ocr_parameters.rb +1 -1
- data/lib/mindee/v2/product/split/params/split_parameters.rb +1 -1
- data/lib/mindee/version.rb +1 -1
- data/sig/mindee/input/base_parameters.rbs +1 -0
- data/sig/mindee/v2/client.rbs +2 -2
- data/sig/mindee/v2/parsing/search/model_webhook.rbs +19 -0
- data/sig/mindee/v2/parsing/search/search_model.rbs +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: addb1d4afceb4816df637946d7d0028da0459681ae05ecf5ce9550f5a2329b2c
|
|
4
|
+
data.tar.gz: f495ddafda38ba5f5cf6c0e00e88a331a32264a297704a941136d61b660700a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e2784c6fb7c8a8cb98eb1bb6d191b451899fbd4c4a4ae985d8f7d0271b4aa2a97edc64a0b084a700d8769def4b0400cdab24393b3eb7b1f14726407d7f2c93b
|
|
7
|
+
data.tar.gz: 6718cc7f954306771effbc7e96236bd246ed7aaf34f6296278d55cc821e3d850e54ce03608c64d7d81cb05d4b4ed8cf4055e2d0c08ec4ec315c0dfc0d948a188
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Mindee Ruby API Library Changelog
|
|
2
2
|
|
|
3
|
+
## v5.2.1 - 2026-05-27
|
|
4
|
+
### Changes
|
|
5
|
+
* :recycle: add polling options as a dedicated parameter (#252)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## v5.2.0 - 2026-05-19
|
|
9
|
+
### Changes
|
|
10
|
+
* :sparkles: add webhook info to model searches
|
|
11
|
+
|
|
12
|
+
|
|
3
13
|
## v5.1.0 - 2026-05-13
|
|
4
14
|
### Changes
|
|
5
15
|
* :sparkles: Add support for extraction in crop, split, and classify products
|
data/lib/mindee/dependencies.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
module Mindee
|
|
4
4
|
# Centralized check for optional heavy dependencies
|
|
5
5
|
module Dependencies
|
|
6
|
+
# Checks the presence of dependencies.
|
|
6
7
|
def self.check_all_dependencies
|
|
7
8
|
require 'origami'
|
|
8
9
|
require 'mini_magick'
|
|
@@ -12,16 +13,20 @@ module Mindee
|
|
|
12
13
|
false
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
# Memoized check.
|
|
15
17
|
@all_deps_available = check_all_dependencies
|
|
16
18
|
|
|
19
|
+
# Checks whether all dependencies are available.
|
|
17
20
|
def self.all_deps_available?
|
|
18
21
|
check_all_dependencies
|
|
19
22
|
end
|
|
20
23
|
|
|
24
|
+
# Raises an error if dependencies are not available.
|
|
21
25
|
def self.require_all_deps!
|
|
22
26
|
raise LoadError, MINDEE_DEPENDENCIES_LOAD_ERROR unless all_deps_available?
|
|
23
27
|
end
|
|
24
28
|
|
|
29
|
+
# Error message to display when dependencies are not available.
|
|
25
30
|
MINDEE_DEPENDENCIES_LOAD_ERROR = 'Attempted to load Mindee PDF/Image tools without required dependencies. ' \
|
|
26
31
|
"If you need to process local files, please replace the 'mindee-lite' gem " \
|
|
27
32
|
"with the standard 'mindee' gem in your Gemfile."
|
|
@@ -9,7 +9,7 @@ module Mindee
|
|
|
9
9
|
# @param image [MiniMagick::Image, StringIO] Input image.
|
|
10
10
|
# @param quality [Integer, nil] Quality of the final file.
|
|
11
11
|
# @param max_width [Integer, nil] Maximum width. If not specified, the horizontal ratio will remain the same.
|
|
12
|
-
# @param max_height [Integer] Maximum height. If not specified, the vertical ratio will remain the same.
|
|
12
|
+
# @param max_height [Integer, nil] Maximum height. If not specified, the vertical ratio will remain the same.
|
|
13
13
|
# @return [StringIO]
|
|
14
14
|
def self.compress_image(image, quality: 85, max_width: nil, max_height: nil)
|
|
15
15
|
processed_image = ImageUtils.to_image(image)
|
|
@@ -22,7 +22,7 @@ module Mindee
|
|
|
22
22
|
# @param [String] model_id ID of the model
|
|
23
23
|
# @param [String, nil] file_alias File alias, if applicable.
|
|
24
24
|
# @param [Array<String>, nil] webhook_ids List of webhook IDs to propagate the API response to.
|
|
25
|
-
# @param [Hash, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
25
|
+
# @param [Hash, PollingOptions, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
26
26
|
# @param [Boolean, nil] close_file Whether to close the file after parsing.
|
|
27
27
|
def initialize(
|
|
28
28
|
model_id,
|
|
@@ -40,6 +40,13 @@ module Mindee
|
|
|
40
40
|
@close_file = close_file.nil? || close_file
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
# Sets polling options after normalizing hash inputs.
|
|
44
|
+
# @param [Hash, PollingOptions, nil] polling_options
|
|
45
|
+
# @return [PollingOptions]
|
|
46
|
+
def polling_options=(polling_options)
|
|
47
|
+
@polling_options = get_clean_polling_options(polling_options)
|
|
48
|
+
end
|
|
49
|
+
|
|
43
50
|
# @return [String] Slug for the endpoint.
|
|
44
51
|
def self.slug
|
|
45
52
|
if self == BaseParameters
|
|
@@ -83,12 +83,14 @@ module Mindee
|
|
|
83
83
|
# @return [StringIO] The fixed stream.
|
|
84
84
|
# @raise [Mindee::Error::MindeePDFError]
|
|
85
85
|
def self.fix_pdf(stream, maximum_offset: 500)
|
|
86
|
-
out_stream = StringIO.new
|
|
86
|
+
out_stream = StringIO.new(''.b)
|
|
87
87
|
stream.gets('%PDF-')
|
|
88
88
|
raise Error::MindeePDFError if stream.eof? || stream.pos > maximum_offset
|
|
89
89
|
|
|
90
90
|
stream.pos = stream.pos - 5
|
|
91
|
-
out_stream
|
|
91
|
+
out_stream.write(stream.read.to_s.b)
|
|
92
|
+
out_stream.rewind
|
|
93
|
+
out_stream
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
# Cuts a PDF file according to provided options.
|
data/lib/mindee/v2/client.rb
CHANGED
|
@@ -57,14 +57,16 @@ module Mindee
|
|
|
57
57
|
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
|
|
58
58
|
# The source of the input document (local file or URL).
|
|
59
59
|
# @param params [Hash, Input::BaseParameters] Parameters for the inference.
|
|
60
|
+
# @param polling_options [Hash, PollingOptions, nil] Parameters for polling.
|
|
60
61
|
# @return [Parsing::BaseResponse]
|
|
61
62
|
def enqueue_and_get_result(
|
|
62
63
|
product,
|
|
63
64
|
input_source,
|
|
64
|
-
params
|
|
65
|
+
params,
|
|
66
|
+
polling_options = nil
|
|
65
67
|
)
|
|
66
68
|
enqueue_response = enqueue(product, input_source, params)
|
|
67
|
-
normalized_params = normalize_parameters(product.params_type, params)
|
|
69
|
+
normalized_params = normalize_parameters(product.params_type, params, polling_options: polling_options)
|
|
68
70
|
normalized_params.validate_async_params
|
|
69
71
|
|
|
70
72
|
if enqueue_response.job.id.nil? || enqueue_response.job.id.empty?
|
|
@@ -121,8 +123,14 @@ module Mindee
|
|
|
121
123
|
|
|
122
124
|
# If needed, converts the parsing options provided as a hash into a proper BaseParameters subclass object.
|
|
123
125
|
# @param params [Hash, Class<BaseParameters>] Params.
|
|
126
|
+
# @param polling_options [Hash, PollingOptions, nil] Polling options.
|
|
124
127
|
# @return [BaseParameters]
|
|
125
|
-
def normalize_parameters(param_class, params)
|
|
128
|
+
def normalize_parameters(param_class, params, polling_options: nil)
|
|
129
|
+
if params.is_a?(Hash)
|
|
130
|
+
params[:polling_options] = polling_options if polling_options
|
|
131
|
+
elsif params.is_a?(Mindee::Input::BaseParameters) && !polling_options.nil?
|
|
132
|
+
params.polling_options = polling_options
|
|
133
|
+
end
|
|
126
134
|
return param_class.from_hash(params: params) if params.is_a?(Hash)
|
|
127
135
|
|
|
128
136
|
params
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Parsing
|
|
6
|
+
module Search
|
|
7
|
+
# Individual webhook information.
|
|
8
|
+
class ModelWebhook
|
|
9
|
+
# @return [String] ID of the webhook.
|
|
10
|
+
attr_reader :id
|
|
11
|
+
|
|
12
|
+
# @return [String] Name of the webhook.
|
|
13
|
+
attr_reader :name
|
|
14
|
+
|
|
15
|
+
# @return [String] URL of the webhook.
|
|
16
|
+
attr_reader :url
|
|
17
|
+
|
|
18
|
+
# @param payload [Hash] The parsed JSON payload mapping to the search model.
|
|
19
|
+
def initialize(payload)
|
|
20
|
+
@id = payload['id']
|
|
21
|
+
@name = payload['name']
|
|
22
|
+
@url = payload['url']
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# String representation of the model.
|
|
26
|
+
# @return [String]
|
|
27
|
+
def to_s
|
|
28
|
+
[
|
|
29
|
+
":Name: #{@name}",
|
|
30
|
+
":ID: #{@id}",
|
|
31
|
+
":URL: #{@url}",
|
|
32
|
+
].join("\n")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative 'model_webhook'
|
|
4
|
+
|
|
3
5
|
module Mindee
|
|
4
6
|
module V2
|
|
5
7
|
module Parsing
|
|
@@ -15,11 +17,15 @@ module Mindee
|
|
|
15
17
|
# @return [String] Type of the model.
|
|
16
18
|
attr_reader :model_type
|
|
17
19
|
|
|
20
|
+
# @return [Array<ModelWebhook>] List of webhooks associated with the model.
|
|
21
|
+
attr_reader :webhooks
|
|
22
|
+
|
|
18
23
|
# @param payload [Hash] The parsed JSON payload mapping to the search model.
|
|
19
24
|
def initialize(payload)
|
|
20
25
|
@id = payload['id']
|
|
21
26
|
@name = payload['name']
|
|
22
27
|
@model_type = payload['model_type']
|
|
28
|
+
@webhooks = (payload['webhooks'] || []).map { |w| ModelWebhook.new(w) }
|
|
23
29
|
end
|
|
24
30
|
|
|
25
31
|
# String representation of the model.
|
|
@@ -29,6 +35,7 @@ module Mindee
|
|
|
29
35
|
":Name: #{@name}",
|
|
30
36
|
":ID: #{@id}",
|
|
31
37
|
":Model Type: #{@model_type}",
|
|
38
|
+
":Webhooks: #{@webhooks.join("\n")}",
|
|
32
39
|
].join("\n")
|
|
33
40
|
end
|
|
34
41
|
end
|
|
@@ -16,7 +16,7 @@ module Mindee
|
|
|
16
16
|
# @param [String] model_id ID of the model
|
|
17
17
|
# @param [String, nil] file_alias File alias, if applicable.
|
|
18
18
|
# @param [Array<String>, nil] webhook_ids List of webhook IDs to propagate the API response to.
|
|
19
|
-
# @param [Hash, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
19
|
+
# @param [Hash, PollingOptions, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
20
20
|
# @param [Boolean, nil] close_file Whether to close the file after parsing.
|
|
21
21
|
def initialize(
|
|
22
22
|
model_id,
|
|
@@ -16,7 +16,7 @@ module Mindee
|
|
|
16
16
|
# @param [String] model_id ID of the model
|
|
17
17
|
# @param [String, nil] file_alias File alias, if applicable.
|
|
18
18
|
# @param [Array<String>, nil] webhook_ids List of webhook IDs to propagate the API response to.
|
|
19
|
-
# @param [Hash, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
19
|
+
# @param [Hash, PollingOptions, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
20
20
|
# @param [Boolean, nil] close_file Whether to close the file after parsing.
|
|
21
21
|
def initialize(
|
|
22
22
|
model_id,
|
|
@@ -13,7 +13,7 @@ module Mindee
|
|
|
13
13
|
# @return [Mindee::V2::Product::Extraction::Params::DataSchemaReplace]
|
|
14
14
|
attr_reader :replace
|
|
15
15
|
|
|
16
|
-
# @param data_schema [Hash, String]
|
|
16
|
+
# @param data_schema [Hash, DataSchema, String]
|
|
17
17
|
def initialize(data_schema)
|
|
18
18
|
case data_schema
|
|
19
19
|
when String
|
|
@@ -46,7 +46,7 @@ module Mindee
|
|
|
46
46
|
# @param [String, nil] file_alias File alias, if applicable.
|
|
47
47
|
# @param [Array<String>, nil] webhook_ids
|
|
48
48
|
# @param [String, nil] text_context
|
|
49
|
-
# @param [Hash, nil] polling_options
|
|
49
|
+
# @param [Hash, PollingOptions, nil] polling_options
|
|
50
50
|
# @param [Boolean, nil] close_file
|
|
51
51
|
# @param [DataSchemaField, String, Hash nil] data_schema
|
|
52
52
|
def initialize(
|
|
@@ -16,7 +16,7 @@ module Mindee
|
|
|
16
16
|
# @param [String] model_id ID of the model
|
|
17
17
|
# @param [String, nil] file_alias File alias, if applicable.
|
|
18
18
|
# @param [Array<String>, nil] webhook_ids List of webhook IDs to propagate the API response to.
|
|
19
|
-
# @param [Hash, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
19
|
+
# @param [Hash, PollingOptions, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
20
20
|
# @param [Boolean, nil] close_file Whether to close the file after parsing.
|
|
21
21
|
def initialize(
|
|
22
22
|
model_id,
|
|
@@ -17,7 +17,7 @@ module Mindee
|
|
|
17
17
|
# @param [String] model_id ID of the model
|
|
18
18
|
# @param [String, nil] file_alias File alias, if applicable.
|
|
19
19
|
# @param [Array<String>, nil] webhook_ids List of webhook IDs to propagate the API response to.
|
|
20
|
-
# @param [Hash, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
20
|
+
# @param [Hash, PollingOptions, nil] polling_options Options for polling. Set only if having timeout issues.
|
|
21
21
|
# @param [Boolean, nil] close_file Whether to close the file after parsing.
|
|
22
22
|
def initialize(
|
|
23
23
|
model_id,
|
data/lib/mindee/version.rb
CHANGED
data/sig/mindee/v2/client.rbs
CHANGED
|
@@ -17,13 +17,13 @@ module Mindee
|
|
|
17
17
|
|
|
18
18
|
def enqueue: [T] (HTTP::_ProductClass[T] product, Input::Source::LocalInputSource | Input::Source::URLInputSource, Hash[String | Symbol, untyped] | Input::BaseParameters params) -> V2::Parsing::JobResponse
|
|
19
19
|
|
|
20
|
-
def enqueue_and_get_result: [T] (HTTP::_ProductClass[T] product, Input::Source::LocalInputSource | Input::Source::URLInputSource, Hash[String | Symbol, untyped] | Input::BaseParameters params) -> T
|
|
20
|
+
def enqueue_and_get_result: [T] (HTTP::_ProductClass[T] product, Input::Source::LocalInputSource | Input::Source::URLInputSource, Hash[String | Symbol, untyped] | Input::BaseParameters params, ?Hash[String | Symbol, untyped] | Input::PollingOptions?) -> T
|
|
21
21
|
|
|
22
22
|
def search_models: (String?, String?) -> Mindee::V2::Parsing::Search::SearchResponse
|
|
23
23
|
|
|
24
24
|
def validate_async_params: (Integer | Float, Integer | Float, Integer) -> void
|
|
25
25
|
|
|
26
|
-
def normalize_parameters: (singleton(Input::BaseParameters) param_class, Hash[String | Symbol, untyped] | Input::BaseParameters params) -> Input::BaseParameters
|
|
26
|
+
def normalize_parameters: (singleton(Input::BaseParameters) param_class, Hash[String | Symbol, untyped] | Input::BaseParameters params, ?polling_options: Hash[String | Symbol, untyped] | Input::PollingOptions?) -> Input::BaseParameters
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# lib/mindee/v2/parsing/search/model_webhook.rb
|
|
2
|
+
|
|
3
|
+
module Mindee
|
|
4
|
+
module V2
|
|
5
|
+
module Parsing
|
|
6
|
+
module Search
|
|
7
|
+
class ModelWebhook
|
|
8
|
+
attr_reader id: String
|
|
9
|
+
attr_reader name: String
|
|
10
|
+
attr_reader url: String
|
|
11
|
+
|
|
12
|
+
def initialize: (Hash[String | Symbol, untyped]) -> void
|
|
13
|
+
|
|
14
|
+
def to_s: -> String
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mindee
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.1
|
|
4
|
+
version: 5.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mindee, SA
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -430,6 +430,7 @@ files:
|
|
|
430
430
|
- lib/mindee/v2/parsing/raw_text.rb
|
|
431
431
|
- lib/mindee/v2/parsing/raw_text_page.rb
|
|
432
432
|
- lib/mindee/v2/parsing/search.rb
|
|
433
|
+
- lib/mindee/v2/parsing/search/model_webhook.rb
|
|
433
434
|
- lib/mindee/v2/parsing/search/pagination_metadata.rb
|
|
434
435
|
- lib/mindee/v2/parsing/search/search_model.rb
|
|
435
436
|
- lib/mindee/v2/parsing/search/search_models.rb
|
|
@@ -648,6 +649,7 @@ files:
|
|
|
648
649
|
- sig/mindee/v2/parsing/rag_metadata.rbs
|
|
649
650
|
- sig/mindee/v2/parsing/raw_text.rbs
|
|
650
651
|
- sig/mindee/v2/parsing/raw_text_page.rbs
|
|
652
|
+
- sig/mindee/v2/parsing/search/model_webhook.rbs
|
|
651
653
|
- sig/mindee/v2/parsing/search/pagination_metadata.rbs
|
|
652
654
|
- sig/mindee/v2/parsing/search/search_model.rbs
|
|
653
655
|
- sig/mindee/v2/parsing/search/search_response.rbs
|