Class: Vapi::CreateConversationBlockDto
- Inherits:
-
Object
- Object
- Vapi::CreateConversationBlockDto
- Defined in:
- lib/vapi_server_sdk/types/create_conversation_block_dto.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#input_schema ⇒ Vapi::JsonSchema
readonly
This is the input schema for the block.
-
#instruction ⇒ String
readonly
This is the instruction to the model.
-
#messages ⇒ Array<Vapi::CreateConversationBlockDtoMessagesItem>
readonly
These are the pre-configured messages that will be spoken to the user while the block is running.
-
#name ⇒ String
readonly
This is the name of the block.
-
#output_schema ⇒ Vapi::JsonSchema
readonly
This is the output schema for the block.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::CreateConversationBlockDto
Deserialize a JSON object to an instance of CreateConversationBlockDto.
-
.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(instruction:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, name: OMIT, additional_properties: nil) ⇒ Vapi::CreateConversationBlockDto constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreateConversationBlockDto to a JSON object.
Constructor Details
#initialize(instruction:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, name: OMIT, additional_properties: nil) ⇒ Vapi::CreateConversationBlockDto
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 131 def initialize(instruction:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, name: OMIT, additional_properties: nil) @messages = if != OMIT @input_schema = input_schema if input_schema != OMIT @output_schema = output_schema if output_schema != OMIT @instruction = instruction @name = name if name != OMIT @additional_properties = additional_properties @_field_set = { "messages": , "inputSchema": input_schema, "outputSchema": output_schema, "instruction": instruction, "name": name }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
69 70 71 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 69 def additional_properties @additional_properties end |
#input_schema ⇒ Vapi::JsonSchema (readonly)
Returns This is the input schema for the block. This is the input the block needs to run. It’s given to the block as ‘steps.input` These are accessible as variables:
-
(Vapi::CreateConversationBlockDto.{input{input.propertyName}) in context of the block execution (step)
-
(Vapi::CreateConversationBlockDto.{stepName{stepName.input{stepName.input.propertyName}) in context of the workflow.
18 19 20 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 18 def input_schema @input_schema end |
#instruction ⇒ String (readonly)
Returns This is the instruction to the model. You can reference any variable in the context of the current block execution (step):
-
“Vapi::CreateConversationBlockDto.{input{input.your-property-name}” for the current step’s input
-
“Vapi::CreateConversationBlockDto.{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::CreateConversationBlockDto.{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::CreateConversationBlockDto.{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::CreateConversationBlockDto.{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::CreateConversationBlockDto.{workflow{workflow.input{workflow.input.your-property-name}” for the current workflow’s input
-
“Vapi::CreateConversationBlockDto.{global{global.your-property-name}” for the global context
This can be as simple or as complex as you want it to be.
-
“say hello and ask the user about their day!”
-
“collect the user’s first and last name”
-
“user is Vapi::CreateConversationBlockDto.{input{input.firstName} Vapi::CreateConversationBlockDto.{input{input.lastName}. their age is Vapi::CreateConversationBlockDto.{input{input.age}.
ask them about their salary and if they might be interested in buying a house. we offer Vapi::CreateConversationBlockDto.{input{input.offer}“ Caveats:
-
a workflow can execute a step multiple times. example, if a loop is used in
the graph. Vapi::CreateConversationBlockDto.{stepName{stepName.output/input{stepName.output/input.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::CreateConversationBlockDto.{blockName{blockName.output/input{blockName.output/input.propertyName} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow with steps.
65 66 67 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 65 def instruction @instruction end |
#messages ⇒ Array<Vapi::CreateConversationBlockDtoMessagesItem> (readonly)
Returns These are the pre-configured messages that will be spoken to the user while the block is running.
12 13 14 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 12 def @messages end |
#name ⇒ String (readonly)
Returns This is the name of the block. This is just for your reference.
67 68 69 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 67 def name @name end |
#output_schema ⇒ Vapi::JsonSchema (readonly)
This is the output schema for the block. This is the output the block will return to the workflow (‘Vapi::CreateConversationBlockDto.{stepName{stepName.output}`). These are accessible as variables:
-
(Vapi::CreateConversationBlockDto.{output{output.propertyName}) in context of the block execution (step)
-
(Vapi::CreateConversationBlockDto.{stepName{stepName.output{stepName.output.propertyName}) in context of the workflow (read caveat #1)
-
(Vapi::CreateConversationBlockDto.{blockName{blockName.output{blockName.output.propertyName}) in context of the workflow (read caveat
#2) Caveats:
-
a workflow can execute a step multiple times. example, if a loop is used in
the graph. Vapi::CreateConversationBlockDto.{stepName{stepName.output{stepName.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::CreateConversationBlockDto.{blockName{blockName.output{blockName.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 with steps.
35 36 37 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 35 def output_schema @output_schema end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::CreateConversationBlockDto
Deserialize a JSON object to an instance of CreateConversationBlockDto
154 155 156 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 182 183 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 154 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) = parsed_json["messages"]&.map do |item| item = item.to_json Vapi::CreateConversationBlockDtoMessagesItem.from_json(json_object: item) end if parsed_json["inputSchema"].nil? input_schema = nil else input_schema = parsed_json["inputSchema"].to_json input_schema = Vapi::JsonSchema.from_json(json_object: input_schema) end if parsed_json["outputSchema"].nil? output_schema = nil else output_schema = parsed_json["outputSchema"].to_json output_schema = Vapi::JsonSchema.from_json(json_object: output_schema) end instruction = parsed_json["instruction"] name = parsed_json["name"] new( messages: , input_schema: input_schema, output_schema: output_schema, instruction: instruction, name: name, 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.
198 199 200 201 202 203 204 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 198 def self.validate_raw(obj:) obj.&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") obj.input_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.input_schema) obj.output_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.output_schema) obj.instruction.is_a?(String) != false || raise("Passed value for field obj.instruction 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.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CreateConversationBlockDto to a JSON object
188 189 190 |
# File 'lib/vapi_server_sdk/types/create_conversation_block_dto.rb', line 188 def to_json(*_args) @_field_set&.to_json end |