Class: Vellum::ImageVellumValue

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/image_vellum_value.rb

Overview

A base Vellum primitive value representing an image.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, value: OMIT, additional_properties: nil) ⇒ Vellum::ImageVellumValue



25
26
27
28
29
30
31
32
# File 'lib/vellum_ai/types/image_vellum_value.rb', line 25

def initialize(type:, value: OMIT, additional_properties: nil)
  @type = type
  @value = value if value != OMIT
  @additional_properties = additional_properties
  @_field_set = { "type": type, "value": value }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)



14
15
16
# File 'lib/vellum_ai/types/image_vellum_value.rb', line 14

def additional_properties
  @additional_properties
end

#type ⇒ String (readonly)



10
11
12
# File 'lib/vellum_ai/types/image_vellum_value.rb', line 10

def type
  @type
end

#value ⇒ Vellum::VellumImage (readonly)



12
13
14
# File 'lib/vellum_ai/types/image_vellum_value.rb', line 12

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::ImageVellumValue



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vellum_ai/types/image_vellum_value.rb', line 37

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  type = parsed_json["type"]
  unless parsed_json["value"].nil?
    value = parsed_json["value"].to_json
    value = Vellum::VellumImage.from_json(json_object: value)
  else
    value = nil
  end
  new(
    type: type,
    value: value,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void



65
66
67
68
# File 'lib/vellum_ai/types/image_vellum_value.rb', line 65

def self.validate_raw(obj:)
  obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.value.nil? || Vellum::VellumImage.validate_raw(obj: obj.value)
end

Instance Method Details

#to_json ⇒ String



56
57
58
# File 'lib/vellum_ai/types/image_vellum_value.rb', line 56

def to_json
  @_field_set&.to_json
end