Class: Vapi::ToolMessage
- Inherits:
-
Object
- Object
- Vapi::ToolMessage
- Defined in:
- lib/vapi_server_sdk/types/tool_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 tool message.
-
#name ⇒ String
readonly
This is an optional name for the participant.
-
#role ⇒ String
readonly
This is the role of the message author.
-
#tool_call_id ⇒ String
readonly
This is the ID of the tool call this message is responding to.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ToolMessage
Deserialize a JSON object to an instance of ToolMessage.
-
.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:, tool_call_id:, name: OMIT, additional_properties: nil) ⇒ Vapi::ToolMessage constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ToolMessage to a JSON object.
Constructor Details
#initialize(role:, content:, tool_call_id:, name: OMIT, additional_properties: nil) ⇒ Vapi::ToolMessage
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vapi_server_sdk/types/tool_message.rb', line 30 def initialize(role:, content:, tool_call_id:, name: OMIT, additional_properties: nil) @role = role @content = content @tool_call_id = tool_call_id @name = name if name != OMIT @additional_properties = additional_properties @_field_set = { "role": role, "content": content, "tool_call_id": tool_call_id, "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.
17 18 19 |
# File 'lib/vapi_server_sdk/types/tool_message.rb', line 17 def additional_properties @additional_properties end |
#content ⇒ String (readonly)
Returns This is the content of the tool message.
11 12 13 |
# File 'lib/vapi_server_sdk/types/tool_message.rb', line 11 def content @content end |
#name ⇒ String (readonly)
Returns This is an optional name for the participant.
15 16 17 |
# File 'lib/vapi_server_sdk/types/tool_message.rb', line 15 def name @name end |
#role ⇒ String (readonly)
Returns This is the role of the message author.
9 10 11 |
# File 'lib/vapi_server_sdk/types/tool_message.rb', line 9 def role @role end |
#tool_call_id ⇒ String (readonly)
Returns This is the ID of the tool call this message is responding to.
13 14 15 |
# File 'lib/vapi_server_sdk/types/tool_message.rb', line 13 def tool_call_id @tool_call_id end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ToolMessage
Deserialize a JSON object to an instance of ToolMessage
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vapi_server_sdk/types/tool_message.rb', line 45 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"] tool_call_id = parsed_json["tool_call_id"] name = parsed_json["name"] new( role: role, content: content, tool_call_id: tool_call_id, 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.
74 75 76 77 78 79 |
# File 'lib/vapi_server_sdk/types/tool_message.rb', line 74 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.tool_call_id.is_a?(String) != false || raise("Passed value for field obj.tool_call_id 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 ToolMessage to a JSON object
64 65 66 |
# File 'lib/vapi_server_sdk/types/tool_message.rb', line 64 def to_json(*_args) @_field_set&.to_json end |