Class: Vapi::ToolMessageComplete
- Inherits:
-
Object
- Object
- Vapi::ToolMessageComplete
- Defined in:
- lib/vapi_server_sdk/types/tool_message_complete.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#conditions ⇒ Array<Vapi::Condition>
readonly
This is an optional array of conditions that the tool call arguments must meet in order for this message to be triggered.
-
#content ⇒ String
readonly
This is the content that the assistant says when this message is triggered.
-
#end_call_after_spoken_enabled ⇒ Boolean
readonly
This is an optional boolean that if true, the call will end after the message is spoken.
-
#role ⇒ Vapi::ToolMessageCompleteRole
readonly
This is optional and defaults to “assistant”.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ToolMessageComplete
Deserialize a JSON object to an instance of ToolMessageComplete.
-
.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(content:, role: OMIT, end_call_after_spoken_enabled: OMIT, conditions: OMIT, additional_properties: nil) ⇒ Vapi::ToolMessageComplete constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ToolMessageComplete to a JSON object.
Constructor Details
#initialize(content:, role: OMIT, end_call_after_spoken_enabled: OMIT, conditions: OMIT, additional_properties: nil) ⇒ Vapi::ToolMessageComplete
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 70 def initialize(content:, role: OMIT, end_call_after_spoken_enabled: OMIT, conditions: OMIT, additional_properties: nil) @role = role if role != OMIT @end_call_after_spoken_enabled = end_call_after_spoken_enabled if end_call_after_spoken_enabled != OMIT @content = content @conditions = conditions if conditions != OMIT @additional_properties = additional_properties @_field_set = { "role": role, "endCallAfterSpokenEnabled": end_call_after_spoken_enabled, "content": content, "conditions": conditions }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
38 39 40 |
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 38 def additional_properties @additional_properties end |
#conditions ⇒ Array<Vapi::Condition> (readonly)
Returns This is an optional array of conditions that the tool call arguments must meet in order for this message to be triggered.
36 37 38 |
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 36 def conditions @conditions end |
#content ⇒ String (readonly)
Returns This is the content that the assistant says when this message is triggered.
33 34 35 |
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 33 def content @content end |
#end_call_after_spoken_enabled ⇒ Boolean (readonly)
Returns This is an optional boolean that if true, the call will end after the message is spoken. Default is false. This is ignored if ‘role` is set to `system`. @default false.
31 32 33 |
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 31 def end_call_after_spoken_enabled @end_call_after_spoken_enabled end |
#role ⇒ Vapi::ToolMessageCompleteRole (readonly)
Returns This is optional and defaults to “assistant”. When role=assistant, ‘content` is said out loud. When role=system, `content` is passed to the model in a system message. Example: system: default one assistant: user: assistant: user: assistant: user: assistant: tool called tool: your server response <— system prompt as hint —> model generates response which is spoken This is useful when you want to provide a hint to the model about what to say next.
26 27 28 |
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 26 def role @role end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ToolMessageComplete
Deserialize a JSON object to an instance of ToolMessageComplete
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 91 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) role = parsed_json["role"] end_call_after_spoken_enabled = parsed_json["endCallAfterSpokenEnabled"] content = parsed_json["content"] conditions = parsed_json["conditions"]&.map do |item| item = item.to_json Vapi::Condition.from_json(json_object: item) end new( role: role, end_call_after_spoken_enabled: end_call_after_spoken_enabled, content: content, conditions: conditions, 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.
123 124 125 126 127 128 |
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 123 def self.validate_raw(obj:) obj.role&.is_a?(Vapi::ToolMessageCompleteRole) != false || raise("Passed value for field obj.role is not the expected type, validation failed.") obj.end_call_after_spoken_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.end_call_after_spoken_enabled is not the expected type, validation failed.") obj.content.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ToolMessageComplete to a JSON object
113 114 115 |
# File 'lib/vapi_server_sdk/types/tool_message_complete.rb', line 113 def to_json(*_args) @_field_set&.to_json end |