openai_interface/files/mod.rs
1//! File management module for OpenAI API integration.
2//!
3//! This module provides functionality for managing files in the OpenAI ecosystem,
4//! including creating, listing, and retrieving file objects. It defines the core
5//! data structures for representing files and their metadata as returned by the
6//! OpenAI API.
7//!
8//! Submodules: `create`, `list`, `retrieve`, `delete`, and `content` for
9//! specific file operations
10
11pub mod content;
12pub mod create;
13pub mod delete;
14pub mod list;
15pub mod retrieve;
16
17use serde::{Deserialize, Serialize};
18
19#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
20pub struct FileObject {
21 /// The file identifier, which can be referenced in the API endpoints.
22 pub id: String,
23 /// The size of the file, in bytes.
24 pub bytes: usize,
25 /// The Unix timestamp (in seconds) for when the file was created.
26 pub created_at: usize,
27 /// The name of the file.
28 pub filename: String,
29 /// The object type, which is always `file`.
30 pub object: String,
31 /// The intended purpose of the file.
32 /// Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`,
33 /// `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
34 pub purpose: FilePurpose,
35 /// Deprecated. The current status of the file, which can be either `uploaded`,
36 /// `processed`, or `error`.
37 pub status: Option<FileStatus>,
38 /// The Unix timestamp (in seconds) for when the file will expire.
39 pub expires_at: Option<usize>,
40 /// Deprecated. For details on why a fine-tuning training file failed validation, see the
41 /// `error` field on `fine_tuning.job`.
42 pub status_details: Option<String>,
43}
44
45#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
46#[serde(rename_all = "lowercase")]
47pub enum FileStatus {
48 Uploaded,
49 Processed,
50 Error,
51}
52
53#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
54pub enum FilePurpose {
55 #[serde(rename = "assistants")]
56 Assistants,
57 #[serde(rename = "assistants_output")]
58 AssistantsOutput,
59 #[serde(rename = "batch")]
60 Batch,
61 #[serde(rename = "batch_output")]
62 BatchOutput,
63 #[serde(rename = "fine-tune")]
64 FineTune,
65 #[serde(rename = "fine-tune-results")]
66 FineTuneResults,
67 #[serde(rename = "vision")]
68 Vision,
69 #[serde(rename = "user_data")]
70 UserData,
71 #[serde(untagged)]
72 Other(String),
73}
74
75crate::impl_from_str!(FileObject);