Class: Vapi::FallbackTavusVoice

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/fallback_tavus_voice.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(voice_id:, caching_enabled: OMIT, persona_id: OMIT, callback_url: OMIT, conversation_name: OMIT, conversational_context: OMIT, custom_greeting: OMIT, properties: OMIT, chunk_plan: OMIT, additional_properties: nil) ⇒ Vapi::FallbackTavusVoice

Parameters:

  • caching_enabled (Boolean) (defaults to: OMIT)

    This is the flag to toggle voice caching for the assistant.

  • voice_id (Vapi::FallbackTavusVoiceVoiceId)

    This is the provider-specific ID that will be used.

  • persona_id (String) (defaults to: OMIT)

    This is the unique identifier for the persona that the replica will use in the conversation.

  • callback_url (String) (defaults to: OMIT)

    This is the url that will receive webhooks with updates regarding the conversation state.

  • conversation_name (String) (defaults to: OMIT)

    This is the name for the conversation.

  • conversational_context (String) (defaults to: OMIT)

    This is the context that will be appended to any context provided in the persona, if one is provided.

  • custom_greeting (String) (defaults to: OMIT)

    This is the custom greeting that the replica will give once a participant joines the conversation.

  • properties (Vapi::TavusConversationProperties) (defaults to: OMIT)

    These are optional properties used to customize the conversation.

  • chunk_plan (Vapi::ChunkPlan) (defaults to: OMIT)

    This is the plan for chunking the model output before it is sent to the voice provider.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 58

def initialize(voice_id:, caching_enabled: OMIT, persona_id: OMIT, callback_url: OMIT, conversation_name: OMIT,
               conversational_context: OMIT, custom_greeting: OMIT, properties: OMIT, chunk_plan: OMIT, additional_properties: nil)
  @caching_enabled = caching_enabled if caching_enabled != OMIT
  @voice_id = voice_id
  @persona_id = persona_id if persona_id != OMIT
  @callback_url = callback_url if callback_url != OMIT
  @conversation_name = conversation_name if conversation_name != OMIT
  @conversational_context = conversational_context if conversational_context != OMIT
  @custom_greeting = custom_greeting if custom_greeting != OMIT
  @properties = properties if properties != OMIT
  @chunk_plan = chunk_plan if chunk_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "cachingEnabled": caching_enabled,
    "voiceId": voice_id,
    "personaId": persona_id,
    "callbackUrl": callback_url,
    "conversationName": conversation_name,
    "conversationalContext": conversational_context,
    "customGreeting": custom_greeting,
    "properties": properties,
    "chunkPlan": chunk_plan
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



35
36
37
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 35

def additional_properties
  @additional_properties
end

#caching_enabledBoolean (readonly)

Returns This is the flag to toggle voice caching for the assistant.

Returns:

  • (Boolean)

    This is the flag to toggle voice caching for the assistant.



12
13
14
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 12

def caching_enabled
  @caching_enabled
end

#callback_urlString (readonly)

Returns This is the url that will receive webhooks with updates regarding the conversation state.

Returns:

  • (String)

    This is the url that will receive webhooks with updates regarding the conversation state.



20
21
22
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 20

def callback_url
  @callback_url
end

#chunk_planVapi::ChunkPlan (readonly)

Returns This is the plan for chunking the model output before it is sent to the voice provider.

Returns:

  • (Vapi::ChunkPlan)

    This is the plan for chunking the model output before it is sent to the voice provider.



33
34
35
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 33

def chunk_plan
  @chunk_plan
end

#conversation_nameString (readonly)

Returns This is the name for the conversation.

Returns:

  • (String)

    This is the name for the conversation.



22
23
24
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 22

def conversation_name
  @conversation_name
end

#conversational_contextString (readonly)

Returns This is the context that will be appended to any context provided in the persona, if one is provided.

Returns:

  • (String)

    This is the context that will be appended to any context provided in the persona, if one is provided.



25
26
27
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 25

def conversational_context
  @conversational_context
end

#custom_greetingString (readonly)

Returns This is the custom greeting that the replica will give once a participant joines the conversation.

Returns:

  • (String)

    This is the custom greeting that the replica will give once a participant joines the conversation.



28
29
30
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 28

def custom_greeting
  @custom_greeting
end

#persona_idString (readonly)

Returns This is the unique identifier for the persona that the replica will use in the conversation.

Returns:

  • (String)

    This is the unique identifier for the persona that the replica will use in the conversation.



17
18
19
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 17

def persona_id
  @persona_id
end

#propertiesVapi::TavusConversationProperties (readonly)

Returns These are optional properties used to customize the conversation.

Returns:



30
31
32
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 30

def properties
  @properties
end

#voice_idVapi::FallbackTavusVoiceVoiceId (readonly)

Returns This is the provider-specific ID that will be used.

Returns:



14
15
16
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 14

def voice_id
  @voice_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::FallbackTavusVoice

Deserialize a JSON object to an instance of FallbackTavusVoice

Parameters:

  • json_object (String)

Returns:



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 89

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  caching_enabled = parsed_json["cachingEnabled"]
  if parsed_json["voiceId"].nil?
    voice_id = nil
  else
    voice_id = parsed_json["voiceId"].to_json
    voice_id = Vapi::FallbackTavusVoiceVoiceId.from_json(json_object: voice_id)
  end
  persona_id = parsed_json["personaId"]
  callback_url = parsed_json["callbackUrl"]
  conversation_name = parsed_json["conversationName"]
  conversational_context = parsed_json["conversationalContext"]
  custom_greeting = parsed_json["customGreeting"]
  if parsed_json["properties"].nil?
    properties = nil
  else
    properties = parsed_json["properties"].to_json
    properties = Vapi::TavusConversationProperties.from_json(json_object: properties)
  end
  if parsed_json["chunkPlan"].nil?
    chunk_plan = nil
  else
    chunk_plan = parsed_json["chunkPlan"].to_json
    chunk_plan = Vapi::ChunkPlan.from_json(json_object: chunk_plan)
  end
  new(
    caching_enabled: caching_enabled,
    voice_id: voice_id,
    persona_id: persona_id,
    callback_url: callback_url,
    conversation_name: conversation_name,
    conversational_context: conversational_context,
    custom_greeting: custom_greeting,
    properties: properties,
    chunk_plan: chunk_plan,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


143
144
145
146
147
148
149
150
151
152
153
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 143

def self.validate_raw(obj:)
  obj.caching_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.caching_enabled is not the expected type, validation failed.")
  Vapi::FallbackTavusVoiceVoiceId.validate_raw(obj: obj.voice_id)
  obj.persona_id&.is_a?(String) != false || raise("Passed value for field obj.persona_id is not the expected type, validation failed.")
  obj.callback_url&.is_a?(String) != false || raise("Passed value for field obj.callback_url is not the expected type, validation failed.")
  obj.conversation_name&.is_a?(String) != false || raise("Passed value for field obj.conversation_name is not the expected type, validation failed.")
  obj.conversational_context&.is_a?(String) != false || raise("Passed value for field obj.conversational_context is not the expected type, validation failed.")
  obj.custom_greeting&.is_a?(String) != false || raise("Passed value for field obj.custom_greeting is not the expected type, validation failed.")
  obj.properties.nil? || Vapi::TavusConversationProperties.validate_raw(obj: obj.properties)
  obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of FallbackTavusVoice to a JSON object

Returns:

  • (String)


133
134
135
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 133

def to_json(*_args)
  @_field_set&.to_json
end