Skip to content

Commit a8bb897

Browse files
authored
fix: Update OutputItem to align with OpenAI's Specification (#426)
* Update `OutputItem` to align with OpenAI's Specification * Update
1 parent 64d16cc commit a8bb897

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

async-openai/src/types/responses.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,20 +2104,32 @@ pub struct ResponseMetadata {
21042104

21052105
/// Output item
21062106
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2107+
#[serde(tag = "type")]
2108+
#[serde(rename_all = "snake_case")]
21072109
#[non_exhaustive]
2108-
pub struct OutputItem {
2110+
pub enum OutputItem {
2111+
Message(OutputMessage),
2112+
FileSearchCall(FileSearchCallOutput),
2113+
FunctionCall(FunctionCall),
2114+
WebSearchCall(WebSearchCallOutput),
2115+
ComputerCall(ComputerCallOutput),
2116+
Reasoning(ReasoningItem),
2117+
ImageGenerationCall(ImageGenerationCallOutput),
2118+
CodeInterpreterCall(CodeInterpreterCallOutput),
2119+
LocalShellCall(LocalShellCallOutput),
2120+
McpCall(McpCallOutput),
2121+
McpListTools(McpListToolsOutput),
2122+
McpApprovalRequest(McpApprovalRequestOutput),
2123+
CustomToolCall(CustomToolCallOutput),
2124+
}
2125+
2126+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2127+
#[non_exhaustive]
2128+
pub struct CustomToolCallOutput {
2129+
pub call_id: String,
2130+
pub input: String,
2131+
pub name: String,
21092132
pub id: String,
2110-
#[serde(rename = "type")]
2111-
pub item_type: String,
2112-
#[serde(skip_serializing_if = "Option::is_none")]
2113-
pub status: Option<String>,
2114-
#[serde(skip_serializing_if = "Option::is_none")]
2115-
pub content: Option<Vec<ContentPart>>,
2116-
#[serde(skip_serializing_if = "Option::is_none")]
2117-
pub role: Option<String>,
2118-
/// For reasoning items - summary paragraphs
2119-
#[serde(skip_serializing_if = "Option::is_none")]
2120-
pub summary: Option<Vec<serde_json::Value>>,
21212133
}
21222134

21232135
/// Content part

0 commit comments

Comments
 (0)