rust_ai/openai/
mod.rs

1//! 
2//! # OpenAI
3//! 
4//! ## Introduction
5//! 
6//! This module provides functionalities accessable from OpenAI's RESTful API 
7//! endpoints.
8//! 
9//! You should have a valid API Key first. Put the key in `config.yml`, see
10//! README.md for instance.
11//! 
12//! These types are re-exported from submodules:
13//! - [`Audio`][crate::openai::Audio]: audio transcriptions and translations;
14//! - [`ChatCompletion`][crate::openai::ChatCompletion]: ChatGPT like capabilities for text/code completion;
15//! - [`Completion`][crate::openai::Completion]: GPT-3 based text/code completion;
16//! - [`Edit`][crate::openai::Edit]: text content manipulation;
17//! - [`Embedding`][crate::openai::Embedding]: Ada based embedding extraction;
18//! - [`Moderation`][crate::openai::Moderation]: content violation detection;
19//! - [`Model`][crate::openai::Model]: an enum represents all available OpenAI public models.
20//! 
21//! ## Support List
22//! 
23//! | Category         | Variant        | Tested Models            | Stream |
24//! | :--------------- | :------------- | :----------------------- | :----: |
25//! | Chat completions | -              | `gpt-4-turbo-preview`, `gpt-4-0125-preview`, `gpt-4-1106-vision-preview`, `gpt-4-1106-preview`, `gpt-4-vision-preview`, `gpt-4`, `gpt-4-0314`, `gpt-4-0613`, `gpt-3.5-turbo-0125`, `gpt-3.5-turbo-1106`, `gpt-3.5-turbo`, `gpt-3.5-turbo-16k`, `gpt-3.5-turbo-16k-0613`, `gpt-3.5-turbo-0613`, `gpt-3.5-turbo-0301`, `text-davinci-003`, `text-davinci-002`, `code-davinci-002`[^note_3] | yes    |ext-davinci-002`, `code-davinci-002` | yes    |
26//! | Completions      | -              | `gpt-4-turbo-preview`, `gpt-4-0125-preview`, `gpt-4-1106-vision-preview`, `gpt-4-1106-preview`, `gpt-4-vision-preview`, `gpt-4`, `gpt-4-0314`, `gpt-4-0613`, `gpt-3.5-turbo-0125`, `gpt-3.5-turbo-1106`, `gpt-3.5-turbo`, `gpt-3.5-turbo-16k`, `gpt-3.5-turbo-16k-0613`, `gpt-3.5-turbo-0613`, `gpt-3.5-turbo-0301`, `text-davinci-003`       | yes    |   | yes    |
27//! | Edits            | -              | `text-davinci-edit-001`, `code-davinci-edit-001`  | -      |
28//! | Images           | Generations    | `dall-e-2`, `dall-e-3`   | -      |
29//! | Images           | Edits          | `dall-e-2`               | -      |
30//! | Images           | Variations     | `dall-e-2`               | -      |
31//! | Embeddings       | -              | `text-embedding-ada-002`[^note_4] | -      |
32//! | Audios           | Transcriptions | `whisper-1`              | -      |
33//! | Audios           | Translation    | `whisper-1`              | -      |
34//! | Moderation       | -              | `text-moderation-latest`[^note_2], `text-moderation-stable` | -      |
35//! 
36//! Note: 
37//! - Updated on Feburary 22nd, 2024.
38//! - OpenAI's Fine Tunes endpoints are currently not supported.
39//! - OpenAI's Assistants endpoints are currently not supported.
40//! 
41//! [^note_2]: OpenAI's responses for moderation indicate usage of 
42//! `text-moderation-004` model (March 23rd, 2023). But developers cannot use 
43//! its API endpoints to specify variants other than `text-moderation-latest` 
44//! and `text-moderation-stable`.
45//! 
46//! [^note_3]: GPT-4/GPT-4-0314/GPT-4-0613 tested, GPT-4-32K/GPT-4-32K-0314 not tested 
47//! because developer currently only has access to 8K token ones (May 6th, 
48//! 2023).
49//! 
50//! [^note_4]: You may notice the actual model behind Embedding API to be 
51//! `text-embedding-ada-002-v2` (March 23rd, 2023).
52
53////////////////////////////////////////////////////////////////////////////////
54
55/// API endpoint definitions
56pub mod endpoint;
57
58/// Type definitions for OpenAI
59pub mod types;
60
61/// OpenAI capabilities
62pub mod apis;
63
64pub use apis::chat_completion::ChatCompletion;
65pub use apis::completion::Completion;
66pub use apis::edit::Edit;
67pub use apis::image::Image;
68pub use apis::embedding::Embedding;
69pub use apis::audio::Audio;
70pub use apis::moderation::Moderation;
71pub use types::model::Model;