Class: Vapi::ToolCallMessage
- Inherits:
-
Object
- Object
- Vapi::ToolCallMessage
- Defined in:
- lib/vapi_server_sdk/types/tool_call_message.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#message ⇒ String
readonly
The message content for the tool call.
-
#role ⇒ String
readonly
The role of the tool call in the conversation.
-
#seconds_from_start ⇒ Float
readonly
The number of seconds from the start of the conversation.
-
#time ⇒ Float
readonly
The timestamp when the message was sent.
-
#tool_calls ⇒ Array<Hash{String => Object}>
readonly
The list of tool calls made during the conversation.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ToolCallMessage
Deserialize a JSON object to an instance of ToolCallMessage.
-
.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:, tool_calls:, message:, time:, seconds_from_start:, additional_properties: nil) ⇒ Vapi::ToolCallMessage constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ToolCallMessage to a JSON object.
Constructor Details
#initialize(role:, tool_calls:, message:, time:, seconds_from_start:, additional_properties: nil) ⇒ Vapi::ToolCallMessage
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 33 def initialize(role:, tool_calls:, message:, time:, seconds_from_start:, additional_properties: nil) @role = role @tool_calls = tool_calls @message = @time = time @seconds_from_start = seconds_from_start @additional_properties = additional_properties @_field_set = { "role": role, "toolCalls": tool_calls, "message": , "time": time, "secondsFromStart": seconds_from_start } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
19 20 21 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 19 def additional_properties @additional_properties end |
#message ⇒ String (readonly)
Returns The message content for the tool call.
13 14 15 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 13 def @message end |
#role ⇒ String (readonly)
Returns The role of the tool call in the conversation.
9 10 11 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 9 def role @role end |
#seconds_from_start ⇒ Float (readonly)
Returns The number of seconds from the start of the conversation.
17 18 19 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 17 def seconds_from_start @seconds_from_start end |
#time ⇒ Float (readonly)
Returns The timestamp when the message was sent.
15 16 17 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 15 def time @time end |
#tool_calls ⇒ Array<Hash{String => Object}> (readonly)
Returns The list of tool calls made during the conversation.
11 12 13 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 11 def tool_calls @tool_calls end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ToolCallMessage
Deserialize a JSON object to an instance of ToolCallMessage
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 53 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) role = parsed_json["role"] tool_calls = parsed_json["toolCalls"] = parsed_json["message"] time = parsed_json["time"] seconds_from_start = parsed_json["secondsFromStart"] new( role: role, tool_calls: tool_calls, message: , time: time, seconds_from_start: seconds_from_start, 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.
84 85 86 87 88 89 90 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 84 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.tool_calls.is_a?(Array) != false || raise("Passed value for field obj.tool_calls is not the expected type, validation failed.") obj..is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.") obj.time.is_a?(Float) != false || raise("Passed value for field obj.time is not the expected type, validation failed.") obj.seconds_from_start.is_a?(Float) != false || raise("Passed value for field obj.seconds_from_start is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ToolCallMessage to a JSON object
74 75 76 |
# File 'lib/vapi_server_sdk/types/tool_call_message.rb', line 74 def to_json(*_args) @_field_set&.to_json end |