endpoints/files.rs
1//! Define types for the `files` endpoint.
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Deserialize, Serialize, Default)]
6pub struct FilesRequest {
7 /// The File object (not file name) to be uploaded.
8 file: FileObject,
9 /// The intended purpose of the uploaded file.
10 /// Use "fine-tune" for Fine-tuning and "assistants" for `Assistants` and `Messages`.
11 purpose: String,
12}
13
14/// The File object represents a document that has been uploaded to the server.
15#[derive(Debug, Clone, Deserialize, Serialize, Default)]
16pub struct FileObject {
17 /// The file identifier, which can be referenced in the API endpoints.
18 pub id: String,
19 /// The size of the file, in bytes.
20 pub bytes: u64,
21 /// The Unix timestamp (in seconds) for when the file was created.
22 pub created_at: u64,
23 /// The name of the file.
24 pub filename: String,
25 /// The object type, which is always `file`.
26 pub object: String,
27 /// The intended purpose of the file. Supported values are `fine-tune`, `fine-tune-results`, `assistants`, and `assistants_output`.
28 pub purpose: String,
29}
30
31/// Represent the response from the `files` endpoint.
32#[derive(Debug, Deserialize, Serialize)]
33pub struct ListFilesResponse {
34 /// The object type, which is always `list`.
35 pub object: String,
36 /// The list of file objects.
37 pub data: Vec<FileObject>,
38}
39
40/// Represents the status of a file deletion operation.
41#[derive(Debug, Deserialize, Serialize)]
42pub struct DeleteFileStatus {
43 /// The file identifier, which can be referenced in the API endpoints.
44 pub id: String,
45 /// The object type, which is always `file`.
46 pub object: String,
47 /// The status of the deletion operation.
48 pub deleted: bool,
49}