openai_api_rs/v1/
batch.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Serialize, Deserialize)]
4pub struct CreateBatchRequest {
5 pub input_file_id: String,
6 pub endpoint: String,
7 pub completion_window: String,
8 #[serde(skip_serializing_if = "Option::is_none")]
9 pub metadata: Option<Metadata>,
10}
11
12#[derive(Debug, Serialize, Deserialize)]
13pub struct Metadata {
14 pub customer_id: String,
15 pub batch_description: String,
16}
17
18#[derive(Debug, Serialize, Deserialize)]
19pub struct RequestCounts {
20 pub total: u32,
21 pub completed: u32,
22 pub failed: u32,
23}
24
25#[derive(Debug, Serialize, Deserialize)]
26pub struct BatchResponse {
27 pub id: String,
28 pub object: String,
29 pub endpoint: String,
30 pub errors: Option<Vec<String>>,
31 pub input_file_id: String,
32 pub completion_window: String,
33 pub status: String,
34 pub output_file_id: Option<String>,
35 pub error_file_id: Option<String>,
36 pub created_at: u64,
37 pub in_progress_at: Option<u64>,
38 pub expires_at: Option<u64>,
39 pub finalizing_at: Option<u64>,
40 pub completed_at: Option<u64>,
41 pub failed_at: Option<u64>,
42 pub expired_at: Option<u64>,
43 pub cancelling_at: Option<u64>,
44 pub cancelled_at: Option<u64>,
45 pub request_counts: RequestCounts,
46 pub metadata: Option<Metadata>,
47}
48
49#[derive(Debug, Serialize, Deserialize)]
50pub struct ListBatchResponse {
51 pub object: String,
52 pub data: Vec<BatchResponse>,
53 pub first_id: String,
54 pub last_id: String,
55 pub has_more: bool,
56}
57
58impl CreateBatchRequest {
59 pub fn new(input_file_id: String, endpoint: String, completion_window: String) -> Self {
60 Self {
61 input_file_id,
62 endpoint,
63 completion_window,
64 metadata: None,
65 }
66 }
67}