mindee-lite 5.5.0 → 5.6.0

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.betterleaks.toml +15 -0
  3. data/.editorconfig +1 -1
  4. data/CHANGELOG.md +6 -0
  5. data/CONTRIBUTING.md +11 -51
  6. data/bin/v1/products.rb +0 -6
  7. data/lib/mindee/v1/client.rb +1 -74
  8. data/lib/mindee/v1/http.rb +0 -1
  9. data/lib/mindee/v1/product.rb +0 -3
  10. data/lib/mindee/v2/client.rb +45 -26
  11. data/lib/mindee/v2/http/mindee_api_v2.rb +34 -49
  12. data/lib/mindee/v2/product/classification/classification_classifier.rb +5 -4
  13. data/lib/mindee/v2/product/crop/crop_item.rb +5 -4
  14. data/lib/mindee/v2/product/split/split_range.rb +5 -4
  15. data/lib/mindee/v2/search/models/model_search_parameters.rb +8 -5
  16. data/lib/mindee/version.rb +1 -1
  17. data/mindee.gemspec +1 -2
  18. data/prek.toml +45 -0
  19. data/sig/mindee/v1/client.rbs +1 -15
  20. data/sig/mindee/v2/client.rbs +4 -0
  21. data/sig/mindee/v2/http/mindee_api_v2.rbs +7 -9
  22. data/sig/mindee/v2/product/classification/classification_classifier.rbs +1 -1
  23. data/sig/mindee/v2/product/crop/crop_item.rbs +1 -1
  24. data/sig/mindee/v2/product/split/split_range.rbs +1 -1
  25. metadata +5 -29
  26. data/.git-hooks/pre_commit/gitleaks.rb +0 -19
  27. data/.overcommit.yml +0 -46
  28. data/docs/code_samples/bank_account_details_v1.txt +0 -24
  29. data/docs/code_samples/barcode_reader_v1.txt +0 -24
  30. data/docs/code_samples/idcard_fr_v1.txt +0 -24
  31. data/docs/code_samples/workflow_execution.txt +0 -28
  32. data/lib/mindee/v1/http/workflow_endpoint.rb +0 -93
  33. data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1.rb +0 -47
  34. data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rb +0 -47
  35. data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rb +0 -38
  36. data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rb +0 -49
  37. data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rb +0 -49
  38. data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rb +0 -40
  39. data/lib/mindee/v1/product/fr/id_card/id_card_v1.rb +0 -49
  40. data/lib/mindee/v1/product/fr/id_card/id_card_v1_document.rb +0 -106
  41. data/lib/mindee/v1/product/fr/id_card/id_card_v1_page.rb +0 -57
  42. data/sig/mindee/v1/http/workflow_endpoint.rbs +0 -22
  43. data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1.rbs +0 -13
  44. data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rbs +0 -16
  45. data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rbs +0 -17
  46. data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rbs +0 -15
  47. data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rbs +0 -19
  48. data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rbs +0 -19
  49. data/sig/mindee/v1/product/fr/id_card/id_card_v1.rbs +0 -15
  50. data/sig/mindee/v1/product/fr/id_card/id_card_v1_document.rbs +0 -26
  51. data/sig/mindee/v1/product/fr/id_card/id_card_v1_page.rbs +0 -20
@@ -19,18 +19,6 @@ module Mindee
19
19
  def initialize: (params: Hash[String | Symbol, untyped]) -> void
20
20
  end
21
21
 
22
- class WorkflowOptions
23
- attr_accessor document_alias: (String?)
24
- attr_accessor priority: (Symbol?)
25
- attr_accessor full_text: bool
26
- attr_accessor rag: bool?
27
- attr_accessor public_url: (String?)
28
- attr_accessor page_options: (PageOptions)
29
- attr_accessor close_file: bool
30
-
31
- def initialize: (params: Hash[String | Symbol, untyped]) -> void
32
- end
33
-
34
22
  class Client
35
23
  @api_key: String?
36
24
 
@@ -48,8 +36,6 @@ module Mindee
48
36
 
49
37
  def enqueue_and_parse: (Input::Source::URLInputSource | Input::Source::LocalInputSource, singleton(V1::Parsing::Common::Inference), V1::HTTP::Endpoint, ParseOptions) -> V1::Parsing::Common::ApiResponse
50
38
 
51
- def execute_workflow: (Input::Source::URLInputSource | Input::Source::LocalInputSource, String, options: (Hash[String | Symbol, untyped] | WorkflowOptions)) -> V1::Parsing::Common::WorkflowResponse
52
-
53
39
  def load_prediction: (singleton(V1::Parsing::Common::Inference), Input::LocalResponse) -> V1::Parsing::Common::ApiResponse
54
40
 
55
41
  def source_from_path: (String, ?repair_pdf: bool) -> Input::Source::PathInputSource
@@ -68,7 +54,7 @@ module Mindee
68
54
 
69
55
  def normalize_parse_options: ((Hash[String | Symbol, untyped] | ParseOptions)) -> ParseOptions
70
56
 
71
- def process_pdf_if_required: (Input::Source::LocalInputSource, ParseOptions | WorkflowOptions) -> void
57
+ def process_pdf_if_required: (Input::Source::LocalInputSource, ParseOptions ) -> void
72
58
 
73
59
  def initialize_endpoint: (singleton(V1::Parsing::Common::Inference), ?endpoint_name: String, ?account_name: String, ?version: String) -> V1::HTTP::Endpoint
74
60
 
@@ -15,6 +15,10 @@ module Mindee
15
15
 
16
16
  def get_job: (String job_id) -> V2::Parsing::JobResponse
17
17
 
18
+ def get_result_by_url: [T] (HTTP::_ProductClass[T] product, String url) -> T
19
+
20
+ def get_job_by_url: (String url) -> V2::Parsing::JobResponse
21
+
18
22
  def enqueue: [T] (HTTP::_ProductClass[T] product, Input::Source::LocalInputSource | Input::Source::URLInputSource, Hash[String | Symbol, untyped] | ClientOptions::BaseProductParameters params) -> V2::Parsing::JobResponse
19
23
 
20
24
  def enqueue_and_get_result: [T] (HTTP::_ProductClass[T] product, Input::Source::LocalInputSource | Input::Source::URLInputSource, Hash[String | Symbol, untyped] | ClientOptions::BaseProductParameters params, ?Hash[String | Symbol, untyped] | Input::PollingOptions | nil) -> T
@@ -27,18 +27,20 @@ module Mindee
27
27
 
28
28
  def initialize: (?api_key: String?) -> void
29
29
 
30
- def req_get_result: [T] (_ProductClass[T] product, String resource) -> T
30
+ def req_get_result_by_id: [T] (_ProductClass[T] product, String inference_id) -> T
31
31
 
32
32
  def req_post_product_enqueue: (Input::Source::LocalInputSource | Input::Source::URLInputSource, ClientOptions::BaseProductParameters) -> V2::Parsing::JobResponse
33
33
 
34
- def req_get_job: (String) -> V2::Parsing::JobResponse
34
+ def req_get_job_by_id: (String job_id) -> V2::Parsing::JobResponse
35
+
36
+ def req_get_job_by_url: (String url) -> V2::Parsing::JobResponse
37
+
38
+ def req_get_result_by_url: [T] (_ProductClass[T] product, String url) -> T
35
39
 
36
40
  def process_response: (Net::HTTPResponse?) -> Hash[String | Symbol, untyped]
37
41
 
38
42
  def poll: (String) -> Net::HTTPResponse
39
43
 
40
- def result_req_get: [T] (String, _ProductClass[T] product) -> Net::HTTPResponse
41
-
42
44
  def enqueue: (Input::Source::LocalInputSource | Input::Source::URLInputSource, ClientOptions::BaseProductParameters) -> Net::HTTPResponse?
43
45
 
44
46
  def req_get_search: [T] (_SearchParameters[T] params) -> T
@@ -47,11 +49,7 @@ module Mindee
47
49
 
48
50
  def enqueue_form_options: (Array[Array[untyped]], V2::Product::Extraction::Params::ExtractionParameters) -> Array[Array[untyped]]
49
51
 
50
- def req_get_job_url: (String) -> V2::Parsing::JobResponse
51
-
52
- def req_get_result_url: [T] (_ResponseFactory[T] result_class, String url) -> T
53
-
54
- def uri?: (String) -> bool
52
+ def validate_https_url!: (String) -> void
55
53
  end
56
54
  end
57
55
  end
@@ -6,7 +6,7 @@ module Mindee
6
6
  module Classification
7
7
  class ClassificationClassifier
8
8
  attr_reader document_type: String
9
- attr_reader extraction_response: Extraction::ExtractionResponse
9
+ attr_reader extraction_response: Extraction::ExtractionResponse | nil
10
10
 
11
11
  def initialize: (Hash[String | Symbol, untyped]) -> void
12
12
  end
@@ -3,7 +3,7 @@ module Mindee
3
3
  module Product
4
4
  module Crop
5
5
  class CropItem
6
- attr_reader extraction_response: Extraction::ExtractionResponse
6
+ attr_reader extraction_response: Extraction::ExtractionResponse | nil
7
7
  attr_reader object_type: String
8
8
  attr_reader location: Parsing::Field::FieldLocation
9
9
 
@@ -3,7 +3,7 @@ module Mindee
3
3
  module Product
4
4
  module Split
5
5
  class SplitRange
6
- attr_reader extraction_response: Extraction::ExtractionResponse
6
+ attr_reader extraction_response: Extraction::ExtractionResponse | nil
7
7
  attr_reader page_range: Array[Integer]
8
8
  attr_reader document_type: String
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mindee-lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.0
4
+ version: 5.6.0
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-09-30 00:00:00.000000000 Z
11
+ date: 2026-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -57,17 +57,16 @@ description: Quickly and easily connect to Mindee's API services using Ruby. Thi
57
57
  email:
58
58
  - opensource@mindee.co
59
59
  executables:
60
- - console
61
60
  - mindee.rb
61
+ - console
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
+ - ".betterleaks.toml"
65
66
  - ".editorconfig"
66
- - ".git-hooks/pre_commit/gitleaks.rb"
67
67
  - ".gitattributes"
68
68
  - ".gitignore"
69
69
  - ".gitmodules"
70
- - ".overcommit.yml"
71
70
  - ".rubocop.yml"
72
71
  - ".yardopts"
73
72
  - CHANGELOG.md
@@ -86,10 +85,8 @@ files:
86
85
  - bin/v2/parser.rb
87
86
  - bin/v2/products.rb
88
87
  - bin/v2/search_commands.rb
89
- - docs/code_samples/bank_account_details_v1.txt
90
88
  - docs/code_samples/bank_account_details_v2.txt
91
89
  - docs/code_samples/bank_statement_fr_v2_async.txt
92
- - docs/code_samples/barcode_reader_v1.txt
93
90
  - docs/code_samples/cropper_v1.txt
94
91
  - docs/code_samples/default.txt
95
92
  - docs/code_samples/default_async.txt
@@ -97,7 +94,6 @@ files:
97
94
  - docs/code_samples/expense_receipts_v5_async.txt
98
95
  - docs/code_samples/financial_document_v1.txt
99
96
  - docs/code_samples/financial_document_v1_async.txt
100
- - docs/code_samples/idcard_fr_v1.txt
101
97
  - docs/code_samples/idcard_fr_v2.txt
102
98
  - docs/code_samples/international_id_v2_async.txt
103
99
  - docs/code_samples/invoice_splitter_v1_async.txt
@@ -112,7 +108,6 @@ files:
112
108
  - docs/code_samples/v2_extraction_webhook.txt
113
109
  - docs/code_samples/v2_ocr.txt
114
110
  - docs/code_samples/v2_split.txt
115
- - docs/code_samples/workflow_execution.txt
116
111
  - docs/code_samples/workflow_polling.txt
117
112
  - examples/auto_invoice_splitter_extraction.rb
118
113
  - examples/auto_multi_receipts_detector_extraction.rb
@@ -168,7 +163,6 @@ files:
168
163
  - lib/mindee/v1/http.rb
169
164
  - lib/mindee/v1/http/.rubocop.yml
170
165
  - lib/mindee/v1/http/endpoint.rb
171
- - lib/mindee/v1/http/workflow_endpoint.rb
172
166
  - lib/mindee/v1/parsing.rb
173
167
  - lib/mindee/v1/parsing/common.rb
174
168
  - lib/mindee/v1/parsing/common/api_request.rb
@@ -212,9 +206,6 @@ files:
212
206
  - lib/mindee/v1/parsing/universal/universal_object_field.rb
213
207
  - lib/mindee/v1/product.rb
214
208
  - lib/mindee/v1/product/.rubocop.yml
215
- - lib/mindee/v1/product/barcode_reader/barcode_reader_v1.rb
216
- - lib/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rb
217
- - lib/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rb
218
209
  - lib/mindee/v1/product/cropper/cropper_v1.rb
219
210
  - lib/mindee/v1/product/cropper/cropper_v1_document.rb
220
211
  - lib/mindee/v1/product/cropper/cropper_v1_page.rb
@@ -223,9 +214,6 @@ files:
223
214
  - lib/mindee/v1/product/financial_document/financial_document_v1_line_item.rb
224
215
  - lib/mindee/v1/product/financial_document/financial_document_v1_line_items.rb
225
216
  - lib/mindee/v1/product/financial_document/financial_document_v1_page.rb
226
- - lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rb
227
- - lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rb
228
- - lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rb
229
217
  - lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v2.rb
230
218
  - lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_bban.rb
231
219
  - lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_document.rb
@@ -235,9 +223,6 @@ files:
235
223
  - lib/mindee/v1/product/fr/bank_statement/bank_statement_v2_page.rb
236
224
  - lib/mindee/v1/product/fr/bank_statement/bank_statement_v2_transaction.rb
237
225
  - lib/mindee/v1/product/fr/bank_statement/bank_statement_v2_transactions.rb
238
- - lib/mindee/v1/product/fr/id_card/id_card_v1.rb
239
- - lib/mindee/v1/product/fr/id_card/id_card_v1_document.rb
240
- - lib/mindee/v1/product/fr/id_card/id_card_v1_page.rb
241
226
  - lib/mindee/v1/product/fr/id_card/id_card_v2.rb
242
227
  - lib/mindee/v1/product/fr/id_card/id_card_v2_document.rb
243
228
  - lib/mindee/v1/product/fr/id_card/id_card_v2_page.rb
@@ -371,6 +356,7 @@ files:
371
356
  - lib/mindee/version.rb
372
357
  - mindee-lite.gemspec
373
358
  - mindee.gemspec
359
+ - prek.toml
374
360
  - sig/custom/marcel.rbs
375
361
  - sig/custom/mini_magick.rbs
376
362
  - sig/custom/net_http.rbs
@@ -414,7 +400,6 @@ files:
414
400
  - sig/mindee/v1/client.rbs
415
401
  - sig/mindee/v1/extraction/multi_receipts_extractor.rbs
416
402
  - sig/mindee/v1/http/endpoint.rbs
417
- - sig/mindee/v1/http/workflow_endpoint.rbs
418
403
  - sig/mindee/v1/parsing/common/api_request.rbs
419
404
  - sig/mindee/v1/parsing/common/api_response.rbs
420
405
  - sig/mindee/v1/parsing/common/document.rbs
@@ -450,9 +435,6 @@ files:
450
435
  - sig/mindee/v1/parsing/standard/tax_field.rbs
451
436
  - sig/mindee/v1/parsing/universal/universal_list_field.rbs
452
437
  - sig/mindee/v1/parsing/universal/universal_object_field.rbs
453
- - sig/mindee/v1/product/barcode_reader/barcode_reader_v1.rbs
454
- - sig/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rbs
455
- - sig/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rbs
456
438
  - sig/mindee/v1/product/cropper/cropper_v1.rbs
457
439
  - sig/mindee/v1/product/cropper/cropper_v1_document.rbs
458
440
  - sig/mindee/v1/product/cropper/cropper_v1_page.rbs
@@ -461,9 +443,6 @@ files:
461
443
  - sig/mindee/v1/product/financial_document/financial_document_v1_line_item.rbs
462
444
  - sig/mindee/v1/product/financial_document/financial_document_v1_line_items.rbs
463
445
  - sig/mindee/v1/product/financial_document/financial_document_v1_page.rbs
464
- - sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rbs
465
- - sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rbs
466
- - sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rbs
467
446
  - sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v2.rbs
468
447
  - sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_bban.rbs
469
448
  - sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v2_document.rbs
@@ -473,9 +452,6 @@ files:
473
452
  - sig/mindee/v1/product/fr/bank_statement/bank_statement_v2_page.rbs
474
453
  - sig/mindee/v1/product/fr/bank_statement/bank_statement_v2_transaction.rbs
475
454
  - sig/mindee/v1/product/fr/bank_statement/bank_statement_v2_transactions.rbs
476
- - sig/mindee/v1/product/fr/id_card/id_card_v1.rbs
477
- - sig/mindee/v1/product/fr/id_card/id_card_v1_document.rbs
478
- - sig/mindee/v1/product/fr/id_card/id_card_v1_page.rbs
479
455
  - sig/mindee/v1/product/fr/id_card/id_card_v2.rbs
480
456
  - sig/mindee/v1/product/fr/id_card/id_card_v2_document.rbs
481
457
  - sig/mindee/v1/product/fr/id_card/id_card_v2_page.rbs
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Overcommit
4
- module Hook
5
- module PreCommit
6
- # Local script to run gitleaks
7
- class Gitleaks < Base
8
- # Runs the command.
9
- def run
10
- result = execute(['gitleaks', 'git', '--staged', '-v', '.'])
11
-
12
- return :pass if result.success?
13
-
14
- [:fail, result.stdout + result.stderr]
15
- end
16
- end
17
- end
18
- end
19
- end
data/.overcommit.yml DELETED
@@ -1,46 +0,0 @@
1
- PreCommit:
2
- MergeConflicts:
3
- enabled: true
4
-
5
- YamlSyntax:
6
- enabled: true
7
-
8
- TrailingWhitespace:
9
- enabled: true
10
-
11
- FileSize:
12
- enabled: true
13
- byte_limit: 1048576
14
-
15
- RuboCop:
16
- enabled: true
17
- required_executable: 'bundle'
18
- command: ['bundle', 'exec', 'rubocop', '--force-exclusion', '--no-server']
19
-
20
- CustomScript:
21
- enabled: true
22
- description: 'Run Steep type checking'
23
- required_executable: 'bundle'
24
- command: ['bundle', 'exec', 'steep', 'check']
25
-
26
- Gitleaks:
27
- enabled: true
28
- required_executable: 'gitleaks'
29
- CommitMsg:
30
- enabled: false
31
- CapitalizedSubject:
32
- enabled: false
33
- TextWidth:
34
- enabled: false
35
- TrailingPeriod:
36
- enabled: false
37
- SingleLineSubject:
38
- enabled: false
39
- EmptyMessage:
40
- enabled: false
41
-
42
- PrePush:
43
- BundleAudit:
44
- enabled: true
45
- required_executable: 'bundle'
46
- command: ['sh', '-c', 'bundle exec bundle-audit check']
@@ -1,24 +0,0 @@
1
- #
2
- # Install the Ruby client library by running:
3
- # gem install mindee
4
- #
5
-
6
- require 'mindee'
7
-
8
- # Init a new client
9
- mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key')
10
-
11
- # Load a file from disk
12
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
13
-
14
- # Parse the file
15
- result = mindee_client.parse(
16
- input_source,
17
- Mindee::V1::Product::FR::BankAccountDetails::BankAccountDetailsV1
18
- )
19
-
20
- # Print a full summary of the parsed data in RST format
21
- puts result.document
22
-
23
- # Print the document-level parsed data
24
- # puts result.document.inference.prediction
@@ -1,24 +0,0 @@
1
- #
2
- # Install the Ruby client library by running:
3
- # gem install mindee
4
- #
5
-
6
- require 'mindee'
7
-
8
- # Init a new client
9
- mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key')
10
-
11
- # Load a file from disk
12
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
13
-
14
- # Parse the file
15
- result = mindee_client.parse(
16
- input_source,
17
- Mindee::V1::Product::BarcodeReader::BarcodeReaderV1
18
- )
19
-
20
- # Print a full summary of the parsed data in RST format
21
- puts result.document
22
-
23
- # Print the document-level parsed data
24
- # puts result.document.inference.prediction
@@ -1,24 +0,0 @@
1
- #
2
- # Install the Ruby client library by running:
3
- # gem install mindee
4
- #
5
-
6
- require 'mindee'
7
-
8
- # Init a new client
9
- mindee_client = Mindee::V1::Client.new(api_key: 'my-api-key')
10
-
11
- # Load a file from disk
12
- input_source = mindee_client.source_from_path('/path/to/the/file.ext')
13
-
14
- # Parse the file
15
- result = mindee_client.parse(
16
- input_source,
17
- Mindee::V1::Product::FR::IdCard::IdCardV1
18
- )
19
-
20
- # Print a full summary of the parsed data in RST format
21
- puts result.document
22
-
23
- # Print the document-level parsed data
24
- # puts result.document.inference.prediction
@@ -1,28 +0,0 @@
1
- #
2
- # Install the Ruby client library by running:
3
- # gem install mindee
4
- #
5
-
6
- require 'mindee'
7
-
8
- workflow_id = 'workflow-id'
9
-
10
- # Init a new client
11
- mindee_client = Mindee::V1::Client.new
12
-
13
- # Load a file from disk
14
- input_source = mindee_client.source_from_path('path/to/my/file.ext')
15
-
16
- # Send the file to the workflow
17
- result = mindee_client.execute_workflow(
18
- input_source,
19
- workflow_id,
20
- # options: { # Optionally, you can provide the following parameters:
21
- # document_alias: 'my-document-alias', # Potential alias for the document
22
- # priority: Mindee::V1::Parsing::Common::ExecutionPriority::LOW, # Priority of the execution
23
- # rag: true # Whether to enable Retrieval-Augmented Generation
24
- # }
25
- )
26
-
27
- # Print the execution's ID to make sure it worked
28
- puts result.execution.id
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'net/http'
5
- require_relative '../../http/http_error_handler'
6
-
7
- module Mindee
8
- module V1
9
- module HTTP
10
- # Handles the routing for workflow calls.
11
- class WorkflowEndpoint
12
- # @return [String]
13
- attr_reader :api_key
14
- # @return [Integer]
15
- attr_reader :request_timeout
16
- # @return [String]
17
- attr_reader :url
18
-
19
- def initialize(workflow_id, api_key: '')
20
- @request_timeout = ENV.fetch(REQUEST_TIMEOUT_ENV_NAME, TIMEOUT_DEFAULT).to_i
21
- @api_key = api_key.nil? || api_key.empty? ? ENV.fetch(API_KEY_ENV_NAME, API_KEY_DEFAULT) : api_key
22
- base_url = ENV.fetch(BASE_URL_ENV_NAME, BASE_URL_DEFAULT)
23
- @url = "#{base_url.chomp('/')}/workflows/#{workflow_id}/executions"
24
- end
25
-
26
- # Sends a document to the workflow.
27
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
28
- # @param opts [WorkflowOptions] Options to configure workflow execution behavior.
29
- # @return [Array]
30
- def execute_workflow(input_source, opts)
31
- check_api_key
32
- response = workflow_execution_req_post(input_source, opts)
33
- if response.nil?
34
- raise Mindee::Error::MindeeHTTPError.new(
35
- { code: 0, details: 'Server response was nil.', message: 'Unknown error.' }, @url, 0
36
- )
37
- end
38
-
39
- hashed_response = JSON.parse(response.body, object_class: Hash)
40
- return [hashed_response, response.body] if Mindee::HTTP::ResponseValidation.valid_async_response?(response)
41
-
42
- Mindee::HTTP::ResponseValidation.clean_request!(response)
43
- error = Mindee::HTTP::ErrorHandler.handle_error(@url_name, response)
44
- raise error
45
- end
46
-
47
- # @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
48
- # @param opts [WorkflowOptions] Options to configure workflow execution behavior.
49
- # @return [Net::HTTPResponse, nil]
50
- def workflow_execution_req_post(input_source, opts)
51
- uri = URI(@url)
52
- params = {} # : Hash[String | Symbol, untyped]
53
- params[:full_text_ocr] = 'true' if opts.full_text
54
- params[:rag] = 'true' if opts.rag
55
- uri.query = URI.encode_www_form(params) if params.any?
56
-
57
- headers = {
58
- 'Authorization' => "Token #{@api_key}",
59
- 'User-Agent' => USER_AGENT,
60
- }
61
- req = Net::HTTP::Post.new(uri, headers)
62
- form_data = [] # : Array[untyped]
63
- if input_source.is_a?(Mindee::Input::Source::URLInputSource)
64
- form_data.push ['document', input_source.url]
65
- else
66
- form_data.push ['document', *input_source.read_contents(close: opts.close_file)]
67
- end
68
- form_data.push ['alias', opts.document_alias] if opts.document_alias
69
- form_data.push ['public_url', opts.public_url] if opts.public_url
70
- form_data.push ['priority', opts.priority.to_s] if opts.priority
71
-
72
- req.set_form(form_data, 'multipart/form-data')
73
- req['Transfer-Encoding'] = 'chunked'
74
-
75
- response = nil
76
- Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: @request_timeout) do |http|
77
- response = http.request(req)
78
- end
79
- response
80
- end
81
-
82
- # Checks API key
83
- def check_api_key
84
- return unless @api_key.nil? || @api_key.empty?
85
-
86
- raise Error::MindeeConfigurationError, "Missing API key. Check your Client Configuration.\n" \
87
- "You can set this using the '#{HTTP::API_KEY_ENV_NAME}'" \
88
- 'environment variable.'
89
- end
90
- end
91
- end
92
- end
93
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../parsing'
4
- require_relative 'barcode_reader_v1_document'
5
- require_relative 'barcode_reader_v1_page'
6
-
7
- module Mindee
8
- module V1
9
- module Product
10
- # Barcode Reader module.
11
- module BarcodeReader
12
- # Barcode Reader API version 1 inference prediction.
13
- class BarcodeReaderV1 < Mindee::V1::Parsing::Common::Inference
14
- @endpoint_name = 'barcode_reader'
15
- @endpoint_version = '1'
16
- @has_async = false
17
- @has_sync = true
18
-
19
- # @param prediction [Hash]
20
- def initialize(prediction)
21
- super
22
- @prediction = BarcodeReaderV1Document.new(prediction['prediction'], nil)
23
- @pages = []
24
- prediction['pages'].each do |page|
25
- @pages.push(BarcodeReaderV1Page.new(page))
26
- end
27
- end
28
-
29
- class << self
30
- # Name of the endpoint for this product.
31
- # @return [String]
32
- attr_reader :endpoint_name
33
- # Version for this product.
34
- # @return [String]
35
- attr_reader :endpoint_version
36
- # Whether this product has access to an asynchronous endpoint.
37
- # @return [bool]
38
- attr_reader :has_async
39
- # Whether this product has access to synchronous endpoint.
40
- # @return [bool]
41
- attr_reader :has_sync
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../parsing'
4
-
5
- module Mindee
6
- module V1
7
- module Product
8
- module BarcodeReader
9
- # Barcode Reader API version 1.0 document data.
10
- class BarcodeReaderV1Document < Mindee::V1::Parsing::Common::Prediction
11
- include Mindee::V1::Parsing::Standard
12
-
13
- # List of decoded 1D barcodes.
14
- # @return [Array<Mindee::V1::Parsing::Standard::StringField>]
15
- attr_reader :codes_1d
16
- # List of decoded 2D barcodes.
17
- # @return [Array<Mindee::V1::Parsing::Standard::StringField>]
18
- attr_reader :codes_2d
19
-
20
- # @param prediction [Hash]
21
- # @param page_id [Integer, nil]
22
- def initialize(prediction, page_id)
23
- super
24
- @codes_1d = [] # : Array[Parsing::Standard::StringField]
25
- prediction['codes_1d'].each do |item|
26
- @codes_1d.push(Parsing::Standard::StringField.new(item, page_id))
27
- end
28
- @codes_2d = [] # : Array[Parsing::Standard::StringField]
29
- prediction['codes_2d'].each do |item|
30
- @codes_2d.push(Parsing::Standard::StringField.new(item, page_id))
31
- end
32
- end
33
-
34
- # @return [String]
35
- def to_s
36
- codes_1d = @codes_1d.join("\n #{' ' * 13}")
37
- codes_2d = @codes_2d.join("\n #{' ' * 13}")
38
- out_str = String.new
39
- out_str << "\n:Barcodes 1D: #{codes_1d}".rstrip
40
- out_str << "\n:Barcodes 2D: #{codes_2d}".rstrip
41
- out_str[1..].to_s
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../parsing'
4
- require_relative 'barcode_reader_v1_document'
5
-
6
- module Mindee
7
- module V1
8
- module Product
9
- module BarcodeReader
10
- # Barcode Reader API version 1.0 page data.
11
- class BarcodeReaderV1Page < Mindee::V1::Parsing::Common::Page
12
- # @param prediction [Hash]
13
- def initialize(prediction)
14
- super
15
- @prediction = if prediction['prediction'].empty?
16
- nil
17
- else
18
- BarcodeReaderV1PagePrediction.new(
19
- prediction['prediction'],
20
- prediction['id']
21
- )
22
- end
23
- end
24
- end
25
-
26
- # Barcode Reader V1 page prediction.
27
- class BarcodeReaderV1PagePrediction < BarcodeReaderV1Document
28
- # @return [String]
29
- def to_s
30
- out_str = String.new
31
- out_str << "\n#{super}"
32
- out_str
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end