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:, 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:

  • 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



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

def initialize(voice_id:, persona_id: OMIT, callback_url: OMIT, conversation_name: OMIT,
               conversational_context: OMIT, custom_greeting: OMIT, properties: OMIT, chunk_plan: OMIT, additional_properties: nil)
  @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 = {
    "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



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

def additional_properties
  @additional_properties
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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

def persona_id
  @persona_id
end

#propertiesVapi::TavusConversationProperties (readonly)

Returns These are optional properties used to customize the conversation.

Returns:



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

def properties
  @properties
end

#voice_idVapi::FallbackTavusVoiceVoiceId (readonly)

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

Returns:



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

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:



84
85
86
87
88
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
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 84

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  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(
    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)


136
137
138
139
140
141
142
143
144
145
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 136

def self.validate_raw(obj:)
  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)


126
127
128
# File 'lib/vapi_server_sdk/types/fallback_tavus_voice.rb', line 126

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