openai-interface 0.13.0

A low-level Rust interface for the OpenAI API
Documentation
//! File management module for OpenAI API integration.
//!
//! This module provides functionality for managing files in the OpenAI ecosystem,
//! including creating, listing, and retrieving file objects. It defines the core
//! data structures for representing files and their metadata as returned by the
//! OpenAI API.
//!
//! Submodules: `create`, `list`, `retrieve`, `delete`, and `content` for
//! specific file operations

pub mod content;
pub mod create;
pub mod delete;
pub mod list;
pub mod retrieve;

use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
pub struct FileObject {
    /// The file identifier, which can be referenced in the API endpoints.
    pub id: String,
    /// The size of the file, in bytes.
    pub bytes: usize,
    /// The Unix timestamp (in seconds) for when the file was created.
    pub created_at: usize,
    /// The name of the file.
    pub filename: String,
    /// The object type, which is always `file`.
    pub object: String,
    /// The intended purpose of the file.
    /// Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`,
    /// `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
    pub purpose: FilePurpose,
    /// Deprecated. The current status of the file, which can be either `uploaded`,
    /// `processed`, or `error`.
    pub status: Option<FileStatus>,
    /// The Unix timestamp (in seconds) for when the file will expire.
    pub expires_at: Option<usize>,
    /// Deprecated. For details on why a fine-tuning training file failed validation, see the
    /// `error` field on `fine_tuning.job`.
    pub status_details: Option<String>,
}

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum FileStatus {
    Uploaded,
    Processed,
    Error,
}

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
pub enum FilePurpose {
    #[serde(rename = "assistants")]
    Assistants,
    #[serde(rename = "assistants_output")]
    AssistantsOutput,
    #[serde(rename = "batch")]
    Batch,
    #[serde(rename = "batch_output")]
    BatchOutput,
    #[serde(rename = "fine-tune")]
    FineTune,
    #[serde(rename = "fine-tune-results")]
    FineTuneResults,
    #[serde(rename = "vision")]
    Vision,
    #[serde(rename = "user_data")]
    UserData,
    #[serde(untagged)]
    Other(String),
}

crate::impl_from_str!(FileObject);