vapi_client/models/
open_ai_model.rs

1/*
2 * Vapi API
3 *
4 * API for building voice assistants
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Serialize};
12use utoipa::ToSchema;
13
14
15use crate::models;
16
17#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, ToSchema)]
18pub struct OpenAiModel {
19    /// This is the starting state for the conversation.
20    #[serde(rename = "messages", skip_serializing_if = "Option::is_none")]
21    pub messages: Option<Vec<models::OpenAiMessage>>,
22    /// These are the tools that the assistant can use during the call. To use existing tools, use `toolIds`.  Both `tools` and `toolIds` can be used together.
23    #[serde(rename = "tools", skip_serializing_if = "Option::is_none")]
24    pub tools: Option<Vec<models::AnyscaleModelToolsInner>>,
25    /// These are the tools that the assistant can use during the call. To use transient tools, use `tools`.  Both `tools` and `toolIds` can be used together.
26    #[serde(rename = "toolIds", skip_serializing_if = "Option::is_none")]
27    pub tool_ids: Option<Vec<String>>,
28    #[serde(rename = "knowledgeBase", skip_serializing_if = "Option::is_none")]
29    pub knowledge_base: Option<models::AnyscaleModelKnowledgeBase>,
30    /// This is the ID of the knowledge base the model will use.
31    #[serde(rename = "knowledgeBaseId", skip_serializing_if = "Option::is_none")]
32    pub knowledge_base_id: Option<String>,
33    /// This is the provider that will be used for the model.
34    #[serde(rename = "provider")]
35    pub provider: Provider,
36    /// This is the OpenAI model that will be used.
37    #[serde(rename = "model")]
38    pub model: Model,
39    /// These are the fallback models that will be used if the primary model fails. This shouldn't be specified unless you have a specific reason to do so. Vapi will automatically find the fastest fallbacks that make sense.
40    #[serde(rename = "fallbackModels", skip_serializing_if = "Option::is_none")]
41    pub fallback_models: Option<Vec<FallbackModels>>,
42    /// This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
43    #[serde(rename = "temperature", skip_serializing_if = "Option::is_none")]
44    pub temperature: Option<f64>,
45    /// This is the max number of tokens that the assistant will be allowed to generate in each turn of the conversation. Default is 250.
46    #[serde(rename = "maxTokens", skip_serializing_if = "Option::is_none")]
47    pub max_tokens: Option<f64>,
48    /// This determines whether we detect user's emotion while they speak and send it as an additional info to model.  Default `false` because the model is usually are good at understanding the user's emotion from text.  @default false
49    #[serde(
50        rename = "emotionRecognitionEnabled",
51        skip_serializing_if = "Option::is_none"
52    )]
53    pub emotion_recognition_enabled: Option<bool>,
54    /// This sets how many turns at the start of the conversation to use a smaller, faster model from the same provider before switching to the primary model. Example, gpt-3.5-turbo if provider is openai.  Default is 0.  @default 0
55    #[serde(rename = "numFastTurns", skip_serializing_if = "Option::is_none")]
56    pub num_fast_turns: Option<f64>,
57}
58
59impl OpenAiModel {
60    pub fn new(provider: Provider, model: Model) -> OpenAiModel {
61        OpenAiModel {
62            messages: None,
63            tools: None,
64            tool_ids: None,
65            knowledge_base: None,
66            knowledge_base_id: None,
67            provider,
68            model,
69            fallback_models: None,
70            temperature: None,
71            max_tokens: None,
72            emotion_recognition_enabled: None,
73            num_fast_turns: None,
74        }
75    }
76}
77/// This is the provider that will be used for the model.
78#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, ToSchema)]
79pub enum Provider {
80    #[serde(rename = "openai")]
81    Openai,
82}
83
84impl Default for Provider {
85    fn default() -> Provider {
86        Self::Openai
87    }
88}
89/// This is the OpenAI model that will be used.
90#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, ToSchema)]
91pub enum Model {
92    #[serde(rename = "gpt-4.5-preview")]
93    Gpt4Period5Preview,
94    #[serde(rename = "chatgpt-4o-latest")]
95    Chatgpt4oLatest,
96    #[serde(rename = "o3-mini")]
97    O3Mini,
98    #[serde(rename = "o1-preview")]
99    O1Preview,
100    #[serde(rename = "o1-preview-2024-09-12")]
101    O1Preview20240912,
102    #[serde(rename = "o1-mini")]
103    O1Mini,
104    #[serde(rename = "o1-mini-2024-09-12")]
105    O1Mini20240912,
106    #[serde(rename = "gpt-4o-realtime-preview-2024-10-01")]
107    Gpt4oRealtimePreview20241001,
108    #[serde(rename = "gpt-4o-realtime-preview-2024-12-17")]
109    Gpt4oRealtimePreview20241217,
110    #[serde(rename = "gpt-4o-mini-realtime-preview-2024-12-17")]
111    Gpt4oMiniRealtimePreview20241217,
112    #[serde(rename = "gpt-4o-mini")]
113    Gpt4oMini,
114    #[serde(rename = "gpt-4o-mini-2024-07-18")]
115    Gpt4oMini20240718,
116    #[serde(rename = "gpt-4o")]
117    Gpt4o,
118    #[serde(rename = "gpt-4o-2024-05-13")]
119    Gpt4o20240513,
120    #[serde(rename = "gpt-4o-2024-08-06")]
121    Gpt4o20240806,
122    #[serde(rename = "gpt-4o-2024-11-20")]
123    Gpt4o20241120,
124    #[serde(rename = "gpt-4-turbo")]
125    Gpt4Turbo,
126    #[serde(rename = "gpt-4-turbo-2024-04-09")]
127    Gpt4Turbo20240409,
128    #[serde(rename = "gpt-4-turbo-preview")]
129    Gpt4TurboPreview,
130    #[serde(rename = "gpt-4-0125-preview")]
131    Gpt40125Preview,
132    #[serde(rename = "gpt-4-1106-preview")]
133    Gpt41106Preview,
134    #[serde(rename = "gpt-4")]
135    Gpt4,
136    #[serde(rename = "gpt-4-0613")]
137    Gpt40613,
138    #[serde(rename = "gpt-3.5-turbo")]
139    Gpt3Period5Turbo,
140    #[serde(rename = "gpt-3.5-turbo-0125")]
141    Gpt3Period5Turbo0125,
142    #[serde(rename = "gpt-3.5-turbo-1106")]
143    Gpt3Period5Turbo1106,
144    #[serde(rename = "gpt-3.5-turbo-16k")]
145    Gpt3Period5Turbo16k,
146    #[serde(rename = "gpt-3.5-turbo-0613")]
147    Gpt3Period5Turbo0613,
148}
149
150impl Default for Model {
151    fn default() -> Model {
152        Self::Gpt4Period5Preview
153    }
154}
155/// These are the fallback models that will be used if the primary model fails. This shouldn't be specified unless you have a specific reason to do so. Vapi will automatically find the fastest fallbacks that make sense.
156#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, ToSchema)]
157pub enum FallbackModels {
158    #[serde(rename = "gpt-4.5-preview")]
159    Gpt4Period5Preview,
160    #[serde(rename = "chatgpt-4o-latest")]
161    Chatgpt4oLatest,
162    #[serde(rename = "o3-mini")]
163    O3Mini,
164    #[serde(rename = "o1-preview")]
165    O1Preview,
166    #[serde(rename = "o1-preview-2024-09-12")]
167    O1Preview20240912,
168    #[serde(rename = "o1-mini")]
169    O1Mini,
170    #[serde(rename = "o1-mini-2024-09-12")]
171    O1Mini20240912,
172    #[serde(rename = "gpt-4o-realtime-preview-2024-10-01")]
173    Gpt4oRealtimePreview20241001,
174    #[serde(rename = "gpt-4o-realtime-preview-2024-12-17")]
175    Gpt4oRealtimePreview20241217,
176    #[serde(rename = "gpt-4o-mini-realtime-preview-2024-12-17")]
177    Gpt4oMiniRealtimePreview20241217,
178    #[serde(rename = "gpt-4o-mini")]
179    Gpt4oMini,
180    #[serde(rename = "gpt-4o-mini-2024-07-18")]
181    Gpt4oMini20240718,
182    #[serde(rename = "gpt-4o")]
183    Gpt4o,
184    #[serde(rename = "gpt-4o-2024-05-13")]
185    Gpt4o20240513,
186    #[serde(rename = "gpt-4o-2024-08-06")]
187    Gpt4o20240806,
188    #[serde(rename = "gpt-4o-2024-11-20")]
189    Gpt4o20241120,
190    #[serde(rename = "gpt-4-turbo")]
191    Gpt4Turbo,
192    #[serde(rename = "gpt-4-turbo-2024-04-09")]
193    Gpt4Turbo20240409,
194    #[serde(rename = "gpt-4-turbo-preview")]
195    Gpt4TurboPreview,
196    #[serde(rename = "gpt-4-0125-preview")]
197    Gpt40125Preview,
198    #[serde(rename = "gpt-4-1106-preview")]
199    Gpt41106Preview,
200    #[serde(rename = "gpt-4")]
201    Gpt4,
202    #[serde(rename = "gpt-4-0613")]
203    Gpt40613,
204    #[serde(rename = "gpt-3.5-turbo")]
205    Gpt3Period5Turbo,
206    #[serde(rename = "gpt-3.5-turbo-0125")]
207    Gpt3Period5Turbo0125,
208    #[serde(rename = "gpt-3.5-turbo-1106")]
209    Gpt3Period5Turbo1106,
210    #[serde(rename = "gpt-3.5-turbo-16k")]
211    Gpt3Period5Turbo16k,
212    #[serde(rename = "gpt-3.5-turbo-0613")]
213    Gpt3Period5Turbo0613,
214}
215
216impl Default for FallbackModels {
217    fn default() -> FallbackModels {
218        Self::Gpt4Period5Preview
219    }
220}