Class: Vellum::ChatMessageRequest
- Inherits:
-
Object
- Object
- Vellum::ChatMessageRequest
- Defined in:
- lib/vellum_ai/types/chat_message_request.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #content ⇒ Vellum::ChatMessageContentRequest readonly
- #role ⇒ Vellum::ChatMessageRole readonly
-
#source ⇒ String
readonly
An optional identifier representing who or what generated this message.
- #text ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(text: OMIT, role:, content: OMIT, source: OMIT, additional_properties: nil) ⇒ Vellum::ChatMessageRequest constructor
- #to_json ⇒ String
Constructor Details
#initialize(text: OMIT, role:, content: OMIT, source: OMIT, additional_properties: nil) ⇒ Vellum::ChatMessageRequest
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 31 def initialize(text: OMIT, role:, content: OMIT, source: OMIT, additional_properties: nil) @text = text if text != OMIT @role = role @content = content if content != OMIT @source = source if source != OMIT @additional_properties = additional_properties @_field_set = { "text": text, "role": role, "content": content, "source": source }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
18 19 20 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 18 def additional_properties @additional_properties end |
#content ⇒ Vellum::ChatMessageContentRequest (readonly)
14 15 16 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 14 def content @content end |
#role ⇒ Vellum::ChatMessageRole (readonly)
12 13 14 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 12 def role @role end |
#source ⇒ String (readonly)
Returns An optional identifier representing who or what generated this message.
16 17 18 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 16 def source @source end |
#text ⇒ String (readonly)
10 11 12 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 10 def text @text end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::ChatMessageRequest
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 45 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) text = parsed_json["text"] role = parsed_json["role"] unless parsed_json["content"].nil? content = parsed_json["content"].to_json content = Vellum::ChatMessageContentRequest.from_json(json_object: content) else content = nil end source = parsed_json["source"] new( text: text, role: role, content: content, source: source, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
77 78 79 80 81 82 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 77 def self.validate_raw(obj:) obj.text&.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") obj.role.is_a?(Vellum::ChatMessageRole) != false || raise("Passed value for field obj.role is not the expected type, validation failed.") obj.content.nil? || Vellum::ChatMessageContentRequest.validate_raw(obj: obj.content) obj.source&.is_a?(String) != false || raise("Passed value for field obj.source is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
68 69 70 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 68 def to_json @_field_set&.to_json end |