Class: Vapi::ToolCallResultMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/tool_call_result_message.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(role:, tool_call_id:, name:, result:, time:, seconds_from_start:, additional_properties: nil) ⇒ Vapi::ToolCallResultMessage

Parameters:

  • role (String)

    The role of the tool call result in the conversation.

  • tool_call_id (String)

    The ID of the tool call.

  • name (String)

    The name of the tool that returned the result.

  • result (String)

    The result of the tool call in JSON format.

  • time (Float)

    The timestamp when the message was sent.

  • seconds_from_start (Float)

    The number of seconds from the start of the conversation.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 36

def initialize(role:, tool_call_id:, name:, result:, time:, seconds_from_start:, additional_properties: nil)
  @role = role
  @tool_call_id = tool_call_id
  @name = name
  @result = result
  @time = time
  @seconds_from_start = seconds_from_start
  @additional_properties = additional_properties
  @_field_set = {
    "role": role,
    "toolCallId": tool_call_id,
    "name": name,
    "result": result,
    "time": time,
    "secondsFromStart": seconds_from_start
  }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



21
22
23
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 21

def additional_properties
  @additional_properties
end

#nameString (readonly)

Returns The name of the tool that returned the result.

Returns:

  • (String)

    The name of the tool that returned the result.



13
14
15
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 13

def name
  @name
end

#resultString (readonly)

Returns The result of the tool call in JSON format.

Returns:

  • (String)

    The result of the tool call in JSON format.



15
16
17
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 15

def result
  @result
end

#roleString (readonly)

Returns The role of the tool call result in the conversation.

Returns:

  • (String)

    The role of the tool call result in the conversation.



9
10
11
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 9

def role
  @role
end

#seconds_from_startFloat (readonly)

Returns The number of seconds from the start of the conversation.

Returns:

  • (Float)

    The number of seconds from the start of the conversation.



19
20
21
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 19

def seconds_from_start
  @seconds_from_start
end

#timeFloat (readonly)

Returns The timestamp when the message was sent.

Returns:

  • (Float)

    The timestamp when the message was sent.



17
18
19
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 17

def time
  @time
end

#tool_call_idString (readonly)

Returns The ID of the tool call.

Returns:

  • (String)

    The ID of the tool call.



11
12
13
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 11

def tool_call_id
  @tool_call_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ToolCallResultMessage

Deserialize a JSON object to an instance of ToolCallResultMessage

Parameters:

  • json_object (String)

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 58

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_call_id = parsed_json["toolCallId"]
  name = parsed_json["name"]
  result = parsed_json["result"]
  time = parsed_json["time"]
  seconds_from_start = parsed_json["secondsFromStart"]
  new(
    role: role,
    tool_call_id: tool_call_id,
    name: name,
    result: result,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


91
92
93
94
95
96
97
98
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 91

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_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.")
  obj.result.is_a?(String) != false || raise("Passed value for field obj.result 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 ToolCallResultMessage to a JSON object

Returns:

  • (String)


81
82
83
# File 'lib/vapi_server_sdk/types/tool_call_result_message.rb', line 81

def to_json(*_args)
  @_field_set&.to_json
end