Class: Vapi::ToolNode
- Inherits:
-
Object
- Object
- Vapi::ToolNode
- Defined in:
- lib/vapi_server_sdk/types/tool_node.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#is_start ⇒ Boolean
readonly
This is whether or not the node is the start of the workflow.
-
#metadata ⇒ Hash{String => Object}
readonly
This is for metadata you want to store on the task.
- #name ⇒ String readonly
-
#tool ⇒ Vapi::ToolNodeTool
readonly
This is the tool to call.
-
#tool_id ⇒ String
readonly
This is the tool to call.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ToolNode
Deserialize a JSON object to an instance of ToolNode.
-
.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: OMIT, tool_id: OMIT, is_start: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Vapi::ToolNode constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ToolNode to a JSON object.
Constructor Details
#initialize(name:, tool: OMIT, tool_id: OMIT, is_start: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Vapi::ToolNode
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 34 def initialize(name:, tool: OMIT, tool_id: OMIT, is_start: OMIT, metadata: OMIT, additional_properties: nil) @tool = tool if tool != OMIT @tool_id = tool_id if tool_id != OMIT @name = name @is_start = is_start if is_start != OMIT @metadata = if != OMIT @additional_properties = additional_properties @_field_set = { "tool": tool, "toolId": tool_id, "name": name, "isStart": is_start, "metadata": }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
20 21 22 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 20 def additional_properties @additional_properties end |
#is_start ⇒ Boolean (readonly)
16 17 18 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 16 def is_start @is_start end |
#metadata ⇒ Hash{String => Object} (readonly)
18 19 20 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 18 def @metadata end |
#name ⇒ String (readonly)
14 15 16 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 14 def name @name end |
#tool ⇒ Vapi::ToolNodeTool (readonly)
10 11 12 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 10 def tool @tool end |
#tool_id ⇒ String (readonly)
12 13 14 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 12 def tool_id @tool_id end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ToolNode
Deserialize a JSON object to an instance of ToolNode
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 56 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["tool"].nil? tool = nil else tool = parsed_json["tool"].to_json tool = Vapi::ToolNodeTool.from_json(json_object: tool) end tool_id = parsed_json["toolId"] name = parsed_json["name"] is_start = parsed_json["isStart"] = parsed_json["metadata"] new( tool: tool, tool_id: tool_id, name: name, is_start: is_start, 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.
92 93 94 95 96 97 98 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 92 def self.validate_raw(obj:) obj.tool.nil? || Vapi::ToolNodeTool.validate_raw(obj: obj.tool) obj.tool_id&.is_a?(String) != false || raise("Passed value for field obj.tool_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.is_start&.is_a?(Boolean) != false || raise("Passed value for field obj.is_start 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 ToolNode to a JSON object
82 83 84 |
# File 'lib/vapi_server_sdk/types/tool_node.rb', line 82 def to_json(*_args) @_field_set&.to_json end |