vapi_client/models/
chunk_plan.rs

1use serde::{Deserialize, Serialize};
2use crate::models;
3
4#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
5pub struct ChunkPlan {
6    /// This determines whether the model output is chunked before being sent to the voice provider. Default `true`.
7    /// Usage: - To rely on the voice provider's audio generation logic, set this to `false`.
8    /// - If seeing issues with quality, set this to `true`. If disabled, Vapi-provided audio control tokens like <flush /> will not work.
9    #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
10    pub enabled: Option<bool>,
11
12    /// This is the minimum number of characters in a chunk.
13    /// Usage: - To increase quality, set this to a higher value.
14    /// - To decrease latency, set this to a lower value.
15    #[serde(rename = "minCharacters", skip_serializing_if = "Option::is_none")]
16    pub min_characters: Option<f64>,
17
18    /// These are the punctuations that are considered valid boundaries for a chunk to be created.
19    /// Usage: - To increase quality, constrain to fewer boundaries.
20    /// - To decrease latency, enable all. Default is automatically set to balance the trade-off between quality and latency based on the provider.
21    #[serde(rename = "punctuationBoundaries", skip_serializing_if = "Option::is_none")]
22    pub punctuation_boundaries: Option<Vec<PunctuationBoundaries>>,
23
24    /// This is the plan for formatting the chunk before it is sent to the voice provider.
25    #[serde(rename = "formatPlan", skip_serializing_if = "Option::is_none")]
26    pub format_plan: Option<models::FormatPlan>,
27}
28
29impl ChunkPlan {
30    pub fn new() -> ChunkPlan {
31        ChunkPlan {
32            enabled: None,
33            min_characters: None,
34            punctuation_boundaries: None,
35            format_plan: None,
36        }
37    }
38}
39
40/// Punctuation boundaries used for chunking.
41#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
42pub enum PunctuationBoundaries {
43    #[serde(rename = "。")]
44    FullStopChinese,
45    #[serde(rename = ",")]
46    CommaChinese,
47    #[serde(rename = ".")]
48    Period,
49    #[serde(rename = "!")]
50    Exclamation,
51    #[serde(rename = "?")]
52    QuestionMark,
53    #[serde(rename = ";")]
54    Semicolon,
55    #[serde(rename = ")")]
56    RightParenthesis,
57    #[serde(rename = "،")]
58    CommaArabic,
59    #[serde(rename = "۔")]
60    FullStopArabic,
61    #[serde(rename = "।")]
62    FullStopDevanagari,
63    #[serde(rename = "॥")]
64    DoubleVerticalBar,
65    #[serde(rename = "|")]
66    Pipe,
67    #[serde(rename = "||")]
68    DoublePipe,
69    #[serde(rename = ",")]
70    Comma,
71    #[serde(rename = ":")]
72    Colon,
73}
74
75impl Default for PunctuationBoundaries {
76    fn default() -> PunctuationBoundaries {
77        PunctuationBoundaries::Period // Default value for chunking
78    }
79}