openai-types 0.1.3

Typed OpenAI API models — zero dependencies beyond serde
Documentation
// AUTO-GENERATED by py2rust — do not edit.
// Re-generate: python3 scripts/py2rust.py sync <python_dir> <rust_dir>
// Domain: embedding
#![allow(unused_imports)]

use serde::{Deserialize, Serialize};
use super::*;

/// The usage information for the request.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct Usage {
    /// The number of tokens used by the prompt.
    pub prompt_tokens: i64,
    /// The total number of tokens used by the request.
    pub total_tokens: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct CreateEmbeddingResponse {
    /// The list of embeddings generated by the model.
    pub data: Vec<Embedding>,
    /// The name of the model used to generate the embedding.
    pub model: String,
    /// The object type, which is always "list".
    pub object: String,
    /// The usage information for the request.
    pub usage: Usage,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum EmbeddingCreateParamsEncodingFormat {
    #[serde(rename = "float")]
    Float,
    #[serde(rename = "base64")]
    Base64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
pub struct EmbeddingCreateParams {
    /// Input text to embed, encoded as a string or array of tokens.
    pub input: serde_json::Value,
    /// ID of the model to use.
    pub model: String,
    /// The number of dimensions the resulting output embeddings should have.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub dimensions: Option<i64>,
    /// The format to return the embeddings in.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub encoding_format: Option<EmbeddingCreateParamsEncodingFormat>,
    /// A unique identifier representing your end-user, which can help OpenAI to monitor
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub user: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum EmbeddingModel {
    #[serde(rename = "text-embedding-ada-002")]
    TextEmbeddingAda002,
    #[serde(rename = "text-embedding-3-small")]
    TextEmbedding3Small,
    #[serde(rename = "text-embedding-3-large")]
    TextEmbedding3Large,
}