Class: Vapi::AssistantMessage
- Inherits:
-
Object
- Object
- Vapi::AssistantMessage
- Defined in:
- lib/vapi_server_sdk/types/assistant_message.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#content ⇒ String
readonly
This is the content of the assistant message.
-
#name ⇒ String
readonly
This is an optional name for the participant.
-
#refusal ⇒ String
readonly
This is the refusal message generated by the model.
-
#role ⇒ String
readonly
This is the role of the message author.
-
#tool_calls ⇒ Array<Vapi::ToolCall>
readonly
This is the tool calls generated by the model.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::AssistantMessage
Deserialize a JSON object to an instance of AssistantMessage.
-
.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(role:, content: OMIT, refusal: OMIT, tool_calls: OMIT, name: OMIT, additional_properties: nil) ⇒ Vapi::AssistantMessage constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AssistantMessage to a JSON object.
Constructor Details
#initialize(role:, content: OMIT, refusal: OMIT, tool_calls: OMIT, name: OMIT, additional_properties: nil) ⇒ Vapi::AssistantMessage
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vapi_server_sdk/types/assistant_message.rb', line 34 def initialize(role:, content: OMIT, refusal: OMIT, tool_calls: OMIT, name: OMIT, additional_properties: nil) @role = role @content = content if content != OMIT @refusal = refusal if refusal != OMIT @tool_calls = tool_calls if tool_calls != OMIT @name = name if name != OMIT @additional_properties = additional_properties @_field_set = { "role": role, "content": content, "refusal": refusal, "tool_calls": tool_calls, "name": name }.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/vapi_server_sdk/types/assistant_message.rb', line 20 def additional_properties @additional_properties end |
#content ⇒ String (readonly)
Returns This is the content of the assistant message.
12 13 14 |
# File 'lib/vapi_server_sdk/types/assistant_message.rb', line 12 def content @content end |
#name ⇒ String (readonly)
Returns This is an optional name for the participant.
18 19 20 |
# File 'lib/vapi_server_sdk/types/assistant_message.rb', line 18 def name @name end |
#refusal ⇒ String (readonly)
Returns This is the refusal message generated by the model.
14 15 16 |
# File 'lib/vapi_server_sdk/types/assistant_message.rb', line 14 def refusal @refusal end |
#role ⇒ String (readonly)
Returns This is the role of the message author.
10 11 12 |
# File 'lib/vapi_server_sdk/types/assistant_message.rb', line 10 def role @role end |
#tool_calls ⇒ Array<Vapi::ToolCall> (readonly)
Returns This is the tool calls generated by the model.
16 17 18 |
# File 'lib/vapi_server_sdk/types/assistant_message.rb', line 16 def tool_calls @tool_calls end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::AssistantMessage
Deserialize a JSON object to an instance of AssistantMessage
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/vapi_server_sdk/types/assistant_message.rb', line 56 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) role = parsed_json["role"] content = parsed_json["content"] refusal = parsed_json["refusal"] tool_calls = parsed_json["tool_calls"]&.map do |item| item = item.to_json Vapi::ToolCall.from_json(json_object: item) end name = parsed_json["name"] new( role: role, content: content, refusal: refusal, tool_calls: tool_calls, name: name, additional_properties: struct ) 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.
90 91 92 93 94 95 96 |
# File 'lib/vapi_server_sdk/types/assistant_message.rb', line 90 def self.validate_raw(obj:) obj.role.is_a?(String) != false || raise("Passed value for field obj.role is not the expected type, validation failed.") obj.content&.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") obj.refusal&.is_a?(String) != false || raise("Passed value for field obj.refusal is not the expected type, validation failed.") obj.tool_calls&.is_a?(Array) != false || raise("Passed value for field obj.tool_calls is not the expected type, validation failed.") obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of AssistantMessage to a JSON object
80 81 82 |
# File 'lib/vapi_server_sdk/types/assistant_message.rb', line 80 def to_json(*_args) @_field_set&.to_json end |