openai_rst/assistant.rs
1//! This module defines the structures and methods for handling assistant-related requests and responses.
2//! It includes the `AssistantRequest`, `AssistantObject`, `DeletionStatus`, `ListAssistant`, `AssistantFileRequest`,
3//! `AssistantFileObject`, and `ListAssistantFile` structs along with their associated methods.
4
5use crate::{impl_builder_methods, models::Model};
6use serde::{Deserialize, Serialize};
7use std::collections::HashMap;
8
9/// Represents a request to create or update an assistant.
10#[derive(Debug, Serialize, Clone)]
11pub struct AssistantRequest {
12 /// Model to be used for the assistant.
13 pub model: Model,
14 /// Optional name of the assistant.
15 #[serde(skip_serializing_if = "Option::is_none")]
16 pub name: Option<String>,
17 /// Optional description of the assistant.
18 #[serde(skip_serializing_if = "Option::is_none")]
19 pub description: Option<String>,
20 /// Optional instructions for the assistant.
21 #[serde(skip_serializing_if = "Option::is_none")]
22 pub instructions: Option<String>,
23 /// Optional tools to be used by the assistant.
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub tools: Option<Vec<HashMap<String, String>>>,
26 /// Optional file IDs associated with the assistant.
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub file_ids: Option<Vec<String>>,
29 /// Optional metadata for the assistant.
30 #[serde(skip_serializing_if = "Option::is_none")]
31 pub metadata: Option<HashMap<String, String>>,
32}
33
34impl AssistantRequest {
35 /// Creates a new `AssistantRequest` with the specified model.
36 pub fn new(model: Model) -> Self {
37 Self {
38 model,
39 name: None,
40 description: None,
41 instructions: None,
42 tools: None,
43 file_ids: None,
44 metadata: None,
45 }
46 }
47}
48
49impl_builder_methods!(
50 AssistantRequest,
51 name: String,
52 description: String,
53 instructions: String,
54 tools: Vec<HashMap<String, String>>,
55 file_ids: Vec<String>,
56 metadata: HashMap<String, String>
57);
58
59/// Represents an assistant object with its properties.
60#[derive(Debug, Deserialize, Serialize)]
61pub struct AssistantObject {
62 /// Unique identifier for the assistant.
63 pub id: String,
64 /// Object type, typically "assistant".
65 pub object: String,
66 /// Timestamp of when the assistant was created.
67 pub created_at: i64,
68 /// Optional name of the assistant.
69 #[serde(skip_serializing_if = "Option::is_none")]
70 pub name: Option<String>,
71 /// Optional description of the assistant.
72 #[serde(skip_serializing_if = "Option::is_none")]
73 pub description: Option<String>,
74 /// Model used by the assistant.
75 pub model: Model,
76 /// Optional instructions for the assistant.
77 #[serde(skip_serializing_if = "Option::is_none")]
78 pub instructions: Option<String>,
79 /// Tools associated with the assistant.
80 pub tools: Vec<HashMap<String, String>>,
81 /// File IDs associated with the assistant.
82 pub file_ids: Vec<String>,
83 /// Metadata for the assistant.
84 pub metadata: HashMap<String, String>,
85 /// Optional headers associated with the assistant.
86 pub headers: Option<HashMap<String, String>>,
87}
88
89/// Represents the status of an assistant deletion request.
90#[derive(Debug, Deserialize, Serialize)]
91pub struct DeletionStatus {
92 /// Unique identifier for the assistant.
93 pub id: String,
94 /// Object type, typically "assistant".
95 pub object: String,
96 /// Indicates whether the assistant was deleted.
97 pub deleted: bool,
98 /// Optional headers associated with the deletion status.
99 pub headers: Option<HashMap<String, String>>,
100}
101
102/// Represents a list of assistants.
103#[derive(Debug, Deserialize, Serialize)]
104pub struct ListAssistant {
105 /// Object type, typically "list".
106 pub object: String,
107 /// List of assistant objects.
108 pub data: Vec<AssistantObject>,
109 /// Optional headers associated with the list of assistants.
110 pub headers: Option<HashMap<String, String>>,
111}
112
113/// Represents a request to get an assistant file by its ID.
114#[derive(Debug, Serialize, Clone)]
115pub struct AssistantFileRequest {
116 /// Unique identifier for the file.
117 pub file_id: String,
118}
119
120/// Represents an assistant file object with its properties.
121#[derive(Debug, Deserialize, Serialize)]
122pub struct AssistantFileObject {
123 /// Unique identifier for the file.
124 pub id: String,
125 /// Object type, typically "file".
126 pub object: String,
127 /// Timestamp of when the file was created.
128 pub created_at: i64,
129 /// Unique identifier for the assistant associated with the file.
130 pub assistant_id: String,
131 /// Optional headers associated with the file.
132 pub headers: Option<HashMap<String, String>>,
133}
134
135/// Represents a list of assistant files.
136#[derive(Debug, Deserialize, Serialize)]
137pub struct ListAssistantFile {
138 /// Object type, typically "list".
139 pub object: String,
140 /// List of assistant file objects.
141 pub data: Vec<AssistantFileObject>,
142 /// Optional headers associated with the list of assistant files.
143 pub headers: Option<HashMap<String, String>>,
144}