rust_ai/openai/types/model.rs
1//!
2//! Note: all contents copied from OpenAI documentation on November 7, 2023.
3//!
4//! Source: <https://platform.openai.com/docs/models/overview>
5//!
6//! # Models
7//!
8//! | MODELS | DESCRIPTION |
9//! | :----------- | :---------- |
10//! | GPT-4 | A set of models that improve on GPT-3.5 and can understand as well as generate natural language or code |
11//! | GPT-3.5 | A set of models that improve on GPT-3 and can understand as well as generate natural language or code |
12//! | DALL·E | A model that can generate and edit images given a natural language prompt |
13//! | Whisper | A model that can convert audio into text |
14//! | Embeddings | A set of models that can convert text into a numerical form |
15//! | CodexLimited | A set of models that can understand and generate code, including translating natural language to code |
16//! | Moderation | A fine-tuned model that can detect whether text may be sensitive or unsafe |
17//! | GPT-3 | A set of models that can understand and generate natural language |
18//! | TTS | A set of models that can convert text into natural sounding spoken audio |
19
20////////////////////////////////////////////////////////////////////////////////
21
22use serde::{Deserialize, Serialize};
23
24/// An enum of OpenAI models
25///
26/// Note: GPT-4 are not publicly availble yet (Mar 22, 2023).
27#[allow(non_camel_case_types)]
28#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
29pub enum Model {
30 /// **GPT-4 Turbo**
31 ///
32 /// The latest GPT-4 model intended to reduce cases of “laziness” where the
33 /// model doesn’t complete a task. Returns a maximum of 4,096 output
34 /// tokens. [Learn more](https://openai.com/blog/new-embedding-models-and-api-updates).
35 ///
36 /// | MAX TOKENS | TRAINING DATA | SERIES |
37 /// | :------------ | :------------- | :----- |
38 /// | 128000 tokens | Up to Dec 2023 | GPT-4 |
39 #[serde(rename = "gpt-4-0125-preview")]
40 GPT_4_0125_PREVIEW,
41
42 /// Currently points to gpt-4-0125-preview.
43 ///
44 /// | MAX TOKENS | TRAINING DATA | SERIES |
45 /// | :------------ | :------------- | :----- |
46 /// | 128000 tokens | Up to Dec 2023 | GPT-4 |
47 #[serde(rename = "gpt-4-turbo-preview")]
48 GPT_4_TURBO_PREVIEW,
49
50 /// GPT-4 Turbo model featuring improved instruction following, JSON mode,
51 /// reproducible outputs, parallel function calling, and more. Returns a
52 /// maximum of 4,096 output tokens. This is a preview model. [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
53 ///
54 /// | MAX TOKENS | TRAINING DATA | SERIES |
55 /// | :------------ | :------------- | :----- |
56 /// | 128000 tokens | Up to Apr 2023 | GPT-4 |
57 #[serde(rename = "gpt-4-1106-preview")]
58 GPT_4_1106_PREVIEW,
59
60 /// Ability to understand images, in addition to all other GPT-4 Turbo
61 /// capabilties. Returns a maximum of 4,096 output tokens. This is a
62 /// preview model version and not suited yet for production traffic.
63 /// [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
64 ///
65 /// | MAX TOKENS | TRAINING DATA | SERIES |
66 /// | :------------ | :------------- | :----- |
67 /// | 128000 tokens | Up to Apr 2023 | GPT-4 |
68 #[serde(rename = "gpt-4-vision-preview")]
69 GPT_4_TURBO_WITH_VISION,
70
71 /// GPT-4 with the ability to understand images, in addition to all other
72 /// GPT-4 Turbo capabilities. Returns a maximum of 4,096 output tokens.
73 /// This is a preview model version. [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
74 ///
75 /// | MAX TOKENS | TRAINING DATA | SERIES |
76 /// | :------------ | :------------- | :----- |
77 /// | 128000 tokens | Up to Apr 2023 | GPT-4 |
78 #[serde(rename = "gpt-4-1106-vision-preview")]
79 GPT_4_TURBO_1106_WITH_VISION,
80
81 /// More capable than any GPT-3.5 model, able to do more complex tasks, and
82 /// optimized for chat. Will be updated with our latest model iteration.
83 ///
84 /// Note: on June 27th, 2023, `gpt-4` will be updated to point from
85 /// `gpt-4-0314` to `gpt-4-0613`, the latest model iteration.
86 ///
87 /// | MAX TOKENS | TRAINING DATA | SERIES |
88 /// | :---------- | :------------- | :----- |
89 /// | 8192 tokens | Up to Sep 2021 | GPT-4 |
90 #[serde(rename = "gpt-4")]
91 GPT_4,
92
93 /// Snapshot of `gpt-4` from March 14th 2023. Unlike `gpt-4`, this model
94 /// will not receive updates, and will only be supported for a three month
95 /// period ending on June 13th 2023.
96 ///
97 /// | MAX TOKENS | TRAINING DATA | SERIES |
98 /// | :---------- | :------------- | :----- |
99 /// | 8192 tokens | Up to Sep 2021 | GPT-4 |
100 #[deprecated(note = "Discontinuation date 2024-06-13, use `gpt-4-0613` instead")]
101 #[serde(rename = "gpt-4-0314")]
102 GPT_4_0314,
103
104 /// Snapshot of `gpt-4` from June 13th 2023 with function calling data.
105 /// Unlike `gpt-4`, this model will not receive updates, and will be
106 /// deprecated 3 months after a new version is released.
107 ///
108 /// | MAX TOKENS | TRAINING DATA | SERIES |
109 /// | :----------- | :------------- | :----- |
110 /// | 8,192 tokens | Up to Sep 2021 | GPT-4 |
111 #[serde(rename = "gpt-4-0613")]
112 GPT_4_0613,
113
114 /// Same capabilities as the base `gpt-4` mode but with 4x the context
115 /// length. Will be updated with our latest model iteration.
116 ///
117 /// | MAX TOKENS | TRAINING DATA | SERIES |
118 /// | :----------- | :------------- | :----- |
119 /// | 32768 tokens | Up to Sep 2021 | GPT-4 |
120 #[serde(rename = "gpt-4-32k")]
121 GPT_4_32K,
122
123 /// Snapshot of `gpt-4-32` from June 13th 2023. Unlike `gpt-4-32k`, this
124 /// model will not receive updates, and will be deprecated 3 months after a
125 /// new version is released.
126 ///
127 /// | MAX TOKENS | TRAINING DATA | SERIES |
128 /// | :------------ | :------------- | :----- |
129 /// | 32,768 tokens | Up to Sep 2021 | GPT-4 |
130 #[serde(rename = "gpt-4-0613")]
131 GPT_4_32K_0613,
132
133 /// Snapshot of `gpt-4-32` from March 14th 2023. Unlike `gpt-4-32k`, this
134 /// model will not receive updates, and will be deprecated 3 months after a
135 /// new version is released.
136 ///
137 /// | MAX TOKENS | TRAINING DATA | SERIES |
138 /// | :----------- | :------------- | :----- |
139 /// | 32768 tokens | Up to Sep 2021 | GPT-4 |
140 #[deprecated(note = "Discontinuation date 2023-09-13, use `gpt-4-32k-0613` instead")]
141 #[serde(rename = "gpt-4-32k-0314")]
142 GPT_4_32K_0314,
143
144 /// **Updated GPT 3.5 Turbo**
145 ///
146 /// The latest GPT-3.5 Turbo model with higher accuracy at responding in
147 /// requested formats and a fix for a bug which caused a text encoding
148 /// issue for non-English language function calls. Returns a maximum of
149 /// 4,096 output tokens. [Learn more](https://openai.com/blog/new-embedding-models-and-api-updates#:~:text=Other%20new%20models%20and%20lower%20pricing)
150 ///
151 /// | MAX TOKENS | TRAINING DATA | SERIES |
152 /// | :---------- | :------------- | :------ |
153 /// | 16,385 tokens | Up to Sep 2021 | GPT-3.5 |
154 #[serde(rename = "gpt-3.5-turbo-0125")]
155 GPT_3_5_TURBO_0125,
156
157 /// Most capable GPT-3.5 model and optimized for chat at 1/10th the cost of
158 /// `text-davinci-003`. Will be updated with our latest model iteration.
159 ///
160 /// Note: on June 27th, 2023, `gpt-3.5-turbo` will be updated to point from
161 /// `gpt-3.5-turbo-0301` to `gpt-3.5-turbo-0613`.
162 ///
163 /// | MAX TOKENS | TRAINING DATA | SERIES |
164 /// | :---------- | :------------- | :------ |
165 /// | 4096 tokens | Up to Sep 2021 | GPT-3.5 |
166 #[serde(rename = "gpt-3.5-turbo")]
167 GPT_3_5_TURBO,
168
169 /// The latest GPT-3.5 Turbo model with improved instruction following,
170 /// JSON mode, reproducible outputs, parallel function calling, and more.
171 /// Returns a maximum of 4,096 output tokens. [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
172 ///
173 /// | MAX TOKENS | TRAINING DATA | SERIES |
174 /// | :----------- | :------------- | :------ |
175 /// | 16385 tokens | Up to Sep 2021 | GPT-3.5 |
176 #[serde(rename = "gpt-3.5-turbo-1106")]
177 GPT_3_5_TURBO_1106,
178
179 /// Same capabilities as the standard `gpt-3.5-turbo` model but with 4
180 /// times the context.
181 ///
182 /// Note: currently points to gpt-3.5-turbo-16k-0613
183 /// | MAX TOKENS | TRAINING DATA | SERIES |
184 /// | :------------ | :------------- | :------ |
185 /// | 16,385 tokens | Up to Sep 2021 | GPT-3.5 |
186 #[serde(rename = "gpt-3.5-turbo-16k")]
187 GPT_3_5_TURBO_16K,
188
189 /// Snapshot of `gpt-3.5-turbo-16k` from June 13th 2023. Unlike
190 /// `gpt-3.5-turbo-16k`, this model will not receive updates, and will be
191 /// deprecated 3 months after a new version is released.
192 ///
193 /// Note: Will be deprecated on June 13, 2024.
194 ///
195 /// | MAX TOKENS | TRAINING DATA | SERIES |
196 /// | :------------ | :------------- | :------ |
197 /// | 16,385 tokens | Up to Sep 2021 | GPT-3.5 |
198 #[deprecated(note = "Discontinuation date 2024-06-13")]
199 #[serde(rename = "gpt-3.5-turbo-16k-0613")]
200 GPT_3_5_TURBO_16K_0613,
201
202 /// Snapshot of `gpt-3.5-turbo` from June 13th 2023 with function calling
203 /// data. Unlike `gpt-3.5-turbo`, this model will not receive updates, and
204 /// will be deprecated 3 months after a new version is released.
205 ///
206 /// Note: Will be deprecated on June 13, 2024.
207 ///
208 /// | MAX TOKENS | TRAINING DATA | SERIES |
209 /// | :----------- | :------------- | :------ |
210 /// | 4,096 tokens | Up to Sep 2021 | GPT-3.5 |
211 #[deprecated(note = "Discontinuation date 2024-06-13")]
212 #[serde(rename = "gpt-3.5-turbo-0613")]
213 GPT_3_5_TURBO_0613,
214
215 /// Snapshot of `gpt-3.5-turbo` from March 1st 2023. Unlike
216 /// `gpt-3.5-turbo`, this model will not receive updates, and will only be
217 /// supported for a three month period ending on June 1st 2023.
218 ///
219 /// | MAX TOKENS | TRAINING DATA | SERIES |
220 /// | :---------- | :------------- | :------ |
221 /// | 4096 tokens | Up to Sep 2021 | GPT-3.5 |
222 #[deprecated(note = "Discontinuation date 2023-09-13, use `gpt-3.5-turbo-0613` instead")]
223 #[serde(rename = "gpt-3.5-turbo-0301")]
224 GPT_3_5_TURBO_0301,
225
226 /// Can do any language task with better quality, longer output, and
227 /// consistent instruction-following than the curie, babbage, or ada
228 /// models. Also supports some additional features such as [inserting text](https://platform.openai.com/docs/guides/gpt/inserting-text).
229 ///
230 /// | MAX TOKENS | TRAINING DATA | SERIES |
231 /// | :---------- | :------------- | :------ |
232 /// | 4097 tokens | Up to Sep 2021 | GPT-3.5 |
233 #[serde(rename = "text-davinci-003")]
234 TEXT_DAVINCI_003,
235
236 /// Similar capabilities to `text-davinci-003` but trained with supervised
237 /// fine-tuning instead of reinforcement learning
238 ///
239 /// | MAX TOKENS | TRAINING DATA | SERIES |
240 /// | :---------- | :------------- | :------ |
241 /// | 4097 tokens | Up to Sep 2021 | GPT-3.5 |
242 #[serde(rename = "text-davinci-002")]
243 TEXT_DAVINCI_002,
244 #[serde(rename = "text-davinci-edit-001")]
245 TEXT_DAVINCI_EDIT_001,
246
247 /// Optimized for code-completion tasks
248 ///
249 /// | MAX TOKENS | TRAINING DATA | SERIES |
250 /// | :---------- | :------------- | :------ |
251 /// | 8001 tokens | Up to Sep 2021 | GPT-3.5 |
252 #[serde(rename = "code-davinci-edit-001")]
253 CODE_DAVINCI_EDIT_001,
254
255 #[serde(rename = "whisper-1")]
256 WHISPER_1,
257
258 #[serde(rename = "text-embedding-ada-002")]
259 TEXT_EMBEDDING_ADA_002,
260
261 #[serde(rename = "text-embedding-ada-002-v2")]
262 TEXT_EMBEDDING_ADA_002_v2,
263
264 #[serde(rename = "text-search-ada-doc-001")]
265 TEXT_SEARCH_ADA_DOC_001,
266
267 /// Most capable Codex model. Particularly good at translating natural
268 /// language to code. In addition to completing code, also supports
269 /// [inserting](https://platform.openai.com/docs/guides/code/inserting-code) completions within code.
270 ///
271 /// | MAX TOKENS | TRAINING DATA | SERIES |
272 /// | :---------- | :------------- | :----- |
273 /// | 8001 tokens | Up to Jun 2021 | Codex |
274 #[deprecated(note = "The Codex models are now deprecated.")]
275 #[serde(rename = "code-davinci-002")]
276 CODE_DAVINCI_002,
277
278 /// Earlier version of `code-davinci-002`
279 ///
280 /// | MAX TOKENS | TRAINING DATA | SERIES |
281 /// | :---------- | :------------- | :----- |
282 /// | 8001 tokens | Up to Jun 2021 | Codex |
283 #[deprecated(note = "The Codex models are now deprecated.")]
284 #[serde(rename = "code-davinci-001")]
285 CODE_DAVINCI_001,
286
287 /// Almost as capable as Davinci Codex, but slightly faster. This speed
288 /// advantage may make it preferable for real-time applications.
289 ///
290 /// | MAX TOKENS | TRAINING DATA | SERIES |
291 /// | :---------- | :------------- | :----- |
292 /// | 2048 tokens | - | Codex |
293 #[deprecated(note = "The Codex models are now deprecated.")]
294 #[serde(rename = "code-cushman-002")]
295 CODE_CUSHMAN_002,
296
297 /// Earlier version of `code-cushman-002`
298 ///
299 /// | MAX TOKENS | TRAINING DATA | SERIES |
300 /// | :---------- | :------------- | :----- |
301 /// | 2048 tokens | - | Codex |
302 #[deprecated(note = "The Codex models are now deprecated.")]
303 #[serde(rename = "code-cushman-001")]
304 CODE_CUSHMAN_001,
305
306 /// Most capable moderation model. Accuracy will be slighlty higher than
307 /// the stable model
308 ///
309 /// Series: Moderation
310 #[serde(rename = "text-moderation-latest")]
311 TEXT_MODERATION_LATEST,
312 #[serde(rename = "text-moderation-004")]
313 TEXT_MODERATION_004,
314 #[serde(rename = "text-moderation-003")]
315 TEXT_MODERATION_003,
316 #[serde(rename = "text-moderation-002")]
317 TEXT_MODERATION_002,
318 #[serde(rename = "text-moderation-001")]
319 TEXT_MODERATION_001,
320
321 /// Almost as capable as the latest model, but slightly older.
322 ///
323 /// Series: Moderation
324 #[serde(rename = "text-moderation-stable")]
325 TEXT_MODERATION_STABLE,
326
327 /// Very capable, faster and lower cost than Davinci.
328 ///
329 /// | MAX TOKENS | TRAINING DATA | SERIES |
330 /// | :---------- | :------------- | :----- |
331 /// | 2049 tokens | Up to Oct 2019 | GPT-3 |
332 #[serde(rename = "text-curie-001")]
333 TEXT_CURIE_001,
334
335 /// Capable of straightforward tasks, very fast, and lower cost.
336 ///
337 /// | MAX TOKENS | TRAINING DATA | SERIES |
338 /// | :---------- | :------------- | :----- |
339 /// | 2049 tokens | Up to Oct 2019 | GPT-3 |
340 #[serde(rename = "text-babbage-001")]
341 TEXT_BABBAGE_001,
342
343 /// Capable of very simple tasks, usually the fastest model in the GPT-3
344 /// series, and lowest cost.
345 ///
346 /// | MAX TOKENS | TRAINING DATA | SERIES |
347 /// | :---------- | :------------- | :----- |
348 /// | 2049 tokens | Up to Oct 2019 | GPT-3 |
349 #[serde(rename = "text-ada-001")]
350 TEXT_ADA_001,
351
352 /// Most capable GPT-3 model. Can do any task the other models can do,
353 /// often with higher quality.
354 ///
355 /// | MAX TOKENS | TRAINING DATA | SERIES |
356 /// | :---------- | :------------- | :----- |
357 /// | 2049 tokens | Up to Oct 2019 | GPT-3 |
358 #[serde(rename = "davinci")]
359 DAVINCI,
360
361 /// Very capable, but faster and lower cost than Davinci.
362 ///
363 /// | MAX TOKENS | TRAINING DATA | SERIES |
364 /// | :---------- | :------------- | :----- |
365 /// | 2049 tokens | Up to Oct 2019 | GPT-3 |
366 #[serde(rename = "curie")]
367 CURIE,
368
369 /// Capable of straightforward tasks, very fast, and lower cost.
370 ///
371 /// | MAX TOKENS | TRAINING DATA | SERIES |
372 /// | :---------- | :------------- | :----- |
373 /// | 2049 tokens | Up to Oct 2019 | GPT-3 |
374 #[serde(rename = "babbage")]
375 BABBAGE,
376
377 /// Capable of very simple tasks, usually the fastest model in the GPT-3 series, and lowest cost.
378 ///
379 /// | MAX TOKENS | TRAINING DATA | SERIES |
380 /// | :---------- | :------------- | :----- |
381 /// | 2049 tokens | Up to Oct 2019 | GPT-3 |
382 #[serde(rename = "ada")]
383 ADA,
384
385 /// The latest DALL·E model released in Nov 2023. [Learn more](https://openai.com/blog/new-models-and-developer-products-announced-at-devday).
386 #[serde(rename = "dall-e-3")]
387 DALL_E_3,
388
389 /// The previous DALL·E model released in Nov 2022. The 2nd iteration of
390 /// DALL·E with more realistic, accurate, and 4x greater resolution images
391 /// than the original model.
392 #[serde(rename = "dall-e-2")]
393 DALL_E_2,
394
395 /// The latest text to speech model, optimized for speed.
396 #[serde(rename = "tts-1")]
397 TTS_1,
398
399 /// The latest text to speech model, optimized for quality.
400 #[serde(rename = "tts-1-hd")]
401 TTS_1_HD,
402
403 #[serde(other)]
404 UNKNOWN,
405}
406
407#[allow(deprecated)]
408impl Into<&'static str> for Model {
409 fn into(self) -> &'static str {
410 match self {
411 Model::GPT_4 => "gpt-4",
412 Model::GPT_4_0613 => "gpt-4-0613",
413 Model::GPT_4_0314 => "gpt-4-0314",
414 Model::GPT_4_32K => "gpt-4-32k",
415 Model::GPT_4_32K_0613 => "gpt-4-32k-0613",
416 Model::GPT_4_32K_0314 => "gpt-4-32k-0314",
417 Model::GPT_3_5_TURBO => "gpt-3.5-turbo",
418 Model::GPT_3_5_TURBO_16K => "gpt-3.5-turbo-16k",
419 Model::GPT_3_5_TURBO_16K_0613 => "gpt-3.5-turbo-16k-0613",
420 Model::GPT_3_5_TURBO_0613 => "gpt-3.5-turbo-0613",
421 Model::GPT_3_5_TURBO_0301 => "gpt-3.5-turbo-0301",
422 Model::TEXT_DAVINCI_003 => "text-davinci-003",
423 Model::TEXT_DAVINCI_002 => "text-davinci-002",
424 Model::TEXT_DAVINCI_EDIT_001 => "text-davinci-edit-001",
425 Model::CODE_DAVINCI_EDIT_001 => "code-davinci-edit-001",
426 Model::WHISPER_1 => "whisper-1",
427 Model::TEXT_EMBEDDING_ADA_002 => "text-embedding-ada-002",
428 Model::TEXT_EMBEDDING_ADA_002_v2 => "text-embedding-ada-002-v2",
429 Model::TEXT_SEARCH_ADA_DOC_001 => "text-search-ada-doc-001",
430 Model::CODE_DAVINCI_002 => "code-davinci-002",
431 Model::CODE_DAVINCI_001 => "code-davinci-001",
432 Model::CODE_CUSHMAN_002 => "code-cushman-002",
433 Model::CODE_CUSHMAN_001 => "code-cushman-001",
434 Model::TEXT_MODERATION_LATEST => "text-moderation-latest",
435 Model::TEXT_MODERATION_STABLE => "text-moderation-stable",
436 Model::TEXT_CURIE_001 => "text-curie-001",
437 Model::TEXT_BABBAGE_001 => "text-babbage-001",
438 Model::TEXT_ADA_001 => "text-ada-001",
439 Model::DAVINCI => "davinci",
440 Model::CURIE => "curie",
441 Model::BABBAGE => "babbage",
442 Model::ADA => "ada",
443 Model::TEXT_MODERATION_001 => "text-moderation-001",
444 Model::TEXT_MODERATION_002 => "text-moderation-002",
445 Model::TEXT_MODERATION_003 => "text-moderation-003",
446 Model::TEXT_MODERATION_004 => "text-moderation-004",
447 Model::UNKNOWN => "unknown",
448 Model::GPT_4_TURBO_WITH_VISION => "gpt-4-vision-preview",
449 Model::GPT_3_5_TURBO_1106 => "gpt-3.5-turbo-1106",
450 Model::DALL_E_3 => "dall-e-3",
451 Model::DALL_E_2 => "dall-e-2",
452 Model::TTS_1 => "tts-1",
453 Model::TTS_1_HD => "tts-1-hd",
454 Model::GPT_4_0125_PREVIEW => "gpt-4-0125-preview",
455 Model::GPT_4_TURBO_PREVIEW => "gpt-4-turbo-preview",
456 Model::GPT_4_1106_PREVIEW => "gpt-4-1106-preview",
457 Model::GPT_4_TURBO_1106_WITH_VISION => "gpt-4-1106-vision-preview",
458 Model::GPT_3_5_TURBO_0125 => "gpt-3.5-turbo-0125",
459 }
460 }
461}