Class: Vapi::ToolCallResult
- Inherits:
-
Object
- Object
- Vapi::ToolCallResult
- Defined in:
- lib/vapi_server_sdk/types/tool_call_result.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#error ⇒ String
readonly
This is the error if the tool call was not successful.
-
#message ⇒ Vapi::ToolCallResultMessage
readonly
This is the message that will be spoken to the user.
-
#metadata ⇒ Hash{String => Object}
readonly
This is optional metadata for the tool call result to be sent to the client.
-
#name ⇒ String
readonly
This is the name of the function the model called.
-
#result ⇒ String
readonly
This is the result if the tool call was successful.
-
#tool_call_id ⇒ String
readonly
This is the unique identifier for the tool call.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ToolCallResult
Deserialize a JSON object to an instance of ToolCallResult.
-
.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(name:, tool_call_id:, message: OMIT, result: OMIT, error: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Vapi::ToolCallResult constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ToolCallResult to a JSON object.
Constructor Details
#initialize(name:, tool_call_id:, message: OMIT, result: OMIT, error: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Vapi::ToolCallResult
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 65 def initialize(name:, tool_call_id:, message: OMIT, result: OMIT, error: OMIT, metadata: OMIT, additional_properties: nil) @message = if != OMIT @name = name @tool_call_id = tool_call_id @result = result if result != OMIT @error = error if error != OMIT @metadata = if != OMIT @additional_properties = additional_properties @_field_set = { "message": , "name": name, "toolCallId": tool_call_id, "result": result, "error": error, "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.
36 37 38 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 36 def additional_properties @additional_properties end |
#error ⇒ String (readonly)
Returns This is the error if the tool call was not successful. This is added to the conversation history. Further, if this is returned, assistant will speak:
-
the ‘message`, if it exists and is of type `request-failed`
-
a ‘request-failed` message from `tool.messages`, if it exists
-
a response generated by the model, if neither exist.
32 33 34 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 32 def error @error end |
#message ⇒ Vapi::ToolCallResultMessage (readonly)
Returns This is the message that will be spoken to the user. If this is not returned, assistant will speak:
-
a ‘request-complete` or `request-failed` message from `tool.messages`, if it
exists
-
a response generated by the model, if not.
14 15 16 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 14 def @message end |
#metadata ⇒ Hash{String => Object} (readonly)
Returns This is optional metadata for the tool call result to be sent to the client.
34 35 36 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 34 def @metadata end |
#name ⇒ String (readonly)
Returns This is the name of the function the model called.
16 17 18 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 16 def name @name end |
#result ⇒ String (readonly)
Returns This is the result if the tool call was successful. This is added to the conversation history. Further, if this is returned, assistant will speak:
-
the ‘message`, if it exists and is of type `request-complete`
-
a ‘request-complete` message from `tool.messages`, if it exists
-
a response generated by the model, if neither exist.
25 26 27 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 25 def result @result end |
#tool_call_id ⇒ String (readonly)
Returns This is the unique identifier for the tool call.
18 19 20 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 18 def tool_call_id @tool_call_id end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ToolCallResult
Deserialize a JSON object to an instance of ToolCallResult
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 90 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["message"].nil? = nil else = parsed_json["message"].to_json = Vapi::ToolCallResultMessage.from_json(json_object: ) end name = parsed_json["name"] tool_call_id = parsed_json["toolCallId"] result = parsed_json["result"] error = parsed_json["error"] = parsed_json["metadata"] new( message: , name: name, tool_call_id: tool_call_id, result: result, error: error, metadata: , 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.
128 129 130 131 132 133 134 135 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 128 def self.validate_raw(obj:) obj..nil? || Vapi::ToolCallResultMessage.validate_raw(obj: obj.) obj.name.is_a?(String) != false || raise("Passed value for field obj.name 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.result&.is_a?(String) != false || raise("Passed value for field obj.result is not the expected type, validation failed.") obj.error&.is_a?(String) != false || raise("Passed value for field obj.error 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(*_args) ⇒ String
Serialize an instance of ToolCallResult to a JSON object
118 119 120 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 118 def to_json(*_args) @_field_set&.to_json end |