1use derive_builder::Builder;
2use serde::{Deserialize, Serialize};
3
4use crate::error::OpenAIError;
5use crate::spec::Metadata;
6use crate::spec::responses::{
7 AnyItemReference, CodeInterpreterToolCall, ComputerToolCall, CustomToolCall,
8 CustomToolCallOutput, FileSearchToolCall, ImageGenToolCall, InputFileContent,
9 InputImageContent, InputItem, InputTextContent, LocalShellToolCall, LocalShellToolCallOutput,
10 MCPApprovalRequest, MCPApprovalResponse, MCPListTools, MCPToolCall, OutputTextContent,
11 ReasoningItem, ReasoningTextContent, RefusalContent, WebSearchToolCall,
12};
13
14#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
16pub struct ConversationResource {
17 pub id: String,
19 pub object: String,
21 pub metadata: Metadata,
23 pub created_at: u64,
25}
26
27#[derive(Clone, Serialize, Default, Debug, Deserialize, Builder, PartialEq)]
30#[builder(name = "CreateConversationRequestArgs")]
31#[builder(pattern = "mutable")]
32#[builder(setter(into, strip_option), default)]
33#[builder(derive(Debug))]
34#[builder(build_fn(error = "OpenAIError"))]
35pub struct CreateConversationRequest {
36 #[serde(skip_serializing_if = "Option::is_none")]
38 pub metadata: Option<Metadata>,
39
40 #[serde(skip_serializing_if = "Option::is_none")]
42 pub items: Option<Vec<InputItem>>,
43}
44
45#[derive(Clone, Serialize, Default, Debug, Deserialize, Builder, PartialEq)]
47#[builder(name = "UpdateConversationRequestArgs")]
48#[builder(pattern = "mutable")]
49#[builder(setter(into, strip_option), default)]
50#[builder(derive(Debug))]
51#[builder(build_fn(error = "OpenAIError"))]
52pub struct UpdateConversationRequest {
53 pub metadata: Metadata,
55}
56
57#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
59pub struct DeleteConversationResponse {
60 pub id: String,
62 pub object: String,
64 pub deleted: bool,
66}
67
68#[derive(Clone, Serialize, Default, Debug, Deserialize, Builder, PartialEq)]
70#[builder(name = "CreateConversationItemsRequestArgs")]
71#[builder(pattern = "mutable")]
72#[builder(setter(into, strip_option), default)]
73#[builder(derive(Debug))]
74#[builder(build_fn(error = "OpenAIError"))]
75pub struct CreateConversationItemsRequest {
76 pub items: Vec<InputItem>,
78}
79
80#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
82pub struct ConversationItemList {
83 pub object: String,
85 pub data: Vec<ConversationItem>,
87 pub has_more: bool,
89 pub first_id: Option<String>,
91 pub last_id: Option<String>,
93}
94
95#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
96#[serde(rename_all = "snake_case")]
97pub enum MessageStatus {
98 InProgress,
99 Incomplete,
100 Completed,
101}
102
103#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
104#[serde(rename_all = "snake_case")]
105pub enum MessageRole {
106 Unknown,
107 User,
108 Assistant,
109 System,
110 Critic,
111 Discriminator,
112 Developer,
113 Tool,
114}
115
116#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
117pub struct TextContent {
118 pub text: String,
119}
120
121#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
122pub struct SummaryTextContent {
123 pub text: String,
125}
126
127#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
128pub struct ComputerScreenContent {
129 pub image_url: Option<String>,
131 pub file_id: Option<String>,
133}
134
135#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
136#[serde(tag = "type", rename_all = "snake_case")]
137pub enum MessageContent {
138 InputText(InputTextContent),
139 OutputText(OutputTextContent),
140 Text(TextContent),
141 SummaryText(SummaryTextContent),
142 ReasoningText(ReasoningTextContent),
143 Refusal(RefusalContent),
144 InputImage(InputImageContent),
145 ComputerScreen(ComputerScreenContent),
146 InputFile(InputFileContent),
147}
148
149#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
150pub struct Message {
151 pub id: String,
153 pub status: MessageStatus,
156 pub role: MessageRole,
159 pub content: Vec<MessageContent>,
161}
162
163#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
164#[serde(tag = "type", rename_all = "snake_case")]
165pub enum ConversationItem {
166 Message(Message),
167 FileSearchCall(FileSearchToolCall),
168 WebSearchCall(WebSearchToolCall),
169 ImageGenerationCall(ImageGenToolCall),
170 ComputerCall(ComputerToolCall),
171 Reasoning(ReasoningItem),
172 CodeInterpreterCall(CodeInterpreterToolCall),
173 LocalShellCall(LocalShellToolCall),
174 LocalShellCallOutput(LocalShellToolCallOutput),
175 McpListTools(MCPListTools),
176 McpApprovalRequest(MCPApprovalRequest),
177 McpApprovalResponse(MCPApprovalResponse),
178 McpCall(MCPToolCall),
179 CustomToolCall(CustomToolCall),
180 CustomToolCallOutput(CustomToolCallOutput),
181 #[serde(untagged)]
182 ItemReference(AnyItemReference),
183}
184
185#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
187#[serde(rename_all = "snake_case")]
188pub enum IncludeParam {
189 #[serde(rename = "web_search_call.action.sources")]
191 WebSearchCallActionSources,
192 #[serde(rename = "code_interpreter_call.outputs")]
194 CodeInterpreterCallOutputs,
195 #[serde(rename = "computer_call_output.output.image_url")]
197 ComputerCallOutputOutputImageUrl,
198 #[serde(rename = "file_search_call.results")]
200 FileSearchCallResults,
201 #[serde(rename = "message.input_image.image_url")]
203 MessageInputImageImageUrl,
204 #[serde(rename = "message.output_text.logprobs")]
206 MessageOutputTextLogprobs,
207 #[serde(rename = "reasoning.encrypted_content")]
209 ReasoningEncryptedContent,
210}
211
212#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
214#[serde(rename_all = "lowercase")]
215pub enum ListOrder {
216 Asc,
218 Desc,
220}