vellum_ai 1.2.2 → 1.2.3

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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/requests.rb +2 -2
  3. data/lib/types_export.rb +20 -0
  4. data/lib/vellum_ai/types/audio_input_request.rb +75 -0
  5. data/lib/vellum_ai/types/delimiter_chunker_config.rb +63 -0
  6. data/lib/vellum_ai/types/delimiter_chunker_config_request.rb +63 -0
  7. data/lib/vellum_ai/types/delimiter_chunking.rb +69 -0
  8. data/lib/vellum_ai/types/delimiter_chunking_request.rb +69 -0
  9. data/lib/vellum_ai/types/document_index_chunking.rb +16 -0
  10. data/lib/vellum_ai/types/document_index_chunking_request.rb +16 -0
  11. data/lib/vellum_ai/types/document_input_request.rb +75 -0
  12. data/lib/vellum_ai/types/execution_audio_vellum_value.rb +84 -0
  13. data/lib/vellum_ai/types/execution_document_vellum_value.rb +84 -0
  14. data/lib/vellum_ai/types/execution_image_vellum_value.rb +84 -0
  15. data/lib/vellum_ai/types/execution_vellum_value.rb +64 -0
  16. data/lib/vellum_ai/types/execution_video_vellum_value.rb +84 -0
  17. data/lib/vellum_ai/types/image_input_request.rb +75 -0
  18. data/lib/vellum_ai/types/logical_operator.rb +2 -0
  19. data/lib/vellum_ai/types/node_input_compiled_audio_value.rb +83 -0
  20. data/lib/vellum_ai/types/node_input_compiled_document_value.rb +83 -0
  21. data/lib/vellum_ai/types/node_input_compiled_image_value.rb +83 -0
  22. data/lib/vellum_ai/types/node_input_compiled_video_value.rb +83 -0
  23. data/lib/vellum_ai/types/node_input_variable_compiled_value.rb +64 -0
  24. data/lib/vellum_ai/types/prompt_deployment_input_request.rb +64 -0
  25. data/lib/vellum_ai/types/prompt_request_audio_input.rb +74 -0
  26. data/lib/vellum_ai/types/prompt_request_document_input.rb +74 -0
  27. data/lib/vellum_ai/types/prompt_request_image_input.rb +74 -0
  28. data/lib/vellum_ai/types/prompt_request_input.rb +64 -0
  29. data/lib/vellum_ai/types/prompt_request_video_input.rb +74 -0
  30. data/lib/vellum_ai/types/video_input_request.rb +75 -0
  31. data/lib/vellum_ai/workflow_executions/client.rb +8 -8
  32. metadata +22 -2
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+ require_relative "vellum_audio"
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Vellum
7
+ # A base Vellum primitive value representing audio.
8
+ class ExecutionAudioVellumValue
9
+ # @return [String] The variable's uniquely identifying internal id.
10
+ attr_reader :id
11
+ # @return [String]
12
+ attr_reader :name
13
+ # @return [String]
14
+ attr_reader :type
15
+ # @return [Vellum::VellumAudio]
16
+ attr_reader :value
17
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
18
+ attr_reader :additional_properties
19
+ # @return [Object]
20
+ attr_reader :_field_set
21
+ protected :_field_set
22
+
23
+ OMIT = Object.new
24
+
25
+ # @param id [String] The variable's uniquely identifying internal id.
26
+ # @param name [String]
27
+ # @param type [String]
28
+ # @param value [Vellum::VellumAudio]
29
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
+ # @return [Vellum::ExecutionAudioVellumValue]
31
+ def initialize(id:, name:, type:, value: OMIT, additional_properties: nil)
32
+ @id = id
33
+ @name = name
34
+ @type = type
35
+ @value = value if value != OMIT
36
+ @additional_properties = additional_properties
37
+ @_field_set = { "id": id, "name": name, "type": type, "value": value }.reject do | _k, v |
38
+ v == OMIT
39
+ end
40
+ end
41
+ # Deserialize a JSON object to an instance of ExecutionAudioVellumValue
42
+ #
43
+ # @param json_object [String]
44
+ # @return [Vellum::ExecutionAudioVellumValue]
45
+ def self.from_json(json_object:)
46
+ struct = JSON.parse(json_object, object_class: OpenStruct)
47
+ parsed_json = JSON.parse(json_object)
48
+ id = parsed_json["id"]
49
+ name = parsed_json["name"]
50
+ type = parsed_json["type"]
51
+ unless parsed_json["value"].nil?
52
+ value = parsed_json["value"].to_json
53
+ value = Vellum::VellumAudio.from_json(json_object: value)
54
+ else
55
+ value = nil
56
+ end
57
+ new(
58
+ id: id,
59
+ name: name,
60
+ type: type,
61
+ value: value,
62
+ additional_properties: struct
63
+ )
64
+ end
65
+ # Serialize an instance of ExecutionAudioVellumValue to a JSON object
66
+ #
67
+ # @return [String]
68
+ def to_json
69
+ @_field_set&.to_json
70
+ end
71
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
72
+ # hash and check each fields type against the current object's property
73
+ # definitions.
74
+ #
75
+ # @param obj [Object]
76
+ # @return [Void]
77
+ def self.validate_raw(obj:)
78
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
79
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
80
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
81
+ obj.value.nil? || Vellum::VellumAudio.validate_raw(obj: obj.value)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+ require_relative "vellum_document"
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Vellum
7
+ # A base Vellum primitive value representing a document.
8
+ class ExecutionDocumentVellumValue
9
+ # @return [String] The variable's uniquely identifying internal id.
10
+ attr_reader :id
11
+ # @return [String]
12
+ attr_reader :name
13
+ # @return [String]
14
+ attr_reader :type
15
+ # @return [Vellum::VellumDocument]
16
+ attr_reader :value
17
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
18
+ attr_reader :additional_properties
19
+ # @return [Object]
20
+ attr_reader :_field_set
21
+ protected :_field_set
22
+
23
+ OMIT = Object.new
24
+
25
+ # @param id [String] The variable's uniquely identifying internal id.
26
+ # @param name [String]
27
+ # @param type [String]
28
+ # @param value [Vellum::VellumDocument]
29
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
+ # @return [Vellum::ExecutionDocumentVellumValue]
31
+ def initialize(id:, name:, type:, value: OMIT, additional_properties: nil)
32
+ @id = id
33
+ @name = name
34
+ @type = type
35
+ @value = value if value != OMIT
36
+ @additional_properties = additional_properties
37
+ @_field_set = { "id": id, "name": name, "type": type, "value": value }.reject do | _k, v |
38
+ v == OMIT
39
+ end
40
+ end
41
+ # Deserialize a JSON object to an instance of ExecutionDocumentVellumValue
42
+ #
43
+ # @param json_object [String]
44
+ # @return [Vellum::ExecutionDocumentVellumValue]
45
+ def self.from_json(json_object:)
46
+ struct = JSON.parse(json_object, object_class: OpenStruct)
47
+ parsed_json = JSON.parse(json_object)
48
+ id = parsed_json["id"]
49
+ name = parsed_json["name"]
50
+ type = parsed_json["type"]
51
+ unless parsed_json["value"].nil?
52
+ value = parsed_json["value"].to_json
53
+ value = Vellum::VellumDocument.from_json(json_object: value)
54
+ else
55
+ value = nil
56
+ end
57
+ new(
58
+ id: id,
59
+ name: name,
60
+ type: type,
61
+ value: value,
62
+ additional_properties: struct
63
+ )
64
+ end
65
+ # Serialize an instance of ExecutionDocumentVellumValue to a JSON object
66
+ #
67
+ # @return [String]
68
+ def to_json
69
+ @_field_set&.to_json
70
+ end
71
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
72
+ # hash and check each fields type against the current object's property
73
+ # definitions.
74
+ #
75
+ # @param obj [Object]
76
+ # @return [Void]
77
+ def self.validate_raw(obj:)
78
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
79
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
80
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
81
+ obj.value.nil? || Vellum::VellumDocument.validate_raw(obj: obj.value)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+ require_relative "vellum_image"
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Vellum
7
+ # A base Vellum primitive value representing an image.
8
+ class ExecutionImageVellumValue
9
+ # @return [String] The variable's uniquely identifying internal id.
10
+ attr_reader :id
11
+ # @return [String]
12
+ attr_reader :name
13
+ # @return [String]
14
+ attr_reader :type
15
+ # @return [Vellum::VellumImage]
16
+ attr_reader :value
17
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
18
+ attr_reader :additional_properties
19
+ # @return [Object]
20
+ attr_reader :_field_set
21
+ protected :_field_set
22
+
23
+ OMIT = Object.new
24
+
25
+ # @param id [String] The variable's uniquely identifying internal id.
26
+ # @param name [String]
27
+ # @param type [String]
28
+ # @param value [Vellum::VellumImage]
29
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
+ # @return [Vellum::ExecutionImageVellumValue]
31
+ def initialize(id:, name:, type:, value: OMIT, additional_properties: nil)
32
+ @id = id
33
+ @name = name
34
+ @type = type
35
+ @value = value if value != OMIT
36
+ @additional_properties = additional_properties
37
+ @_field_set = { "id": id, "name": name, "type": type, "value": value }.reject do | _k, v |
38
+ v == OMIT
39
+ end
40
+ end
41
+ # Deserialize a JSON object to an instance of ExecutionImageVellumValue
42
+ #
43
+ # @param json_object [String]
44
+ # @return [Vellum::ExecutionImageVellumValue]
45
+ def self.from_json(json_object:)
46
+ struct = JSON.parse(json_object, object_class: OpenStruct)
47
+ parsed_json = JSON.parse(json_object)
48
+ id = parsed_json["id"]
49
+ name = parsed_json["name"]
50
+ type = parsed_json["type"]
51
+ unless parsed_json["value"].nil?
52
+ value = parsed_json["value"].to_json
53
+ value = Vellum::VellumImage.from_json(json_object: value)
54
+ else
55
+ value = nil
56
+ end
57
+ new(
58
+ id: id,
59
+ name: name,
60
+ type: type,
61
+ value: value,
62
+ additional_properties: struct
63
+ )
64
+ end
65
+ # Serialize an instance of ExecutionImageVellumValue to a JSON object
66
+ #
67
+ # @return [String]
68
+ def to_json
69
+ @_field_set&.to_json
70
+ end
71
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
72
+ # hash and check each fields type against the current object's property
73
+ # definitions.
74
+ #
75
+ # @param obj [Object]
76
+ # @return [Void]
77
+ def self.validate_raw(obj:)
78
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
79
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
80
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
81
+ obj.value.nil? || Vellum::VellumImage.validate_raw(obj: obj.value)
82
+ end
83
+ end
84
+ end
@@ -9,6 +9,10 @@ require_relative "execution_error_vellum_value"
9
9
  require_relative "execution_array_vellum_value"
10
10
  require_relative "execution_function_call_vellum_value"
11
11
  require_relative "execution_thinking_vellum_value"
12
+ require_relative "execution_audio_vellum_value"
13
+ require_relative "execution_video_vellum_value"
14
+ require_relative "execution_image_vellum_value"
15
+ require_relative "execution_document_vellum_value"
12
16
 
13
17
  module Vellum
14
18
  class ExecutionVellumValue
@@ -106,6 +110,46 @@ end
106
110
  return Vellum::ExecutionThinkingVellumValue.from_json(json_object: struct)
107
111
  else
108
112
  return nil
113
+ end
114
+ rescue StandardError
115
+ # noop
116
+ end
117
+ begin
118
+ Vellum::ExecutionAudioVellumValue.validate_raw(obj: struct)
119
+ unless struct.nil?
120
+ return Vellum::ExecutionAudioVellumValue.from_json(json_object: struct)
121
+ else
122
+ return nil
123
+ end
124
+ rescue StandardError
125
+ # noop
126
+ end
127
+ begin
128
+ Vellum::ExecutionVideoVellumValue.validate_raw(obj: struct)
129
+ unless struct.nil?
130
+ return Vellum::ExecutionVideoVellumValue.from_json(json_object: struct)
131
+ else
132
+ return nil
133
+ end
134
+ rescue StandardError
135
+ # noop
136
+ end
137
+ begin
138
+ Vellum::ExecutionImageVellumValue.validate_raw(obj: struct)
139
+ unless struct.nil?
140
+ return Vellum::ExecutionImageVellumValue.from_json(json_object: struct)
141
+ else
142
+ return nil
143
+ end
144
+ rescue StandardError
145
+ # noop
146
+ end
147
+ begin
148
+ Vellum::ExecutionDocumentVellumValue.validate_raw(obj: struct)
149
+ unless struct.nil?
150
+ return Vellum::ExecutionDocumentVellumValue.from_json(json_object: struct)
151
+ else
152
+ return nil
109
153
  end
110
154
  rescue StandardError
111
155
  # noop
@@ -164,6 +208,26 @@ end
164
208
  rescue StandardError
165
209
  # noop
166
210
  end
211
+ begin
212
+ return Vellum::ExecutionAudioVellumValue.validate_raw(obj: obj)
213
+ rescue StandardError
214
+ # noop
215
+ end
216
+ begin
217
+ return Vellum::ExecutionVideoVellumValue.validate_raw(obj: obj)
218
+ rescue StandardError
219
+ # noop
220
+ end
221
+ begin
222
+ return Vellum::ExecutionImageVellumValue.validate_raw(obj: obj)
223
+ rescue StandardError
224
+ # noop
225
+ end
226
+ begin
227
+ return Vellum::ExecutionDocumentVellumValue.validate_raw(obj: obj)
228
+ rescue StandardError
229
+ # noop
230
+ end
167
231
  raise("Passed value matched no type within the union, validation failed.")
168
232
  end
169
233
  end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+ require_relative "vellum_video"
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Vellum
7
+ # A base Vellum primitive value representing a video.
8
+ class ExecutionVideoVellumValue
9
+ # @return [String] The variable's uniquely identifying internal id.
10
+ attr_reader :id
11
+ # @return [String]
12
+ attr_reader :name
13
+ # @return [String]
14
+ attr_reader :type
15
+ # @return [Vellum::VellumVideo]
16
+ attr_reader :value
17
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
18
+ attr_reader :additional_properties
19
+ # @return [Object]
20
+ attr_reader :_field_set
21
+ protected :_field_set
22
+
23
+ OMIT = Object.new
24
+
25
+ # @param id [String] The variable's uniquely identifying internal id.
26
+ # @param name [String]
27
+ # @param type [String]
28
+ # @param value [Vellum::VellumVideo]
29
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
+ # @return [Vellum::ExecutionVideoVellumValue]
31
+ def initialize(id:, name:, type:, value: OMIT, additional_properties: nil)
32
+ @id = id
33
+ @name = name
34
+ @type = type
35
+ @value = value if value != OMIT
36
+ @additional_properties = additional_properties
37
+ @_field_set = { "id": id, "name": name, "type": type, "value": value }.reject do | _k, v |
38
+ v == OMIT
39
+ end
40
+ end
41
+ # Deserialize a JSON object to an instance of ExecutionVideoVellumValue
42
+ #
43
+ # @param json_object [String]
44
+ # @return [Vellum::ExecutionVideoVellumValue]
45
+ def self.from_json(json_object:)
46
+ struct = JSON.parse(json_object, object_class: OpenStruct)
47
+ parsed_json = JSON.parse(json_object)
48
+ id = parsed_json["id"]
49
+ name = parsed_json["name"]
50
+ type = parsed_json["type"]
51
+ unless parsed_json["value"].nil?
52
+ value = parsed_json["value"].to_json
53
+ value = Vellum::VellumVideo.from_json(json_object: value)
54
+ else
55
+ value = nil
56
+ end
57
+ new(
58
+ id: id,
59
+ name: name,
60
+ type: type,
61
+ value: value,
62
+ additional_properties: struct
63
+ )
64
+ end
65
+ # Serialize an instance of ExecutionVideoVellumValue to a JSON object
66
+ #
67
+ # @return [String]
68
+ def to_json
69
+ @_field_set&.to_json
70
+ end
71
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
72
+ # hash and check each fields type against the current object's property
73
+ # definitions.
74
+ #
75
+ # @param obj [Object]
76
+ # @return [Void]
77
+ def self.validate_raw(obj:)
78
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
79
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
80
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
81
+ obj.value.nil? || Vellum::VellumVideo.validate_raw(obj: obj.value)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+ require_relative "vellum_image_request"
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Vellum
7
+ # A user input representing a Vellum Image value
8
+ class ImageInputRequest
9
+ # @return [String] The variable's name
10
+ attr_reader :name
11
+ # @return [String]
12
+ attr_reader :type
13
+ # @return [Vellum::VellumImageRequest]
14
+ attr_reader :value
15
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
16
+ attr_reader :additional_properties
17
+ # @return [Object]
18
+ attr_reader :_field_set
19
+ protected :_field_set
20
+
21
+ OMIT = Object.new
22
+
23
+ # @param name [String] The variable's name
24
+ # @param type [String]
25
+ # @param value [Vellum::VellumImageRequest]
26
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
27
+ # @return [Vellum::ImageInputRequest]
28
+ def initialize(name:, type:, value:, additional_properties: nil)
29
+ @name = name
30
+ @type = type
31
+ @value = value
32
+ @additional_properties = additional_properties
33
+ @_field_set = { "name": name, "type": type, "value": value }
34
+ end
35
+ # Deserialize a JSON object to an instance of ImageInputRequest
36
+ #
37
+ # @param json_object [String]
38
+ # @return [Vellum::ImageInputRequest]
39
+ def self.from_json(json_object:)
40
+ struct = JSON.parse(json_object, object_class: OpenStruct)
41
+ parsed_json = JSON.parse(json_object)
42
+ name = parsed_json["name"]
43
+ type = parsed_json["type"]
44
+ unless parsed_json["value"].nil?
45
+ value = parsed_json["value"].to_json
46
+ value = Vellum::VellumImageRequest.from_json(json_object: value)
47
+ else
48
+ value = nil
49
+ end
50
+ new(
51
+ name: name,
52
+ type: type,
53
+ value: value,
54
+ additional_properties: struct
55
+ )
56
+ end
57
+ # Serialize an instance of ImageInputRequest to a JSON object
58
+ #
59
+ # @return [String]
60
+ def to_json
61
+ @_field_set&.to_json
62
+ end
63
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
64
+ # hash and check each fields type against the current object's property
65
+ # definitions.
66
+ #
67
+ # @param obj [Object]
68
+ # @return [Void]
69
+ def self.validate_raw(obj:)
70
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
71
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
72
+ Vellum::VellumImageRequest.validate_raw(obj: obj.value)
73
+ end
74
+ end
75
+ end
@@ -27,6 +27,7 @@ module Vellum
27
27
  # * `and` - AND
28
28
  # * `or` - OR
29
29
  # * `isError` - IS_ERROR
30
+ # * `length` - LENGTH
30
31
  class LogicalOperator
31
32
 
32
33
  EQUALS = "="
@@ -55,6 +56,7 @@ module Vellum
55
56
  AND = "and"
56
57
  OR = "or"
57
58
  IS_ERROR = "isError"
59
+ LENGTH = "length"
58
60
 
59
61
  end
60
62
  end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+ require_relative "vellum_audio"
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Vellum
7
+ class NodeInputCompiledAudioValue
8
+ # @return [String]
9
+ attr_reader :node_input_id
10
+ # @return [String]
11
+ attr_reader :key
12
+ # @return [String]
13
+ attr_reader :type
14
+ # @return [Vellum::VellumAudio]
15
+ attr_reader :value
16
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
17
+ attr_reader :additional_properties
18
+ # @return [Object]
19
+ attr_reader :_field_set
20
+ protected :_field_set
21
+
22
+ OMIT = Object.new
23
+
24
+ # @param node_input_id [String]
25
+ # @param key [String]
26
+ # @param type [String]
27
+ # @param value [Vellum::VellumAudio]
28
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
29
+ # @return [Vellum::NodeInputCompiledAudioValue]
30
+ def initialize(node_input_id:, key:, type:, value: OMIT, additional_properties: nil)
31
+ @node_input_id = node_input_id
32
+ @key = key
33
+ @type = type
34
+ @value = value if value != OMIT
35
+ @additional_properties = additional_properties
36
+ @_field_set = { "node_input_id": node_input_id, "key": key, "type": type, "value": value }.reject do | _k, v |
37
+ v == OMIT
38
+ end
39
+ end
40
+ # Deserialize a JSON object to an instance of NodeInputCompiledAudioValue
41
+ #
42
+ # @param json_object [String]
43
+ # @return [Vellum::NodeInputCompiledAudioValue]
44
+ def self.from_json(json_object:)
45
+ struct = JSON.parse(json_object, object_class: OpenStruct)
46
+ parsed_json = JSON.parse(json_object)
47
+ node_input_id = parsed_json["node_input_id"]
48
+ key = parsed_json["key"]
49
+ type = parsed_json["type"]
50
+ unless parsed_json["value"].nil?
51
+ value = parsed_json["value"].to_json
52
+ value = Vellum::VellumAudio.from_json(json_object: value)
53
+ else
54
+ value = nil
55
+ end
56
+ new(
57
+ node_input_id: node_input_id,
58
+ key: key,
59
+ type: type,
60
+ value: value,
61
+ additional_properties: struct
62
+ )
63
+ end
64
+ # Serialize an instance of NodeInputCompiledAudioValue to a JSON object
65
+ #
66
+ # @return [String]
67
+ def to_json
68
+ @_field_set&.to_json
69
+ end
70
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
71
+ # hash and check each fields type against the current object's property
72
+ # definitions.
73
+ #
74
+ # @param obj [Object]
75
+ # @return [Void]
76
+ def self.validate_raw(obj:)
77
+ obj.node_input_id.is_a?(String) != false || raise("Passed value for field obj.node_input_id is not the expected type, validation failed.")
78
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
79
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
80
+ obj.value.nil? || Vellum::VellumAudio.validate_raw(obj: obj.value)
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+ require_relative "vellum_document"
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Vellum
7
+ class NodeInputCompiledDocumentValue
8
+ # @return [String]
9
+ attr_reader :node_input_id
10
+ # @return [String]
11
+ attr_reader :key
12
+ # @return [String]
13
+ attr_reader :type
14
+ # @return [Vellum::VellumDocument]
15
+ attr_reader :value
16
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
17
+ attr_reader :additional_properties
18
+ # @return [Object]
19
+ attr_reader :_field_set
20
+ protected :_field_set
21
+
22
+ OMIT = Object.new
23
+
24
+ # @param node_input_id [String]
25
+ # @param key [String]
26
+ # @param type [String]
27
+ # @param value [Vellum::VellumDocument]
28
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
29
+ # @return [Vellum::NodeInputCompiledDocumentValue]
30
+ def initialize(node_input_id:, key:, type:, value: OMIT, additional_properties: nil)
31
+ @node_input_id = node_input_id
32
+ @key = key
33
+ @type = type
34
+ @value = value if value != OMIT
35
+ @additional_properties = additional_properties
36
+ @_field_set = { "node_input_id": node_input_id, "key": key, "type": type, "value": value }.reject do | _k, v |
37
+ v == OMIT
38
+ end
39
+ end
40
+ # Deserialize a JSON object to an instance of NodeInputCompiledDocumentValue
41
+ #
42
+ # @param json_object [String]
43
+ # @return [Vellum::NodeInputCompiledDocumentValue]
44
+ def self.from_json(json_object:)
45
+ struct = JSON.parse(json_object, object_class: OpenStruct)
46
+ parsed_json = JSON.parse(json_object)
47
+ node_input_id = parsed_json["node_input_id"]
48
+ key = parsed_json["key"]
49
+ type = parsed_json["type"]
50
+ unless parsed_json["value"].nil?
51
+ value = parsed_json["value"].to_json
52
+ value = Vellum::VellumDocument.from_json(json_object: value)
53
+ else
54
+ value = nil
55
+ end
56
+ new(
57
+ node_input_id: node_input_id,
58
+ key: key,
59
+ type: type,
60
+ value: value,
61
+ additional_properties: struct
62
+ )
63
+ end
64
+ # Serialize an instance of NodeInputCompiledDocumentValue to a JSON object
65
+ #
66
+ # @return [String]
67
+ def to_json
68
+ @_field_set&.to_json
69
+ end
70
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
71
+ # hash and check each fields type against the current object's property
72
+ # definitions.
73
+ #
74
+ # @param obj [Object]
75
+ # @return [Void]
76
+ def self.validate_raw(obj:)
77
+ obj.node_input_id.is_a?(String) != false || raise("Passed value for field obj.node_input_id is not the expected type, validation failed.")
78
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
79
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
80
+ obj.value.nil? || Vellum::VellumDocument.validate_raw(obj: obj.value)
81
+ end
82
+ end
83
+ end