Class: Vapi::ToolCall
- Inherits:
-
Object
- Object
- Vapi::ToolCall
- Defined in:
- lib/vapi_server_sdk/types/tool_call.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#function ⇒ Vapi::ToolCallFunction
readonly
This is the function the model called.
-
#id ⇒ String
readonly
This is the unique identifier for the tool call.
-
#type ⇒ String
readonly
This is the type of tool the model called.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ToolCall
Deserialize a JSON object to an instance of ToolCall.
-
.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(type:, function:, id:, additional_properties: nil) ⇒ Vapi::ToolCall constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ToolCall to a JSON object.
Constructor Details
#initialize(type:, function:, id:, additional_properties: nil) ⇒ Vapi::ToolCall
28 29 30 31 32 33 34 |
# File 'lib/vapi_server_sdk/types/tool_call.rb', line 28 def initialize(type:, function:, id:, additional_properties: nil) @type = type @function = function @id = id @additional_properties = additional_properties @_field_set = { "type": type, "function": function, "id": id } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
16 17 18 |
# File 'lib/vapi_server_sdk/types/tool_call.rb', line 16 def additional_properties @additional_properties end |
#function ⇒ Vapi::ToolCallFunction (readonly)
Returns This is the function the model called.
12 13 14 |
# File 'lib/vapi_server_sdk/types/tool_call.rb', line 12 def function @function end |
#id ⇒ String (readonly)
Returns This is the unique identifier for the tool call.
14 15 16 |
# File 'lib/vapi_server_sdk/types/tool_call.rb', line 14 def id @id end |
#type ⇒ String (readonly)
Returns This is the type of tool the model called.
10 11 12 |
# File 'lib/vapi_server_sdk/types/tool_call.rb', line 10 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ToolCall
Deserialize a JSON object to an instance of ToolCall
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vapi_server_sdk/types/tool_call.rb', line 40 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) type = parsed_json["type"] if parsed_json["function"].nil? function = nil else function = parsed_json["function"].to_json function = Vapi::ToolCallFunction.from_json(json_object: function) end id = parsed_json["id"] new( type: type, function: function, id: id, 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.
72 73 74 75 76 |
# File 'lib/vapi_server_sdk/types/tool_call.rb', line 72 def self.validate_raw(obj:) obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") Vapi::ToolCallFunction.validate_raw(obj: obj.function) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ToolCall to a JSON object
62 63 64 |
# File 'lib/vapi_server_sdk/types/tool_call.rb', line 62 def to_json(*_args) @_field_set&.to_json end |