Class: Vellum::ArrayChatMessageContentItemRequest
- Inherits:
-
Object
- Object
- Vellum::ArrayChatMessageContentItemRequest
- Defined in:
- lib/vellum_ai/types/array_chat_message_content_item_request.rb
Instance Attribute Summary collapse
-
#discriminant ⇒ Object
readonly
Returns the value of attribute discriminant.
-
#member ⇒ Object
readonly
Returns the value of attribute member.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ ArrayChatMessageContentItemRequest
Deserialize a JSON object to an instance of ArrayChatMessageContentItemRequest.
- .function_call(member:) ⇒ ArrayChatMessageContentItemRequest
- .image(member:) ⇒ ArrayChatMessageContentItemRequest
- .string(member:) ⇒ ArrayChatMessageContentItemRequest
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(member:, discriminant:) ⇒ ArrayChatMessageContentItemRequest constructor
-
#is_a?(obj) ⇒ Boolean
For Union Types, is_a? functionality is delegated to the wrapped member.
- #kind_of? ⇒ Object
-
#to_json(*_args) ⇒ JSON
For Union Types, to_json functionality is delegated to the wrapped member.
Constructor Details
#initialize(member:, discriminant:) ⇒ ArrayChatMessageContentItemRequest
17 18 19 20 21 22 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 17 def initialize(member:, discriminant:) # @type [Object] @member = member # @type [String] @discriminant = discriminant end |
Instance Attribute Details
#discriminant ⇒ Object (readonly)
Returns the value of attribute discriminant.
10 11 12 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 10 def discriminant @discriminant end |
#member ⇒ Object (readonly)
Returns the value of attribute member.
10 11 12 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 10 def member @member end |
Class Method Details
.from_json(json_object:) ⇒ ArrayChatMessageContentItemRequest
Deserialize a JSON object to an instance of ArrayChatMessageContentItemRequest
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 28 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) member = case struct.type when "STRING" StringChatMessageContentRequest.from_json(json_object: json_object) when "FUNCTION_CALL" FunctionCallChatMessageContentRequest.from_json(json_object: json_object) when "IMAGE" ImageChatMessageContentRequest.from_json(json_object: json_object) else StringChatMessageContentRequest.from_json(json_object: json_object) end new(member: member, discriminant: struct.type) end |
.function_call(member:) ⇒ ArrayChatMessageContentItemRequest
93 94 95 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 93 def self.function_call(member:) new(member: member, discriminant: "FUNCTION_CALL") end |
.image(member:) ⇒ ArrayChatMessageContentItemRequest
99 100 101 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 99 def self.image(member:) new(member: member, discriminant: "IMAGE") end |
.string(member:) ⇒ ArrayChatMessageContentItemRequest
87 88 89 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 87 def self.string(member:) new(member: member, discriminant: "STRING") end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 64 def self.validate_raw(obj:) case obj.type when "STRING" StringChatMessageContentRequest.validate_raw(obj: obj) when "FUNCTION_CALL" FunctionCallChatMessageContentRequest.validate_raw(obj: obj) when "IMAGE" ImageChatMessageContentRequest.validate_raw(obj: obj) else raise("Passed value matched no type within the union, validation failed.") end end |
Instance Method Details
#is_a?(obj) ⇒ Boolean
For Union Types, is_a? functionality is delegated to the wrapped member.
81 82 83 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 81 def is_a?(obj) @member.is_a?(obj) end |
#kind_of? ⇒ Object
13 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 13 alias kind_of? is_a? |
#to_json(*_args) ⇒ JSON
For Union Types, to_json functionality is delegated to the wrapped member.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vellum_ai/types/array_chat_message_content_item_request.rb', line 46 def to_json(*_args) case @discriminant when "STRING" { **@member.to_json, type: @discriminant }.to_json when "FUNCTION_CALL" { **@member.to_json, type: @discriminant }.to_json when "IMAGE" { **@member.to_json, type: @discriminant }.to_json else { "type": @discriminant, value: @member }.to_json end @member.to_json end |