Class: Vapi::CallbackStep
- Inherits:
-
Object
- Object
- Vapi::CallbackStep
- Defined in:
- lib/vapi_server_sdk/types/callback_step.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#block ⇒ Vapi::CallbackStepBlock
readonly
This is the block to use.
-
#block_id ⇒ String
readonly
This is the id of the block to use.
-
#input ⇒ Hash{String => Object}
readonly
This is the input to the block.
-
#mutations ⇒ Array<Vapi::AssignmentMutation>
readonly
This is the mutations to apply to the context after the step is done.
-
#name ⇒ String
readonly
This is the name of the step.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::CallbackStep
Deserialize a JSON object to an instance of CallbackStep.
-
.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:, block: OMIT, mutations: OMIT, block_id: OMIT, input: OMIT, additional_properties: nil) ⇒ Vapi::CallbackStep constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CallbackStep to a JSON object.
Constructor Details
#initialize(name:, block: OMIT, mutations: OMIT, block_id: OMIT, input: OMIT, additional_properties: nil) ⇒ Vapi::CallbackStep
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 135 def initialize(name:, block: OMIT, mutations: OMIT, block_id: OMIT, input: OMIT, additional_properties: nil) @block = block if block != OMIT @mutations = mutations if mutations != OMIT @name = name @block_id = block_id if block_id != OMIT @input = input if input != OMIT @additional_properties = additional_properties @_field_set = { "block": block, "mutations": mutations, "name": name, "blockId": block_id, "input": input }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
71 72 73 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 71 def additional_properties @additional_properties end |
#block ⇒ Vapi::CallbackStepBlock (readonly)
Returns This is the block to use. To use an existing block, use ‘blockId`.
11 12 13 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 11 def block @block end |
#block_id ⇒ String (readonly)
Returns This is the id of the block to use. To use a transient block, use ‘block`.
17 18 19 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 17 def block_id @block_id end |
#input ⇒ Hash{String => Object} (readonly)
Returns This is the input to the block. You can use any key-value map as input to the block. Example: { “name”: “John Doe”, “age”: 20 } You can reference any variable in the context of the current block:
-
“Vapi::CallbackStep.{your-step-name{your-step-name.output{your-step-name.output.your-property-name}” for another step’s output (in
the same workflow; read caveat #1)
-
“Vapi::CallbackStep.{your-step-name{your-step-name.input{your-step-name.input.your-property-name}” for another step’s input (in the
same workflow; read caveat #1)
-
“Vapi::CallbackStep.{your-block-name{your-block-name.output{your-block-name.output.your-property-name}” for another block’s output (in
the same workflow; read caveat #2)
-
“Vapi::CallbackStep.{your-block-name{your-block-name.input{your-block-name.input.your-property-name}” for another block’s input (in
the same workflow; read caveat #2)
-
“Vapi::CallbackStep.{workflow{workflow.input{workflow.input.your-property-name}” for the current workflow’s input
-
“Vapi::CallbackStep.{global{global.your-property-name}” for the global context
Example: { “name”: “Vapi::CallbackStep.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.name}”, “age”: “Vapi::CallbackStep.{my-tool-call-step{my-tool-call-step.input{my-tool-call-step.input.age}”, “date”: “Vapi::CallbackStep.{workflow{workflow.input{workflow.input.date}” } You can dynamically change the key name. Example: { “Vapi::CallbackStep.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.key-name-for-name}”: “{name}”, “Vapi::CallbackStep.{my-tool-call-step{my-tool-call-step.input{my-tool-call-step.input.key-name-for-age}”: “{age}”, “Vapi::CallbackStep.{workflow{workflow.input{workflow.input.key-name-for-date}”: “{date}” } You can represent the value as a string, number, boolean, array, or object. Example: { “name”: “john”, “age”: 20, “date”: “2021-01-01”, “metadata”: { “unique-key”: “Vapi::CallbackStep.{my-tool-call-step{my-tool-call-step.output{my-tool-call-step.output.unique-key}” }, “array”: [“A”, “B”, “C”], } Caveats:
-
a workflow can execute a step multiple times. example, if a loop is used in
the graph. Vapi::CallbackStep.{stepName{stepName.input/output{stepName.input/output.propertyName} will reference the latest usage of the step.
-
a workflow can execute a block multiple times. example, if a step is called
multiple times or if a block is used in multiple steps. Vapi::CallbackStep.{blockName{blockName.input/output{blockName.input/output.propertyName} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow.
69 70 71 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 69 def input @input end |
#mutations ⇒ Array<Vapi::AssignmentMutation> (readonly)
Returns This is the mutations to apply to the context after the step is done.
13 14 15 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 13 def mutations @mutations end |
#name ⇒ String (readonly)
Returns This is the name of the step.
15 16 17 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 15 def name @name end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::CallbackStep
Deserialize a JSON object to an instance of CallbackStep
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 157 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["block"].nil? block = nil else block = parsed_json["block"].to_json block = Vapi::CallbackStepBlock.from_json(json_object: block) end mutations = parsed_json["mutations"]&.map do |item| item = item.to_json Vapi::AssignmentMutation.from_json(json_object: item) end name = parsed_json["name"] block_id = parsed_json["blockId"] input = parsed_json["input"] new( block: block, mutations: mutations, name: name, block_id: block_id, input: input, 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.
196 197 198 199 200 201 202 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 196 def self.validate_raw(obj:) obj.block.nil? || Vapi::CallbackStepBlock.validate_raw(obj: obj.block) obj.mutations&.is_a?(Array) != false || raise("Passed value for field obj.mutations 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.block_id&.is_a?(String) != false || raise("Passed value for field obj.block_id is not the expected type, validation failed.") obj.input&.is_a?(Hash) != false || raise("Passed value for field obj.input is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CallbackStep to a JSON object
186 187 188 |
# File 'lib/vapi_server_sdk/types/callback_step.rb', line 186 def to_json(*_args) @_field_set&.to_json end |