mindee 5.4.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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/.betterleaks.toml +15 -0
  3. data/.editorconfig +1 -1
  4. data/CHANGELOG.md +14 -0
  5. data/CONTRIBUTING.md +88 -0
  6. data/bin/mindee.rb +4 -1
  7. data/bin/v1/products.rb +0 -6
  8. data/bin/v2/parser.rb +40 -45
  9. data/bin/v2/search_commands.rb +100 -0
  10. data/lib/mindee/v1/client.rb +1 -75
  11. data/lib/mindee/v1/http.rb +0 -1
  12. data/lib/mindee/v1/product.rb +0 -3
  13. data/lib/mindee/v2/client.rb +62 -36
  14. data/lib/mindee/v2/client_options/base_product_parameters.rb +162 -0
  15. data/lib/mindee/v2/client_options/base_search_parameters.rb +51 -0
  16. data/lib/mindee/v2/client_options.rb +4 -0
  17. data/lib/mindee/v2/http/mindee_api_v2.rb +59 -78
  18. data/lib/mindee/v2/parsing/search/base_search_response.rb +47 -0
  19. data/lib/mindee/v2/parsing/search/model_webhook.rb +3 -3
  20. data/lib/mindee/v2/parsing/search/pagination_metadata.rb +1 -1
  21. data/lib/mindee/v2/parsing/search/search_models.rb +2 -1
  22. data/lib/mindee/v2/parsing/search/search_rag_document.rb +60 -0
  23. data/lib/mindee/v2/parsing/search/search_rag_documents.rb +39 -0
  24. data/lib/mindee/v2/parsing/search/search_response.rb +2 -29
  25. data/lib/mindee/v2/parsing/search.rb +5 -1
  26. data/lib/mindee/v2/product/base_product.rb +2 -2
  27. data/lib/mindee/v2/product/classification/classification_classifier.rb +5 -5
  28. data/lib/mindee/v2/product/classification/params/classification_parameters.rb +1 -1
  29. data/lib/mindee/v2/product/crop/crop_item.rb +5 -5
  30. data/lib/mindee/v2/product/crop/params/crop_parameters.rb +1 -1
  31. data/lib/mindee/v2/product/extraction/params/extraction_parameters.rb +2 -2
  32. data/lib/mindee/v2/product/ocr/params/ocr_parameters.rb +1 -1
  33. data/lib/mindee/v2/product/split/params/split_parameters.rb +1 -1
  34. data/lib/mindee/v2/product/split/split_range.rb +5 -5
  35. data/lib/mindee/v2/search/models/model_search_parameters.rb +54 -0
  36. data/lib/mindee/v2/search/models/model_search_response.rb +28 -0
  37. data/lib/mindee/v2/search/rag_documents/rag_document_search_parameters.rb +52 -0
  38. data/lib/mindee/v2/search/rag_documents/rag_document_search_response.rb +28 -0
  39. data/lib/mindee/v2/search.rb +6 -0
  40. data/lib/mindee/v2.rb +2 -0
  41. data/lib/mindee/version.rb +1 -1
  42. data/mindee.gemspec +1 -1
  43. data/prek.toml +45 -0
  44. data/sig/custom/net_http.rbs +1 -1
  45. data/sig/mindee/v1/client.rbs +1 -15
  46. data/sig/mindee/v2/client.rbs +11 -4
  47. data/sig/mindee/v2/client_options/base_product_parameters.rbs +41 -0
  48. data/sig/mindee/v2/client_options/base_search_parameters.rbs +19 -0
  49. data/sig/mindee/v2/http/mindee_api_v2.rbs +19 -15
  50. data/sig/mindee/v2/parsing/search/base_search_response.rbs +19 -0
  51. data/sig/mindee/v2/parsing/search/search_rag_document.rbs +23 -0
  52. data/sig/mindee/v2/parsing/search/search_rag_documents.rbs +16 -0
  53. data/sig/mindee/v2/parsing/search/search_response.rbs +4 -9
  54. data/sig/mindee/v2/product/base_product.rbs +3 -3
  55. data/sig/mindee/v2/product/classification/classification_classifier.rbs +1 -1
  56. data/sig/mindee/v2/product/classification/params/classification_parameters/classification_parameters.rbs +1 -1
  57. data/sig/mindee/v2/product/crop/crop_item.rbs +1 -1
  58. data/sig/mindee/v2/product/crop/params/crop_parameters/crop_parameters.rbs +1 -1
  59. data/sig/mindee/v2/product/extraction/params/extraction_parameters.rbs +1 -1
  60. data/sig/mindee/v2/product/ocr/params/ocr_parameters/ocr_parameters.rbs +1 -1
  61. data/sig/mindee/v2/product/split/params/split_parameters/split_parameters.rbs +1 -1
  62. data/sig/mindee/v2/product/split/split_range.rbs +1 -1
  63. data/sig/mindee/v2/search/models/model_search_parameters.rbs +22 -0
  64. data/sig/mindee/v2/search/models/model_search_response.rbs +17 -0
  65. data/sig/mindee/v2/search/rag_documents/rag_document_search_parameters.rbs +22 -0
  66. data/sig/mindee/v2/search/rag_documents/rag_document_search_response.rbs +17 -0
  67. metadata +28 -32
  68. data/.pre-commit-config.yaml +0 -36
  69. data/docs/code_samples/bank_account_details_v1.txt +0 -24
  70. data/docs/code_samples/barcode_reader_v1.txt +0 -24
  71. data/docs/code_samples/idcard_fr_v1.txt +0 -24
  72. data/docs/code_samples/workflow_execution.txt +0 -28
  73. data/lib/mindee/input/base_parameters.rb +0 -156
  74. data/lib/mindee/v1/http/workflow_endpoint.rb +0 -93
  75. data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1.rb +0 -47
  76. data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rb +0 -47
  77. data/lib/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rb +0 -38
  78. data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rb +0 -49
  79. data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rb +0 -49
  80. data/lib/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rb +0 -40
  81. data/lib/mindee/v1/product/fr/id_card/id_card_v1.rb +0 -49
  82. data/lib/mindee/v1/product/fr/id_card/id_card_v1_document.rb +0 -106
  83. data/lib/mindee/v1/product/fr/id_card/id_card_v1_page.rb +0 -57
  84. data/sig/mindee/input/base_parameters.rbs +0 -36
  85. data/sig/mindee/v1/http/workflow_endpoint.rbs +0 -22
  86. data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1.rbs +0 -13
  87. data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1_document.rbs +0 -16
  88. data/sig/mindee/v1/product/barcode_reader/barcode_reader_v1_page.rbs +0 -17
  89. data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1.rbs +0 -15
  90. data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_document.rbs +0 -19
  91. data/sig/mindee/v1/product/fr/bank_account_details/bank_account_details_v1_page.rbs +0 -19
  92. data/sig/mindee/v1/product/fr/id_card/id_card_v1.rbs +0 -15
  93. data/sig/mindee/v1/product/fr/id_card/id_card_v1_document.rbs +0 -26
  94. data/sig/mindee/v1/product/fr/id_card/id_card_v1_page.rbs +0 -20
@@ -4,8 +4,9 @@ module Mindee
4
4
  module V2
5
5
  module Parsing
6
6
  module Search
7
- # Array of search models.
7
+ # List of search models.
8
8
  class SearchModels < Array
9
+ # @param prediction [Array<Hash>] The parsed JSON payload mapping to the search models.
9
10
  def initialize(prediction)
10
11
  super(prediction.map { |entry| SearchModel.new(entry) })
11
12
  end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+
5
+ module Mindee
6
+ module V2
7
+ module Parsing
8
+ module Search
9
+ # Individual RAG document information.
10
+ class SearchRAGDocument
11
+ # @return [String] Unique identifier of the RAG document.
12
+ attr_reader :id
13
+
14
+ # @return [String] Model identifier linked to the RAG document.
15
+ attr_reader :model_id
16
+
17
+ # @return [String] Original filename of the uploaded document.
18
+ attr_reader :filename
19
+
20
+ # @return [Time] Date and time of the document creation.
21
+ attr_reader :created_at
22
+
23
+ # @return [Integer] Number of times this document was used in an inference.
24
+ attr_reader :total_matches
25
+
26
+ # @return [Time, nil] Date and time of the latest matching inference, if any.
27
+ attr_reader :last_match_at
28
+
29
+ # @return [String] Current status of the RAG document.
30
+ attr_reader :status
31
+
32
+ # @param server_response [Hash] The parsed JSON payload mapping to the RAG document.
33
+ def initialize(server_response)
34
+ @id = server_response['id']
35
+ @model_id = server_response['model_id']
36
+ @filename = server_response['filename']
37
+ @created_at = Time.iso8601(server_response['created_at'])
38
+ @total_matches = server_response['total_matches']
39
+ @last_match_at = (Time.iso8601(server_response['last_match_at']) if server_response['last_match_at'])
40
+ @status = server_response['status']
41
+ end
42
+
43
+ # String representation of the RAG document.
44
+ # @return [String]
45
+ def to_s
46
+ [
47
+ ":ID: #{@id}",
48
+ ":Model ID: #{@model_id}",
49
+ ":Filename: #{@filename}",
50
+ ":Created At: #{@created_at}",
51
+ ":Total Matches: #{@total_matches}",
52
+ ":Last Match At: #{@last_match_at}",
53
+ ":Status: #{@status}",
54
+ ].join("\n")
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'search_rag_document'
4
+
5
+ module Mindee
6
+ module V2
7
+ module Parsing
8
+ module Search
9
+ # List of RAG documents.
10
+ class SearchRAGDocuments < Array
11
+ # @param raw_response [Array<Hash>] The parsed JSON payload mapping to the RAG documents.
12
+ def initialize(raw_response)
13
+ super(raw_response.map { |entry| SearchRAGDocument.new(entry) })
14
+ end
15
+
16
+ # Default string representation.
17
+ # @return [String]
18
+ def to_s
19
+ return "\n" if empty?
20
+
21
+ lines = flat_map do |rag_document|
22
+ [
23
+ "* :ID: #{rag_document.id}",
24
+ " :Model ID: #{rag_document.model_id}",
25
+ " :Filename: #{rag_document.filename}",
26
+ " :Created At: #{rag_document.created_at}",
27
+ " :Total Matches: #{rag_document.total_matches}",
28
+ " :Last Match At: #{rag_document.last_match_at}",
29
+ " :Status: #{rag_document.status}",
30
+ ]
31
+ end
32
+
33
+ "#{lines.join("\n")}\n"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -5,35 +5,8 @@ module Mindee
5
5
  module Parsing
6
6
  module Search
7
7
  # Models search response.
8
- class SearchResponse < CommonResponse
9
- # @return [Search::SearchModels] Parsed search payload.
10
- attr_reader :models
11
- # @return [Search::PaginationMetadata] Pagination metadata.
12
- attr_reader :pagination
13
- # @return [Search::PaginationMetadata] Pagination metadata.
14
- attr_reader :pagination_metadata
15
-
16
- def initialize(server_response)
17
- super
18
-
19
- @models = SearchModels.new(server_response['models'])
20
- @pagination = PaginationMetadata.new(server_response['pagination'])
21
- @pagination_metadata = @pagination
22
- end
23
-
24
- # String representation.
25
- # @return [String]
26
- def to_s
27
- [
28
- 'Models',
29
- '######',
30
- @models.to_s,
31
- 'Pagination Metadata',
32
- '###################',
33
- @pagination.to_s,
34
- '',
35
- ].join("\n")
36
- end
8
+ # @deprecated Use {Mindee::V2::Search::Models::ModelSearchResponse} instead.
9
+ class SearchResponse < Mindee::V2::Search::Models::ModelSearchResponse
37
10
  end
38
11
  end
39
12
  end
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'search/pagination_metadata'
4
+ require_relative 'search/model_webhook'
4
5
  require_relative 'search/search_model'
5
6
  require_relative 'search/search_models'
7
+ require_relative 'search/search_rag_document'
8
+ require_relative 'search/search_rag_documents'
9
+ require_relative 'search/base_search_response'
10
+ require_relative '../search/models/model_search_response'
6
11
  require_relative 'search/search_response'
7
- require_relative 'search/model_webhook'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../parsing/base_response'
4
- require_relative '../../input/base_parameters'
4
+ require_relative '../client_options/base_product_parameters'
5
5
 
6
6
  module Mindee
7
7
  module V2
@@ -11,7 +11,7 @@ module Mindee
11
11
  # @return [String] The slug of the endpoint used for this response
12
12
  @slug = ''
13
13
  # @return [Class<BaseParameters>] The class of the parameters used for this response
14
- @params_type = Mindee::Input::BaseParameters
14
+ @params_type = Mindee::V2::ClientOptions::BaseProductParameters
15
15
  # @return [Class<BaseResponse>] The class of the response used for this product
16
16
  @response_type = Mindee::V2::Parsing::BaseResponse
17
17
 
@@ -13,11 +13,11 @@ module Mindee
13
13
  # @param server_response [Hash] Hash representation of the JSON returned by the service.
14
14
  def initialize(server_response)
15
15
  @document_type = server_response['document_type']
16
- # rubocop:disable Style/GuardClause
17
- unless server_response['extraction_response'].nil?
18
- @extraction_response = V2::Product::Extraction::ExtractionResponse.new(server_response['extraction_response'])
19
- end
20
- # rubocop:enable Style/GuardClause
16
+ @extraction_response = if server_response['extraction_response'].nil?
17
+ nil
18
+ else
19
+ V2::Product::Extraction::ExtractionResponse.new(server_response['extraction_response'])
20
+ end
21
21
  end
22
22
 
23
23
  # @return [String] String representation.
@@ -7,7 +7,7 @@ module Mindee
7
7
  # Classification parameters.
8
8
  module Params
9
9
  # Parameters accepted by the classification utility v2 endpoint.
10
- class ClassificationParameters < Mindee::Input::BaseParameters
10
+ class ClassificationParameters < Mindee::V2::ClientOptions::BaseProductParameters
11
11
  # @return [String] Slug for the endpoint.
12
12
  def self.slug
13
13
  'classification'
@@ -16,11 +16,11 @@ module Mindee
16
16
  def initialize(server_response)
17
17
  @object_type = server_response['object_type']
18
18
  @location = Mindee::V2::Parsing::Field::FieldLocation.new(server_response['location'])
19
- # rubocop:disable Style/GuardClause
20
- unless server_response['extraction_response'].nil?
21
- @extraction_response = V2::Product::Extraction::ExtractionResponse.new(server_response['extraction_response'])
22
- end
23
- # rubocop:enable Style/GuardClause
19
+ @extraction_response = if server_response['extraction_response'].nil?
20
+ nil
21
+ else
22
+ V2::Product::Extraction::ExtractionResponse.new(server_response['extraction_response'])
23
+ end
24
24
  end
25
25
 
26
26
  # String representation.
@@ -7,7 +7,7 @@ module Mindee
7
7
  # Crop parameters.
8
8
  module Params
9
9
  # Parameters accepted by the crop utility v2 endpoint.
10
- class CropParameters < Mindee::Input::BaseParameters
10
+ class CropParameters < Mindee::V2::ClientOptions::BaseProductParameters
11
11
  # @return [String] Slug for the endpoint.
12
12
  def self.slug
13
13
  'crop'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../../../input/base_parameters'
3
+ require_relative '../../../client_options/base_product_parameters'
4
4
  require_relative 'data_schema'
5
5
 
6
6
  module Mindee
@@ -9,7 +9,7 @@ module Mindee
9
9
  module Extraction
10
10
  module Params
11
11
  # Parameters accepted by the extraction v2 endpoint.
12
- class ExtractionParameters < Mindee::Input::BaseParameters
12
+ class ExtractionParameters < Mindee::V2::ClientOptions::BaseProductParameters
13
13
  # @return [Boolean, nil] Enhance extraction accuracy with Retrieval-Augmented Generation.
14
14
  attr_reader :rag
15
15
 
@@ -7,7 +7,7 @@ module Mindee
7
7
  # OCR Parameters.
8
8
  module Params
9
9
  # Parameters accepted by the ocr utility v2 endpoint.
10
- class OCRParameters < Mindee::Input::BaseParameters
10
+ class OCRParameters < Mindee::V2::ClientOptions::BaseProductParameters
11
11
  # @return [String] Slug for the endpoint.
12
12
  def self.slug
13
13
  'ocr'
@@ -8,7 +8,7 @@ module Mindee
8
8
  # Split parameters.
9
9
  module Params
10
10
  # Parameters accepted by the split utility v2 endpoint.
11
- class SplitParameters < Mindee::Input::BaseParameters
11
+ class SplitParameters < Mindee::V2::ClientOptions::BaseProductParameters
12
12
  # @return [String] Slug for the endpoint.
13
13
  def self.slug
14
14
  'split'
@@ -17,11 +17,11 @@ module Mindee
17
17
  def initialize(server_response)
18
18
  @page_range = server_response['page_range']
19
19
  @document_type = server_response['document_type']
20
- # rubocop:disable Style/GuardClause
21
- unless server_response['extraction_response'].nil?
22
- @extraction_response = V2::Product::Extraction::ExtractionResponse.new(server_response['extraction_response'])
23
- end
24
- # rubocop:enable Style/GuardClause
20
+ @extraction_response = if server_response['extraction_response'].nil?
21
+ nil
22
+ else
23
+ V2::Product::Extraction::ExtractionResponse.new(server_response['extraction_response'])
24
+ end
25
25
  end
26
26
 
27
27
  # String representation.
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mindee
4
+ module V2
5
+ module Search
6
+ module Models
7
+ # Search for models within the organization linked to the API key.
8
+ # All search filters are optional.
9
+ # If no search filters are given, all models belonging to the organization are returned.
10
+ # Results are paginated.
11
+ class ModelSearchParameters < Mindee::V2::ClientOptions::BaseSearchParameters
12
+ # @return [String, nil] Filter models by partial name match, case-insensitive.
13
+ attr_reader :name
14
+
15
+ # @return [String, nil] Filter by an exact model type.
16
+ attr_reader :model_type
17
+
18
+ # @param name [String, nil] Filter models by partial name match, case-insensitive.
19
+ # @param model_type [String, nil] Filter by an exact model type.
20
+ # @param page [Integer, nil] 1-based page index.
21
+ # @param per_page [Integer, nil] Number of items per page.
22
+ def initialize(name: nil, model_type: nil, page: nil, per_page: nil)
23
+ super(page: page, per_page: per_page)
24
+ @name = name
25
+ @model_type = model_type
26
+ end
27
+
28
+ # @return [String] Slug of searchable resources.
29
+ def self.slug
30
+ 'models'
31
+ end
32
+
33
+ # @return [Class<Mindee::V2::Search::Models::ModelSearchResponse>] Response class for the search.
34
+ def self.response_class
35
+ ModelSearchResponse
36
+ end
37
+
38
+ # Gets the request parameters for the search request.
39
+ # @return [Hash{String => String, Array<String>}]
40
+ def request_parameters
41
+ params = super
42
+
43
+ name = @name
44
+ model_type = @model_type
45
+ params['name'] = name unless name.nil?
46
+ params['model_type'] = model_type unless model_type.nil?
47
+
48
+ params
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mindee
4
+ module V2
5
+ module Search
6
+ module Models
7
+ # Models search response.
8
+ class ModelSearchResponse < Mindee::V2::Parsing::Search::BaseSearchResponse
9
+ # @return [Mindee::V2::Parsing::Search::SearchModels] Paginated list of matching models.
10
+ attr_reader :models
11
+
12
+ # @param raw_response [Hash] The parsed JSON payload from the API.
13
+ def initialize(raw_response)
14
+ super
15
+
16
+ @models = Mindee::V2::Parsing::Search::SearchModels.new(raw_response['models'])
17
+ end
18
+
19
+ # Lines composing the response-specific body (header + items).
20
+ # @return [Array<String>]
21
+ def body_lines
22
+ ['Models', '######', @models.to_s]
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mindee
4
+ module V2
5
+ module Search
6
+ module RAGDocuments
7
+ # Search parameters for RAG Documents.
8
+ class RAGDocumentSearchParameters < Mindee::V2::ClientOptions::BaseSearchParameters
9
+ # @return [String] Model identifier to search in.
10
+ attr_reader :model_id
11
+
12
+ # @return [String, nil] Case-insensitive substring search on filename.
13
+ attr_reader :filename
14
+
15
+ # @param model_id [String] Model identifier to search in.
16
+ # @param filename [String, nil] Case-insensitive substring search on filename.
17
+ # @param page [Integer, nil] 1-based page index.
18
+ # @param per_page [Integer, nil] Number of items per page.
19
+ def initialize(model_id:, filename: nil, page: nil, per_page: nil)
20
+ super(page: page, per_page: per_page)
21
+ raise Error::MindeeInputError, 'Model ID is required.' if model_id.nil? || model_id.empty?
22
+
23
+ @model_id = model_id
24
+ @filename = filename
25
+ end
26
+
27
+ # @return [String] Slug of searchable resources.
28
+ def self.slug
29
+ 'rag-documents'
30
+ end
31
+
32
+ # @return [Class<Mindee::V2::Search::RAGDocuments::RAGDocumentSearchResponse>] Response class for the search.
33
+ def self.response_class
34
+ RAGDocumentSearchResponse
35
+ end
36
+
37
+ # Gets the request parameters for the search request.
38
+ # @return [Hash{String => String, Array<String>}]
39
+ def request_parameters
40
+ params = super
41
+
42
+ params['model_id'] = @model_id
43
+ filename = @filename
44
+ params['filename'] = filename unless filename.nil?
45
+
46
+ params
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mindee
4
+ module V2
5
+ module Search
6
+ module RAGDocuments
7
+ # RAG Documents search response.
8
+ class RAGDocumentSearchResponse < Mindee::V2::Parsing::Search::BaseSearchResponse
9
+ # @return [Mindee::V2::Parsing::Search::SearchRAGDocuments] Paginated list of matching RAG documents.
10
+ attr_reader :rag_documents
11
+
12
+ # @param raw_response [Hash] The parsed JSON payload from the API.
13
+ def initialize(raw_response)
14
+ super
15
+
16
+ @rag_documents = Mindee::V2::Parsing::Search::SearchRAGDocuments.new(raw_response['rag_documents'])
17
+ end
18
+
19
+ # Lines composing the response-specific body (header + items).
20
+ # @return [Array<String>]
21
+ def body_lines
22
+ ['RAG Documents', '#############', @rag_documents.to_s]
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'search/models/model_search_response'
4
+ require_relative 'search/models/model_search_parameters'
5
+ require_relative 'search/rag_documents/rag_document_search_response'
6
+ require_relative 'search/rag_documents/rag_document_search_parameters'
data/lib/mindee/v2.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'v2/client_options'
3
4
  require_relative 'v2/client'
4
5
  require_relative 'v2/http'
5
6
  require_relative 'v2/file_operations' if Mindee::Dependencies.all_deps_available?
6
7
  require_relative 'v2/parsing'
8
+ require_relative 'v2/search'
7
9
  require_relative 'v2/product'
@@ -3,7 +3,7 @@
3
3
  # Mindee
4
4
  module Mindee
5
5
  # Current version.
6
- VERSION = '5.4.0'
6
+ VERSION = '5.6.0'
7
7
 
8
8
  # Finds and return the current platform.
9
9
  # @return [Symbol, Hash[String | Symbol, Regexp], Nil?]
data/mindee.gemspec CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
 
39
39
  spec.add_development_dependency 'bundle-audit', '~> 0.2.0'
40
40
  spec.add_development_dependency 'rbs', '~> 3.10'
41
- spec.add_development_dependency 'rubocop', '~> 1.86'
41
+ spec.add_development_dependency 'rubocop', '~> 1.91.0'
42
42
  spec.add_development_dependency 'steep', '~> 1.10'
43
43
  spec.add_development_dependency 'yard', '~> 0.9'
44
44
  end
data/prek.toml ADDED
@@ -0,0 +1,45 @@
1
+ # Configuration file for `prek`, a git hook framework written in Rust.
2
+ # See https://prek.j178.dev for more information.
3
+ #:schema https://www.schemastore.org/prek.json
4
+
5
+ [[repos]]
6
+ repo = "builtin"
7
+ hooks = [
8
+ { id = "trailing-whitespace" },
9
+ { id = "check-yaml" },
10
+ { id = "check-merge-conflict" },
11
+ { id = "check-added-large-files", args = ["--maxkb=1024"] },
12
+ ]
13
+
14
+ [[repos]]
15
+ repo = "https://github.com/betterleaks/betterleaks"
16
+ rev = "v1.9.0"
17
+ hooks = [
18
+ { id = "betterleaks" },
19
+ ]
20
+
21
+ [[repos]]
22
+ repo = "local"
23
+ hooks = [
24
+ {
25
+ id = "rubocop",
26
+ name = "RuboCop",
27
+ entry = "bundle exec rubocop --force-exclusion --no-server",
28
+ language = "system",
29
+ types = ["ruby"]
30
+ },
31
+ {
32
+ id = "steep-check",
33
+ name = "Run Steep type checking",
34
+ entry = "bundle exec steep check",
35
+ language = "system",
36
+ pass_filenames = false
37
+ },
38
+ {
39
+ id = "bundle-audit",
40
+ name = "bundle-audit",
41
+ entry = "bundle exec bundle-audit check",
42
+ language = "system",
43
+ pass_filenames = false
44
+ },
45
+ ]
@@ -6,7 +6,7 @@ module Net
6
6
  class BufferedIO
7
7
  end
8
8
  class HTTP
9
- def self.start: [T] (String?, Integer?, use_ssl: bool?, ?read_timeout: Integer) { (HTTP) -> T } -> T
9
+ def self.start: [T] (String?, Integer?, use_ssl: bool?, ?open_timeout: Integer, ?read_timeout: Integer) { (HTTP) -> T } -> T
10
10
 
11
11
  def request: (untyped) -> untyped
12
12
 
@@ -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,15 +15,22 @@ module Mindee
15
15
 
16
16
  def get_job: (String job_id) -> V2::Parsing::JobResponse
17
17
 
18
- def enqueue: [T] (HTTP::_ProductClass[T] product, Input::Source::LocalInputSource | Input::Source::URLInputSource, Hash[String | Symbol, untyped] | Input::BaseParameters params) -> V2::Parsing::JobResponse
18
+ def get_result_by_url: [T] (HTTP::_ProductClass[T] product, String url) -> T
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, ?Hash[String | Symbol, untyped] | Input::PollingOptions | nil) -> T
20
+ def get_job_by_url: (String url) -> V2::Parsing::JobResponse
21
21
 
22
- def search_models: (String?, String?) -> Mindee::V2::Parsing::Search::SearchResponse
22
+ def enqueue: [T] (HTTP::_ProductClass[T] product, Input::Source::LocalInputSource | Input::Source::URLInputSource, Hash[String | Symbol, untyped] | ClientOptions::BaseProductParameters params) -> V2::Parsing::JobResponse
23
+
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
25
+
26
+ def search: [T] (HTTP::_SearchParameters[T] params) -> T
27
+
28
+ # Deprecated: use `search` instead.
29
+ def search_models: (String?, String?) -> Mindee::V2::Search::Models::ModelSearchResponse
23
30
 
24
31
  def validate_async_params: (Integer | Float, Integer | Float, Integer) -> void
25
32
 
26
- def normalize_parameters: (singleton(Input::BaseParameters) param_class, Hash[String | Symbol, untyped] | Input::BaseParameters params, ?polling_options: Hash[String | Symbol, untyped] | Input::PollingOptions | nil) -> Input::BaseParameters
33
+ def normalize_parameters: (singleton(ClientOptions::BaseProductParameters) param_class, Hash[String | Symbol, untyped] | ClientOptions::BaseProductParameters params, ?polling_options: Hash[String | Symbol, untyped] | Input::PollingOptions | nil) -> ClientOptions::BaseProductParameters
27
34
  end
28
35
  end
29
36
  end