Class: Vapi::ConversationNode
- Inherits:
-
Object
- Object
- Vapi::ConversationNode
- Defined in:
- lib/vapi_server_sdk/types/conversation_node.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#global_node_plan ⇒ Vapi::GlobalNodePlan
readonly
This is the plan for the global node.
-
#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.
-
#model ⇒ Vapi::ConversationNodeModel
readonly
This is the model for the node.
- #name ⇒ String readonly
- #prompt ⇒ String readonly
-
#transcriber ⇒ Vapi::ConversationNodeTranscriber
readonly
This is the transcriber for the node.
-
#variable_extraction_plan ⇒ Vapi::VariableExtractionPlan
readonly
This is the plan that controls the variable extraction from the user’s responses.
-
#voice ⇒ Vapi::ConversationNodeVoice
readonly
This is the voice for the node.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ConversationNode
Deserialize a JSON object to an instance of ConversationNode.
-
.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:, model: OMIT, transcriber: OMIT, voice: OMIT, prompt: OMIT, global_node_plan: OMIT, variable_extraction_plan: OMIT, is_start: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Vapi::ConversationNode constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ConversationNode to a JSON object.
Constructor Details
#initialize(name:, model: OMIT, transcriber: OMIT, voice: OMIT, prompt: OMIT, global_node_plan: OMIT, variable_extraction_plan: OMIT, is_start: OMIT, metadata: OMIT, additional_properties: nil) ⇒ Vapi::ConversationNode
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 140 def initialize(name:, model: OMIT, transcriber: OMIT, voice: OMIT, prompt: OMIT, global_node_plan: OMIT, variable_extraction_plan: OMIT, is_start: OMIT, metadata: OMIT, additional_properties: nil) @model = model if model != OMIT @transcriber = transcriber if transcriber != OMIT @voice = voice if voice != OMIT @prompt = prompt if prompt != OMIT @global_node_plan = global_node_plan if global_node_plan != OMIT @variable_extraction_plan = variable_extraction_plan if variable_extraction_plan != OMIT @name = name @is_start = is_start if is_start != OMIT @metadata = if != OMIT @additional_properties = additional_properties @_field_set = { "model": model, "transcriber": transcriber, "voice": voice, "prompt": prompt, "globalNodePlan": global_node_plan, "variableExtractionPlan": variable_extraction_plan, "name": name, "isStart": is_start, "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.
77 78 79 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 77 def additional_properties @additional_properties end |
#global_node_plan ⇒ Vapi::GlobalNodePlan (readonly)
Returns This is the plan for the global node.
25 26 27 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 25 def global_node_plan @global_node_plan end |
#is_start ⇒ Boolean (readonly)
Returns This is whether or not the node is the start of the workflow.
73 74 75 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 73 def is_start @is_start end |
#metadata ⇒ Hash{String => Object} (readonly)
Returns This is for metadata you want to store on the task.
75 76 77 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 75 def @metadata end |
#model ⇒ Vapi::ConversationNodeModel (readonly)
Returns This is the model for the node. This overrides ‘workflow.model`.
15 16 17 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 15 def model @model end |
#name ⇒ String (readonly)
71 72 73 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 71 def name @name end |
#prompt ⇒ String (readonly)
23 24 25 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 23 def prompt @prompt end |
#transcriber ⇒ Vapi::ConversationNodeTranscriber (readonly)
Returns This is the transcriber for the node. This overrides ‘workflow.transcriber`.
18 19 20 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 18 def transcriber @transcriber end |
#variable_extraction_plan ⇒ Vapi::VariableExtractionPlan (readonly)
Returns This is the plan that controls the variable extraction from the user’s responses. Usage: Use ‘schema` to specify what you want to extract from the user’s responses. “‘json { “schema”: { “type”: “object”, “properties”: { “user”: { “type”: “object”, “properties”: { “name”: { “type”: “string” }, “age”: { “type”: “number” } } } } } } “` This will be extracted as `user.name }` and `user.age }` respectively. (Optional) Use `aliases` to create new variables. “`json { “aliases”: [ { “key”: “userAge”, “value”: “Vapi::ConversationNode.{user{user.age}” }, { “key”: “userName”, “value”: “Vapi::ConversationNode.{user{user.name}” } ] } “` This will be extracted as `userAge }` and `userName }` respectively. Note: The `schema` field is required for Conversation nodes if you want to extract variables from the user’s responses. ‘aliases` is just a convenience.
69 70 71 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 69 def variable_extraction_plan @variable_extraction_plan end |
#voice ⇒ Vapi::ConversationNodeVoice (readonly)
Returns This is the voice for the node. This overrides ‘workflow.voice`.
21 22 23 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 21 def voice @voice end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ConversationNode
Deserialize a JSON object to an instance of ConversationNode
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 171 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["model"].nil? model = nil else model = parsed_json["model"].to_json model = Vapi::ConversationNodeModel.from_json(json_object: model) end if parsed_json["transcriber"].nil? transcriber = nil else transcriber = parsed_json["transcriber"].to_json transcriber = Vapi::ConversationNodeTranscriber.from_json(json_object: transcriber) end if parsed_json["voice"].nil? voice = nil else voice = parsed_json["voice"].to_json voice = Vapi::ConversationNodeVoice.from_json(json_object: voice) end prompt = parsed_json["prompt"] if parsed_json["globalNodePlan"].nil? global_node_plan = nil else global_node_plan = parsed_json["globalNodePlan"].to_json global_node_plan = Vapi::GlobalNodePlan.from_json(json_object: global_node_plan) end if parsed_json["variableExtractionPlan"].nil? variable_extraction_plan = nil else variable_extraction_plan = parsed_json["variableExtractionPlan"].to_json variable_extraction_plan = Vapi::VariableExtractionPlan.from_json(json_object: variable_extraction_plan) end name = parsed_json["name"] is_start = parsed_json["isStart"] = parsed_json["metadata"] new( model: model, transcriber: transcriber, voice: voice, prompt: prompt, global_node_plan: global_node_plan, variable_extraction_plan: variable_extraction_plan, 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.
235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 235 def self.validate_raw(obj:) obj.model.nil? || Vapi::ConversationNodeModel.validate_raw(obj: obj.model) obj.transcriber.nil? || Vapi::ConversationNodeTranscriber.validate_raw(obj: obj.transcriber) obj.voice.nil? || Vapi::ConversationNodeVoice.validate_raw(obj: obj.voice) obj.prompt&.is_a?(String) != false || raise("Passed value for field obj.prompt is not the expected type, validation failed.") obj.global_node_plan.nil? || Vapi::GlobalNodePlan.validate_raw(obj: obj.global_node_plan) obj.variable_extraction_plan.nil? || Vapi::VariableExtractionPlan.validate_raw(obj: obj.variable_extraction_plan) 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 ConversationNode to a JSON object
225 226 227 |
# File 'lib/vapi_server_sdk/types/conversation_node.rb', line 225 def to_json(*_args) @_field_set&.to_json end |