From 223c62954d3c4bd34f7b7ac83815da6759e3aa9e Mon Sep 17 00:00:00 2001 From: Advay Patil Date: Tue, 26 Aug 2025 14:56:36 -0700 Subject: [PATCH 1/2] Update `OutputItem` to align with OpenAI's Specification --- async-openai/src/types/responses.rs | 38 ++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/async-openai/src/types/responses.rs b/async-openai/src/types/responses.rs index 4d036319..ed969b89 100644 --- a/async-openai/src/types/responses.rs +++ b/async-openai/src/types/responses.rs @@ -2104,20 +2104,34 @@ pub struct ResponseMetadata { /// Output item #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +#[serde(tag = "type")] +#[serde(rename_all = "snake_case")] #[non_exhaustive] -pub struct OutputItem { - pub id: String, +pub enum OutputItem { + Message(OutputMessage), + FileSearchCall(FileSearchCallOutput), + FunctionCall(FunctionCall), + WebSearchCall(WebSearchCallOutput), + ComputerCall(ComputerCallOutput), + Reasoning(ReasoningItem), + ImageGenerationCall(ImageGenerationCallOutput), + CodeInterpreterCall(CodeInterpreterCallOutput), + LocalShellCall(LocalShellCallOutput), + McpCall(McpCallOutput), + McpListTools(McpListToolsOutput), + McpApprovalRequest(McpApprovalRequestOutput), + CustomToolCall(CustomToolCallOutput), +} + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +#[non_exhaustive] +pub struct CustomToolCallOutput { + pub call_id: String, + pub input: String, + pub name: String, #[serde(rename = "type")] - pub item_type: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub status: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub content: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub role: Option, - /// For reasoning items - summary paragraphs - #[serde(skip_serializing_if = "Option::is_none")] - pub summary: Option>, + pub output_type: String, + pub id: String, } /// Content part From 29e107a0ab20f068ac3a3d8e9db26ad17793269a Mon Sep 17 00:00:00 2001 From: Advay Patil Date: Tue, 26 Aug 2025 15:19:28 -0700 Subject: [PATCH 2/2] Update --- async-openai/src/types/responses.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/async-openai/src/types/responses.rs b/async-openai/src/types/responses.rs index ed969b89..f77ad7b7 100644 --- a/async-openai/src/types/responses.rs +++ b/async-openai/src/types/responses.rs @@ -2129,8 +2129,6 @@ pub struct CustomToolCallOutput { pub call_id: String, pub input: String, pub name: String, - #[serde(rename = "type")] - pub output_type: String, pub id: String, }