Class: Vapi::ChunkPlan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled: OMIT, min_characters: OMIT, punctuation_boundaries: OMIT, format_plan: OMIT, additional_properties: nil) ⇒ Vapi::ChunkPlan

Parameters:

  • enabled (Boolean) (defaults to: OMIT)

    This determines whether the model output is chunked before being sent to the voice provider. Default ‘true`. Usage:

    • To rely on the voice provider’s audio generation logic, set this to ‘false`.

    • If seeing issues with quality, set this to ‘true`.

    If disabled, Vapi-provided audio control tokens like <flush /> will not work. @default true

  • min_characters (Float) (defaults to: OMIT)

    This is the minimum number of characters in a chunk. Usage:

    • To increase quality, set this to a higher value.

    • To decrease latency, set this to a lower value.

    @default 30

  • punctuation_boundaries (Array<Vapi::PunctuationBoundary>) (defaults to: OMIT)

    These are the punctuations that are considered valid boundaries for a chunk to be created. Usage:

    • To increase quality, constrain to fewer boundaries.

    • To decrease latency, enable all.

    Default is automatically set to balance the trade-off between quality and latency based on the provider.

  • format_plan (Vapi::FormatPlan) (defaults to: OMIT)

    This is the plan for formatting the chunk before it is sent to the voice provider.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/vapi_server_sdk/types/chunk_plan.rb', line 66

def initialize(enabled: OMIT, min_characters: OMIT, punctuation_boundaries: OMIT, format_plan: OMIT,
               additional_properties: nil)
  @enabled = enabled if enabled != OMIT
  @min_characters = min_characters if min_characters != OMIT
  @punctuation_boundaries = punctuation_boundaries if punctuation_boundaries != OMIT
  @format_plan = format_plan if format_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "enabled": enabled,
    "minCharacters": min_characters,
    "punctuationBoundaries": punctuation_boundaries,
    "formatPlan": format_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



36
37
38
# File 'lib/vapi_server_sdk/types/chunk_plan.rb', line 36

def additional_properties
  @additional_properties
end

#enabledBoolean (readonly)

Returns This determines whether the model output is chunked before being sent to the voice provider. Default ‘true`. Usage:

  • To rely on the voice provider’s audio generation logic, set this to ‘false`.

  • If seeing issues with quality, set this to ‘true`.

If disabled, Vapi-provided audio control tokens like <flush /> will not work. @default true.

Returns:

  • (Boolean)

    This determines whether the model output is chunked before being sent to the voice provider. Default ‘true`. Usage:

    • To rely on the voice provider’s audio generation logic, set this to ‘false`.

    • If seeing issues with quality, set this to ‘true`.

    If disabled, Vapi-provided audio control tokens like <flush /> will not work. @default true



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

def enabled
  @enabled
end

#format_planVapi::FormatPlan (readonly)

Returns This is the plan for formatting the chunk before it is sent to the voice provider.

Returns:

  • (Vapi::FormatPlan)

    This is the plan for formatting the chunk before it is sent to the voice provider.



34
35
36
# File 'lib/vapi_server_sdk/types/chunk_plan.rb', line 34

def format_plan
  @format_plan
end

#min_charactersFloat (readonly)

Returns This is the minimum number of characters in a chunk. Usage:

  • To increase quality, set this to a higher value.

  • To decrease latency, set this to a lower value.

@default 30.

Returns:

  • (Float)

    This is the minimum number of characters in a chunk. Usage:

    • To increase quality, set this to a higher value.

    • To decrease latency, set this to a lower value.

    @default 30



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

def min_characters
  @min_characters
end

#punctuation_boundariesArray<Vapi::PunctuationBoundary> (readonly)

Returns These are the punctuations that are considered valid boundaries for a chunk to be created. Usage:

  • To increase quality, constrain to fewer boundaries.

  • To decrease latency, enable all.

Default is automatically set to balance the trade-off between quality and latency based on the provider.

Returns:

  • (Array<Vapi::PunctuationBoundary>)

    These are the punctuations that are considered valid boundaries for a chunk to be created. Usage:

    • To increase quality, constrain to fewer boundaries.

    • To decrease latency, enable all.

    Default is automatically set to balance the trade-off between quality and latency based on the provider.



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

def punctuation_boundaries
  @punctuation_boundaries
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ChunkPlan

Deserialize a JSON object to an instance of ChunkPlan

Parameters:

  • json_object (String)

Returns:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/vapi_server_sdk/types/chunk_plan.rb', line 87

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  enabled = parsed_json["enabled"]
  min_characters = parsed_json["minCharacters"]
  punctuation_boundaries = parsed_json["punctuationBoundaries"]
  if parsed_json["formatPlan"].nil?
    format_plan = nil
  else
    format_plan = parsed_json["formatPlan"].to_json
    format_plan = Vapi::FormatPlan.from_json(json_object: format_plan)
  end
  new(
    enabled: enabled,
    min_characters: min_characters,
    punctuation_boundaries: punctuation_boundaries,
    format_plan: format_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)


121
122
123
124
125
126
# File 'lib/vapi_server_sdk/types/chunk_plan.rb', line 121

def self.validate_raw(obj:)
  obj.enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.enabled is not the expected type, validation failed.")
  obj.min_characters&.is_a?(Float) != false || raise("Passed value for field obj.min_characters is not the expected type, validation failed.")
  obj.punctuation_boundaries&.is_a?(Array) != false || raise("Passed value for field obj.punctuation_boundaries is not the expected type, validation failed.")
  obj.format_plan.nil? || Vapi::FormatPlan.validate_raw(obj: obj.format_plan)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ChunkPlan to a JSON object

Returns:

  • (String)


111
112
113
# File 'lib/vapi_server_sdk/types/chunk_plan.rb', line 111

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