Skip to main content

openai_types/embedding/
_gen.rs

1// AUTO-GENERATED by py2rust — do not edit.
2// Re-generate: python3 scripts/py2rust.py sync <python_dir> <rust_dir>
3// Domain: embedding
4#![allow(unused_imports)]
5
6use serde::{Deserialize, Serialize};
7use super::*;
8
9/// The usage information for the request.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
12pub struct Usage {
13    /// The number of tokens used by the prompt.
14    pub prompt_tokens: i64,
15    /// The total number of tokens used by the request.
16    pub total_tokens: i64,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
21pub struct CreateEmbeddingResponse {
22    /// The list of embeddings generated by the model.
23    pub data: Vec<Embedding>,
24    /// The name of the model used to generate the embedding.
25    pub model: String,
26    /// The object type, which is always "list".
27    pub object: String,
28    /// The usage information for the request.
29    pub usage: Usage,
30}
31
32#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
33#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
34#[non_exhaustive]
35pub enum EmbeddingCreateParamsEncodingFormat {
36    #[serde(rename = "float")]
37    Float,
38    #[serde(rename = "base64")]
39    Base64,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
44pub struct EmbeddingCreateParams {
45    /// Input text to embed, encoded as a string or array of tokens.
46    pub input: serde_json::Value,
47    /// ID of the model to use.
48    pub model: String,
49    /// The number of dimensions the resulting output embeddings should have.
50    #[serde(skip_serializing_if = "Option::is_none", default)]
51    pub dimensions: Option<i64>,
52    /// The format to return the embeddings in.
53    #[serde(skip_serializing_if = "Option::is_none", default)]
54    pub encoding_format: Option<EmbeddingCreateParamsEncodingFormat>,
55    /// A unique identifier representing your end-user, which can help OpenAI to monitor
56    #[serde(skip_serializing_if = "Option::is_none", default)]
57    pub user: Option<String>,
58}
59
60#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
61#[cfg_attr(feature = "structured", derive(schemars::JsonSchema))]
62#[non_exhaustive]
63pub enum EmbeddingModel {
64    #[serde(rename = "text-embedding-ada-002")]
65    TextEmbeddingAda002,
66    #[serde(rename = "text-embedding-3-small")]
67    TextEmbedding3Small,
68    #[serde(rename = "text-embedding-3-large")]
69    TextEmbedding3Large,
70}