Method: Mindee::Client#enqueue

Defined in:
lib/mindee/client.rb

#enqueue(input_source, product_class, endpoint: nil, options: {}) ⇒ Mindee::Parsing::Common::ApiResponse

Enqueue a document for async parsing

Parameters:

  • input_source (Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource)

    The source of the input document (local file or URL).

  • product_class (Mindee::Inference)

    The class of the product.

  • options (Hash) (defaults to: {})

    A hash of options to configure the enqueue behavior. Possible keys:

    • :endpoint [HTTP::Endpoint, nil] Endpoint of the API. Doesn't need to be set in the case of OTS APIs.
    • :all_words [bool] Whether to extract all the words on each page. This performs a full OCR operation on the server and will increase response time.
    • :full_text [bool] Whether to include the full OCR text response in compatible APIs. This performs a full OCR operation on the server and may increase response time.
    • :close_file [bool] Whether to close() the file after parsing it. Set to false if you need to access the file after this operation.
    • :page_options [Hash, nil] Page cutting/merge options:
      • :page_indexes [Array] Zero-based list of page indexes.
      • :operation [Symbol] Operation to apply on the document, given the page_indexes specified:
        • :KEEP_ONLY - keep only the specified pages, and remove all others.
        • :REMOVE - remove the specified pages, and keep all others.
      • :on_min_pages [Integer] Apply the operation only if the document has at least this many pages.
    • :cropper [bool] Whether to include cropper results for each page. This performs a cropping operation on the server and will increase response time.
    • :rag [bool] Whether to enable Retrieval-Augmented Generation. Only works if a Workflow ID is provided.
    • :workflow_id [String, nil] ID of the workflow to use.
  • endpoint (Mindee::HTTP::Endpoint) (defaults to: nil)

    Endpoint of the API.

Returns:



194
195
196
197
198
199
200
201
202
203
204
# File 'lib/mindee/client.rb', line 194

def enqueue(input_source, product_class, endpoint: nil, options: {})
  opts = normalize_parse_options(options)
  endpoint ||= initialize_endpoint(product_class)
  logger.debug("Enqueueing document as '#{endpoint.url_root}'")

  prediction, raw_http = endpoint.predict_async(
    input_source,
    opts
  )
  Mindee::Parsing::Common::ApiResponse.new(product_class, prediction, raw_http.to_json)
end