1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Conversation items and content management for the Realtime API.
/// Define a private namespace for conversation-related items.
mod private
{
// Serde imports
use serde::{ Serialize, Deserialize };
/// Represents an item within the Realtime conversation context (message, function call, etc.).
/// Used when creating/retrieving items via client/server events.
///
/// # Used By
/// - `RealtimeClientEventConversationItemCreate`
/// - `RealtimeServerEventConversationItemCreated`
/// - `RealtimeServerEventConversationItemRetrieved`
/// - `RealtimeServerEventResponseOutputItemAdded`
/// - `RealtimeServerEventResponseOutputItemDone`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq, former::Former ) ] // Added Serialize
pub struct RealtimeConversationItem
{
/// The unique ID of the item. Optional when creating, generated by server if omitted.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub id : Option< String >,
/// The type of the item (`message`, `function_call`, `function_call_output`).
pub r#type : String,
/// Identifier for the API object type, always `realtime.item`.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub object : Option< String >,
/// The status of the item (`completed`, `incomplete`). Used for consistency with server events.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub status : Option< String >,
/// The role of the message sender (`user`, `assistant`, `system`), only for `message` items.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub role : Option< String >,
/// The content of the message (text, audio), only for `message` items.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub content : Option< Vec< RealtimeConversationItemContent > >, // Represents array of InputContent or OutputContent parts
/// The ID of the function call, for `function_call` and `function_call_output` items.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub call_id : Option< String >,
/// The name of the function being called, for `function_call` items.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub name : Option< String >,
/// The arguments of the function call (JSON string), for `function_call` items.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub arguments : Option< String >,
/// The output of the function call (JSON string), for `function_call_output` items.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub output : Option< String >,
}
/// Represents an item content within the Realtime conversation item
/// Used when creating/retrieving items via client/server events.
///
/// # Used By
/// - `RealtimeClientEventConversationItem`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq, former::Former ) ] // Added Serialize
pub struct RealtimeConversationItemContent
{
/// The content type (`input_text`, `input_audio`, `item_reference`, `text`).
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub r#type : Option< String >,
/// The text content, used for `input_text` and `text` content types.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub text : Option< String >,
/// ID of a previous conversation item to reference
/// (for `item_reference` content types in `response.create` events).
/// These can reference both client and server created items.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub id : Option< String >,
/// Base64-encoded audio bytes, used for `input_audio` content type.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub audio : Option< String >,
/// The transcript of the audio, used for `input_audio` content type.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub transcript : Option< String >,
}
/// Represents a reference to an existing conversation item or a new item definition.
/// Used in `RealtimeResponseCreateParams` to build context.
///
/// # Used By
/// - `RealtimeResponseCreateParams`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ] // Added Serialize
#[ serde( untagged ) ] // Can be either a reference or a full item definition
pub enum RealtimeConversationItemWithReference
{
/// A reference to an existing item by ID.
Reference
{
/// The ID of the item to reference.
id : String,
/// The type of item to reference, must be "`item_reference`".
r#type : String
},
/// A full definition of a new item to include in the context.
Item( RealtimeConversationItem ),
}
/// Basic information about a Realtime conversation.
///
/// # Used By
/// - `RealtimeServerEventConversationCreated`
#[ derive( Debug, Deserialize, Clone, PartialEq ) ]
pub struct RealtimeConversationInfo
{
/// The unique ID of the conversation.
pub id : String,
/// The object type, must be `realtime.conversation`.
pub object : String,
}
} // end mod private
crate ::mod_interface!
{
exposed use
{
RealtimeConversationItem,
RealtimeConversationItemContent,
RealtimeConversationItemWithReference,
RealtimeConversationInfo,
};
}