Class: OCI::GenerativeAiInference::Models::EmbedTextDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/generative_ai_inference/models/embed_text_details.rb

Overview

Details for the request to embed texts.

Constant Summary collapse

EMBEDDING_TYPES_ENUM =
[
  EMBEDDING_TYPES_FLOAT = 'float'.freeze,
  EMBEDDING_TYPES_INT8 = 'int8'.freeze,
  EMBEDDING_TYPES_UINT8 = 'uint8'.freeze,
  EMBEDDING_TYPES_BINARY = 'binary'.freeze,
  EMBEDDING_TYPES_UBINARY = 'ubinary'.freeze,
  EMBEDDING_TYPES_BASE64 = 'base64'.freeze
].freeze
TRUNCATE_ENUM =
[
  TRUNCATE_NONE = 'NONE'.freeze,
  TRUNCATE_START = 'START'.freeze,
  TRUNCATE_END = 'END'.freeze
].freeze
INPUT_TYPE_ENUM =
[
  INPUT_TYPE_SEARCH_DOCUMENT = 'SEARCH_DOCUMENT'.freeze,
  INPUT_TYPE_SEARCH_QUERY = 'SEARCH_QUERY'.freeze,
  INPUT_TYPE_CLASSIFICATION = 'CLASSIFICATION'.freeze,
  INPUT_TYPE_CLUSTERING = 'CLUSTERING'.freeze,
  INPUT_TYPE_IMAGE = 'IMAGE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ EmbedTextDetails

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 120

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.inputs = attributes[:'inputs'] if attributes[:'inputs']

  self.embed_contents = attributes[:'embedContents'] if attributes[:'embedContents']

  raise 'You cannot provide both :embedContents and :embed_contents' if attributes.key?(:'embedContents') && attributes.key?(:'embed_contents')

  self.embed_contents = attributes[:'embed_contents'] if attributes[:'embed_contents']

  self.serving_mode = attributes[:'servingMode'] if attributes[:'servingMode']

  raise 'You cannot provide both :servingMode and :serving_mode' if attributes.key?(:'servingMode') && attributes.key?(:'serving_mode')

  self.serving_mode = attributes[:'serving_mode'] if attributes[:'serving_mode']

  self.compartment_id = attributes[:'compartmentId'] if attributes[:'compartmentId']

  raise 'You cannot provide both :compartmentId and :compartment_id' if attributes.key?(:'compartmentId') && attributes.key?(:'compartment_id')

  self.compartment_id = attributes[:'compartment_id'] if attributes[:'compartment_id']

  self.is_echo = attributes[:'isEcho'] unless attributes[:'isEcho'].nil?
  self.is_echo = false if is_echo.nil? && !attributes.key?(:'isEcho') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :isEcho and :is_echo' if attributes.key?(:'isEcho') && attributes.key?(:'is_echo')

  self.is_echo = attributes[:'is_echo'] unless attributes[:'is_echo'].nil?
  self.is_echo = false if is_echo.nil? && !attributes.key?(:'isEcho') && !attributes.key?(:'is_echo') # rubocop:disable Style/StringLiterals

  self.embedding_types = attributes[:'embeddingTypes'] if attributes[:'embeddingTypes']

  raise 'You cannot provide both :embeddingTypes and :embedding_types' if attributes.key?(:'embeddingTypes') && attributes.key?(:'embedding_types')

  self.embedding_types = attributes[:'embedding_types'] if attributes[:'embedding_types']

  self.output_dimensions = attributes[:'outputDimensions'] if attributes[:'outputDimensions']

  raise 'You cannot provide both :outputDimensions and :output_dimensions' if attributes.key?(:'outputDimensions') && attributes.key?(:'output_dimensions')

  self.output_dimensions = attributes[:'output_dimensions'] if attributes[:'output_dimensions']

  self.truncate = attributes[:'truncate'] if attributes[:'truncate']
  self.truncate = "NONE" if truncate.nil? && !attributes.key?(:'truncate') # rubocop:disable Style/StringLiterals

  self.input_type = attributes[:'inputType'] if attributes[:'inputType']

  raise 'You cannot provide both :inputType and :input_type' if attributes.key?(:'inputType') && attributes.key?(:'input_type')

  self.input_type = attributes[:'input_type'] if attributes[:'input_type']
end

Instance Attribute Details

#compartment_idString

[Required] The OCID of compartment in which to call the Generative AI service to create text embeddings.

Returns:

  • (String)


49
50
51
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 49

def compartment_id
  @compartment_id
end

#embed_contentsArray<OCI::GenerativeAiInference::Models::EmbedContent>

An array of text/image inputs to be embedded. Supported for Embed v4 models.



41
42
43
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 41

def embed_contents
  @embed_contents
end

#embedding_typesArray<String>

Specifies the types of embeddings you want to get back. Supports list of enums. Supported values :float, int8, uint8, binary, ubinary, base64. If nothing is passed default will be considered as float.

Returns:

  • (Array<String>)


57
58
59
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 57

def embedding_types
  @embedding_types
end

#input_typeString

Specifies the input type.

Returns:

  • (String)


69
70
71
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 69

def input_type
  @input_type
end

#inputsArray<String>

Provide a list of strings or one base64 encoded image with input_type setting to IMAGE. If text embedding, each string can be words, a phrase, or a paragraph. The maximum length of each string entry in the list is 512 tokens.

Returns:

  • (Array<String>)


36
37
38
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 36

def inputs
  @inputs
end

#is_echoBOOLEAN

Whether or not to include the original inputs in the response. Results are index-based.

Returns:

  • (BOOLEAN)


53
54
55
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 53

def is_echo
  @is_echo
end

#output_dimensionsInteger

The number of dimensions of the output embedding. This is only available for embed-v4 and newer models. Possible values are 256, 512, 1024, and 1536.

Returns:

  • (Integer)


61
62
63
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 61

def output_dimensions
  @output_dimensions
end

#serving_modeOCI::GenerativeAiInference::Models::ServingMode

This attribute is required.



45
46
47
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 45

def serving_mode
  @serving_mode
end

#truncateString

For an input that's longer than the maximum token length, specifies which part of the input text will be truncated.

Returns:

  • (String)


65
66
67
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 65

def truncate
  @truncate
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 72

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'inputs': :'inputs',
    'embed_contents': :'embedContents',
    'serving_mode': :'servingMode',
    'compartment_id': :'compartmentId',
    'is_echo': :'isEcho',
    'embedding_types': :'embeddingTypes',
    'output_dimensions': :'outputDimensions',
    'truncate': :'truncate',
    'input_type': :'inputType'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 89

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'inputs': :'Array<String>',
    'embed_contents': :'Array<OCI::GenerativeAiInference::Models::EmbedContent>',
    'serving_mode': :'OCI::GenerativeAiInference::Models::ServingMode',
    'compartment_id': :'String',
    'is_echo': :'BOOLEAN',
    'embedding_types': :'Array<String>',
    'output_dimensions': :'Integer',
    'truncate': :'String',
    'input_type': :'String'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 214

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    inputs == other.inputs &&
    embed_contents == other.embed_contents &&
    serving_mode == other.serving_mode &&
    compartment_id == other.compartment_id &&
    is_echo == other.is_echo &&
    embedding_types == other.embedding_types &&
    output_dimensions == other.output_dimensions &&
    truncate == other.truncate &&
    input_type == other.input_type
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 252

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


232
233
234
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 232

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



241
242
243
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 241

def hash
  [inputs, embed_contents, serving_mode, compartment_id, is_echo, embedding_types, output_dimensions, truncate, input_type].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



285
286
287
288
289
290
291
292
293
294
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 285

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



279
280
281
# File 'lib/oci/generative_ai_inference/models/embed_text_details.rb', line 279

def to_s
  to_hash.to_s
end