use derive_builder::Builder;
use serde::{Deserialize, Serialize};
use crate::{
error::OpenAIError,
types::responses::{
AnyItemReference, ApplyPatchToolCall, ApplyPatchToolCallOutput, CodeInterpreterToolCall,
ComputerToolCall, CustomToolCall, CustomToolCallOutput, FileSearchToolCall,
FunctionShellCall, FunctionShellCallOutput, ImageGenToolCall, InputFileContent,
InputImageContent, InputItem, InputTextContent, LocalShellToolCall,
LocalShellToolCallOutput, MCPApprovalRequest, MCPApprovalResponse, MCPListTools,
MCPToolCall, OutputTextContent, ReasoningItem, ReasoningTextContent, RefusalContent,
ToolSearchCall, ToolSearchOutput, WebSearchToolCall,
},
};
use crate::types::Metadata;
#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
pub struct ConversationResource {
pub id: String,
pub object: String,
pub metadata: Metadata,
pub created_at: u64,
}
#[derive(Clone, Serialize, Default, Debug, Deserialize, Builder, PartialEq)]
#[builder(name = "CreateConversationRequestArgs")]
#[builder(pattern = "mutable")]
#[builder(setter(into, strip_option), default)]
#[builder(derive(Debug))]
#[builder(build_fn(error = "OpenAIError"))]
pub struct CreateConversationRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Metadata>,
#[serde(skip_serializing_if = "Option::is_none")]
pub items: Option<Vec<InputItem>>,
}
#[derive(Clone, Serialize, Default, Debug, Deserialize, Builder, PartialEq)]
#[builder(name = "UpdateConversationRequestArgs")]
#[builder(pattern = "mutable")]
#[builder(setter(into, strip_option), default)]
#[builder(derive(Debug))]
#[builder(build_fn(error = "OpenAIError"))]
pub struct UpdateConversationRequest {
pub metadata: Metadata,
}
#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
pub struct DeleteConversationResponse {
pub id: String,
pub object: String,
pub deleted: bool,
}
#[derive(Clone, Serialize, Default, Debug, Deserialize, Builder, PartialEq)]
#[builder(name = "CreateConversationItemsRequestArgs")]
#[builder(pattern = "mutable")]
#[builder(setter(into, strip_option), default)]
#[builder(derive(Debug))]
#[builder(build_fn(error = "OpenAIError"))]
pub struct CreateConversationItemsRequest {
pub items: Vec<InputItem>,
}
#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
pub struct ConversationItemList {
pub object: String,
pub data: Vec<ConversationItem>,
pub has_more: bool,
pub first_id: Option<String>,
pub last_id: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum MessageStatus {
InProgress,
Incomplete,
Completed,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum MessageRole {
Unknown,
User,
Assistant,
System,
Critic,
Discriminator,
Developer,
Tool,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct TextContent {
pub text: String,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct SummaryTextContent {
pub text: String,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct ComputerScreenContent {
pub image_url: Option<String>,
pub file_id: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum MessageContent {
InputText(InputTextContent),
OutputText(OutputTextContent),
Text(TextContent),
SummaryText(SummaryTextContent),
ReasoningText(ReasoningTextContent),
Refusal(RefusalContent),
InputImage(InputImageContent),
ComputerScreen(ComputerScreenContent),
InputFile(InputFileContent),
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct Message {
pub id: String,
pub status: MessageStatus,
pub role: MessageRole,
pub content: Vec<MessageContent>,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum ConversationItem {
Message(Message),
FileSearchCall(FileSearchToolCall),
WebSearchCall(WebSearchToolCall),
ImageGenerationCall(ImageGenToolCall),
ComputerCall(ComputerToolCall),
ToolSearchCall(ToolSearchCall),
ToolSearchOutput(ToolSearchOutput),
Reasoning(ReasoningItem),
CodeInterpreterCall(CodeInterpreterToolCall),
LocalShellCall(LocalShellToolCall),
LocalShellCallOutput(LocalShellToolCallOutput),
ShellCall(FunctionShellCall),
ShellCallOutput(FunctionShellCallOutput),
ApplyPatchCall(ApplyPatchToolCall),
ApplyPatchCallOutput(ApplyPatchToolCallOutput),
McpListTools(MCPListTools),
McpApprovalRequest(MCPApprovalRequest),
McpApprovalResponse(MCPApprovalResponse),
McpCall(MCPToolCall),
CustomToolCall(CustomToolCall),
CustomToolCallOutput(CustomToolCallOutput),
#[serde(untagged)]
ItemReference(AnyItemReference),
}
#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IncludeParam {
#[serde(rename = "web_search_call.action.sources")]
WebSearchCallActionSources,
#[serde(rename = "code_interpreter_call.outputs")]
CodeInterpreterCallOutputs,
#[serde(rename = "computer_call_output.output.image_url")]
ComputerCallOutputOutputImageUrl,
#[serde(rename = "file_search_call.results")]
FileSearchCallResults,
#[serde(rename = "message.input_image.image_url")]
MessageInputImageImageUrl,
#[serde(rename = "message.output_text.logprobs")]
MessageOutputTextLogprobs,
#[serde(rename = "reasoning.encrypted_content")]
ReasoningEncryptedContent,
}
#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum ListOrder {
Asc,
Desc,
}