Class: Vapi::LivekitSmartEndpointingPlan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider:, wait_function: OMIT, additional_properties: nil) ⇒ Vapi::LivekitSmartEndpointingPlan

Parameters:

  • provider (Vapi::LivekitSmartEndpointingPlanProvider)

    This is the provider for the smart endpointing plan.

  • wait_function (String) (defaults to: OMIT)

    This expression describes how long the bot will wait to start speaking based on the likelihood that the user has reached an endpoint. This is a millisecond valued function. It maps probabilities (real numbers on [0,1]) to milliseconds that the bot should wait before speaking ([0, infty]). Any negative values that are returned are set to zero (the bot can’t start talking in the past). A probability of zero represents very high confidence that the caller has stopped speaking, and would like the bot to speak to them. A probability of one represents very high confidence that the caller is still speaking. Under the hood, this is parsed into a mathjs expression. Whatever you use to write your expression needs to be valid with respect to mathjs @default “20 + 500 * sqrt(x) + 2500 * x^3”

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



47
48
49
50
51
52
53
54
# File 'lib/vapi_server_sdk/types/livekit_smart_endpointing_plan.rb', line 47

def initialize(provider:, wait_function: OMIT, additional_properties: nil)
  @provider = provider
  @wait_function = wait_function if wait_function != OMIT
  @additional_properties = additional_properties
  @_field_set = { "provider": provider, "waitFunction": wait_function }.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



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

def additional_properties
  @additional_properties
end

#providerVapi::LivekitSmartEndpointingPlanProvider (readonly)

Returns This is the provider for the smart endpointing plan.

Returns:



10
11
12
# File 'lib/vapi_server_sdk/types/livekit_smart_endpointing_plan.rb', line 10

def provider
  @provider
end

#wait_functionString (readonly)

Returns This expression describes how long the bot will wait to start speaking based on the likelihood that the user has reached an endpoint. This is a millisecond valued function. It maps probabilities (real numbers on [0,1]) to milliseconds that the bot should wait before speaking ([0, infty]). Any negative values that are returned are set to zero (the bot can’t start talking in the past). A probability of zero represents very high confidence that the caller has stopped speaking, and would like the bot to speak to them. A probability of one represents very high confidence that the caller is still speaking. Under the hood, this is parsed into a mathjs expression. Whatever you use to write your expression needs to be valid with respect to mathjs @default “20 + 500 * sqrt(x) + 2500 * x^3”.

Returns:

  • (String)

    This expression describes how long the bot will wait to start speaking based on the likelihood that the user has reached an endpoint. This is a millisecond valued function. It maps probabilities (real numbers on [0,1]) to milliseconds that the bot should wait before speaking ([0, infty]). Any negative values that are returned are set to zero (the bot can’t start talking in the past). A probability of zero represents very high confidence that the caller has stopped speaking, and would like the bot to speak to them. A probability of one represents very high confidence that the caller is still speaking. Under the hood, this is parsed into a mathjs expression. Whatever you use to write your expression needs to be valid with respect to mathjs @default “20 + 500 * sqrt(x) + 2500 * x^3”



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

def wait_function
  @wait_function
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::LivekitSmartEndpointingPlan

Deserialize a JSON object to an instance of LivekitSmartEndpointingPlan

Parameters:

  • json_object (String)

Returns:



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/vapi_server_sdk/types/livekit_smart_endpointing_plan.rb', line 60

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  provider = parsed_json["provider"]
  wait_function = parsed_json["waitFunction"]
  new(
    provider: provider,
    wait_function: wait_function,
    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)


85
86
87
88
# File 'lib/vapi_server_sdk/types/livekit_smart_endpointing_plan.rb', line 85

def self.validate_raw(obj:)
  obj.provider.is_a?(Vapi::LivekitSmartEndpointingPlanProvider) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.")
  obj.wait_function&.is_a?(String) != false || raise("Passed value for field obj.wait_function is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of LivekitSmartEndpointingPlan to a JSON object

Returns:

  • (String)


75
76
77
# File 'lib/vapi_server_sdk/types/livekit_smart_endpointing_plan.rb', line 75

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