Class: Mindee::V2::Product::Extraction::Params::ExtractionParameters

Inherits:
Input::BaseParameters show all
Defined in:
lib/mindee/v2/product/extraction/params/extraction_parameters.rb

Overview

Parameters accepted by the extraction v2 endpoint.

Instance Attribute Summary collapse

Attributes inherited from Input::BaseParameters

#close_file, #file_alias, #model_id, #polling_options, #webhook_ids

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Input::BaseParameters

load_from_hash, #slug, #validate_async_params

Constructor Details

#initialize(model_id, rag: nil, raw_text: nil, polygon: nil, confidence: nil, file_alias: nil, webhook_ids: nil, text_context: nil, polling_options: nil, close_file: true, data_schema: nil) ⇒ ExtractionParameters

rubocop:disable Metrics/ParameterLists

Parameters:

  • model_id (String)

    ID of the model

  • rag (Boolean, nil) (defaults to: nil)

    Whether to enable RAG.

  • raw_text (Boolean, nil) (defaults to: nil)

    Whether to enable rax text.

  • polygon (Boolean, nil) (defaults to: nil)

    Whether to enable polygons.

  • confidence (Boolean, nil) (defaults to: nil)

    Whether to enable confidence scores.

  • file_alias (String, nil) (defaults to: nil)

    File alias, if applicable.

  • webhook_ids (Array<String>, nil) (defaults to: nil)
  • text_context (String, nil) (defaults to: nil)
  • polling_options (Hash, nil) (defaults to: nil)
  • close_file (Boolean, nil) (defaults to: true)
  • data_schema (DataSchemaField, String, Hash nil) (defaults to: nil)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 52

def initialize(
  model_id,
  rag: nil,
  raw_text: nil,
  polygon: nil,
  confidence: nil,
  file_alias: nil,
  webhook_ids: nil,
  text_context: nil,
  polling_options: nil,
  close_file: true,
  data_schema: nil
)
  super(
    model_id,
    file_alias: file_alias,
    webhook_ids: webhook_ids,
    polling_options: polling_options,
    close_file: close_file
  )

  @rag = rag
  @raw_text = raw_text
  @polygon = polygon
  @confidence = confidence
  @text_context = text_context
  @data_schema = DataSchema.new(data_schema) unless data_schema.nil?
  # rubocop:enable Metrics/ParameterLists
end

Instance Attribute Details

#confidenceBoolean? (readonly)

Returns Boost the precision and accuracy of all extractions. Calculate confidence scores for all fields, and fill their confidence attribute.

Returns:

  • (Boolean, nil)

    Boost the precision and accuracy of all extractions. Calculate confidence scores for all fields, and fill their confidence attribute.



26
27
28
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 26

def confidence
  @confidence
end

#data_schemaDataSchemaField (readonly)

Returns:



33
34
35
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 33

def data_schema
  @data_schema
end

#polygonBoolean? (readonly)

Returns Calculate bounding box polygons for all fields, and fill their locations attribute.

Returns:

  • (Boolean, nil)

    Calculate bounding box polygons for all fields, and fill their locations attribute.



22
23
24
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 22

def polygon
  @polygon
end

#ragBoolean? (readonly)

Returns Enhance extraction accuracy with Retrieval-Augmented Generation.

Returns:

  • (Boolean, nil)

    Enhance extraction accuracy with Retrieval-Augmented Generation.



14
15
16
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 14

def rag
  @rag
end

#raw_textBoolean? (readonly)

Returns Extract the full text content from the document as strings, and fill the raw_text` attribute.

Returns:

  • (Boolean, nil)

    Extract the full text content from the document as strings, and fill the raw_text` attribute.



18
19
20
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 18

def raw_text
  @raw_text
end

#text_contextString? (readonly)

Returns Additional text context used by the model during inference. Not recommended, for specific use only.

Returns:

  • (String, nil)

    Additional text context used by the model during inference. Not recommended, for specific use only.



30
31
32
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 30

def text_context
  @text_context
end

Class Method Details

.from_hash(params: {}) ⇒ ExtractionParameters

Loads a prediction from a Hash.

Parameters:

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

    Parameters to provide as a hash.

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 101

def self.from_hash(params: {})
  rag = params.fetch(:rag, nil)
  raw_text = params.fetch(:raw_text, nil)
  polygon = params.fetch(:polygon, nil)
  confidence = params.fetch(:confidence, nil)
  base_params = load_from_hash(params: params)
  new_params = base_params.merge(rag: rag, raw_text: raw_text, polygon: polygon, confidence: confidence)
  model_id = new_params.fetch(:model_id)

  ExtractionParameters.new(
    model_id, rag: rag,
              raw_text: raw_text,
              polygon: polygon,
              confidence: confidence,
              file_alias: params.fetch(:file_alias, nil),
              webhook_ids: params.fetch(:webhook_ids, nil),
              close_file: params.fetch(:close_file, true)
  )
end

.slugString

Returns Slug for the endpoint.

Returns:

  • (String)

    Slug for the endpoint.



36
37
38
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 36

def self.slug
  'extraction'
end

Instance Method Details

#append_form_data(form_data) ⇒ Array

Appends inference-specific form data to the provided array.

Parameters:

  • form_data (Array)

    Array of form fields

Returns:

  • (Array)


85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/mindee/v2/product/extraction/params/extraction_parameters.rb', line 85

def append_form_data(form_data)
  new_form_data = super

  new_form_data.push(['rag', @rag.to_s]) unless @rag.nil?
  new_form_data.push(['raw_text', @raw_text.to_s]) unless @raw_text.nil?
  new_form_data.push(['polygon', @polygon.to_s]) unless @polygon.nil?
  new_form_data.push(['confidence', @confidence.to_s]) unless @confidence.nil?
  new_form_data.push(['text_context', @text_context]) if @text_context
  new_form_data.push(['data_schema', @data_schema.to_s]) if @data_schema

  new_form_data
end