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
- #metadata ⇒ Hash{String => Object} 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, metadata: OMIT, additional_properties: nil) ⇒ Vellum::ChatMessageRequest constructor
- #to_json ⇒ String
Constructor Details
#initialize(text: OMIT, role:, content: OMIT, source: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Vellum::ChatMessageRequest
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 34 def initialize(text: OMIT, role:, content: OMIT, source: OMIT, metadata: OMIT, additional_properties: nil) @text = text if text != OMIT @role = role @content = content if content != OMIT @source = source if source != OMIT = if != OMIT @additional_properties = additional_properties @_field_set = { "text": text, "role": role, "content": content, "source": source, "metadata": }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
20 21 22 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 20 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 |
#metadata ⇒ Hash{String => Object} (readonly)
18 19 20 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 18 def 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
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 49 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"] = parsed_json["metadata"] new( text: text, role: role, content: content, source: source, metadata: , additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
83 84 85 86 87 88 89 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 83 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.") obj.&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
74 75 76 |
# File 'lib/vellum_ai/types/chat_message_request.rb', line 74 def to_json @_field_set&.to_json end |