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 ⇒ Array<Vapi::ToolCallResultMessageItem>
readonly
This is the message that will be spoken to the user.
-
#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, 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, additional_properties: nil) ⇒ Vapi::ToolCallResult
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 62 def initialize(name:, tool_call_id:, message: OMIT, result: OMIT, error: 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 @additional_properties = additional_properties @_field_set = { "message": , "name": name, "toolCallId": tool_call_id, "result": result, "error": error }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
34 35 36 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 34 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 ⇒ Array<Vapi::ToolCallResultMessageItem> (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 |
#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
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 84 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) = parsed_json["message"]&.map do |item| item = item.to_json Vapi::ToolCallResultMessageItem.from_json(json_object: item) end name = parsed_json["name"] tool_call_id = parsed_json["toolCallId"] result = parsed_json["result"] error = parsed_json["error"] new( message: , name: name, tool_call_id: tool_call_id, result: result, error: error, 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.
118 119 120 121 122 123 124 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 118 def self.validate_raw(obj:) obj.&.is_a?(Array) != false || raise("Passed value for field obj.message 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.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.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ToolCallResult to a JSON object
108 109 110 |
# File 'lib/vapi_server_sdk/types/tool_call_result.rb', line 108 def to_json(*_args) @_field_set&.to_json end |