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
125
126
127
128
129
130
131
132
133
134
/*
* OpenAI API
*
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.3.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// RealtimeConversationItemWithReference : The item to add to the conversation.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeConversationItemWithReference {
/// For an item of type (`message` | `function_call` | `function_call_output`) this field allows the client to assign the unique ID of the item. It is not required because the server will generate one if not provided. For an item of type `item_reference`, this field is required and is a reference to any item that has previously existed in the conversation.
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
/// The type of the item (`message`, `function_call`, `function_call_output`, `item_reference`).
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<Type>,
/// Identifier for the API object being returned - always `realtime.item`.
#[serde(rename = "object", skip_serializing_if = "Option::is_none")]
pub object: Option<Object>,
/// The status of the item (`completed`, `incomplete`, `in_progress`). These have no effect on the conversation, but are accepted for consistency with the `conversation.item.created` event.
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
pub status: Option<Status>,
/// The role of the message sender (`user`, `assistant`, `system`), only applicable for `message` items.
#[serde(rename = "role", skip_serializing_if = "Option::is_none")]
pub role: Option<Role>,
/// The content of the message, applicable for `message` items. - Message items of role `system` support only `input_text` content - Message items of role `user` support `input_text` and `input_audio` content - Message items of role `assistant` support `text` content.
#[serde(rename = "content", skip_serializing_if = "Option::is_none")]
pub content: Option<Vec<models::RealtimeConversationItemWithReferenceContentInner>>,
/// The ID of the function call (for `function_call` and `function_call_output` items). If passed on a `function_call_output` item, the server will check that a `function_call` item with the same ID exists in the conversation history.
#[serde(rename = "call_id", skip_serializing_if = "Option::is_none")]
pub call_id: Option<String>,
/// The name of the function being called (for `function_call` items).
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// The arguments of the function call (for `function_call` items).
#[serde(rename = "arguments", skip_serializing_if = "Option::is_none")]
pub arguments: Option<String>,
/// The output of the function call (for `function_call_output` items).
#[serde(rename = "output", skip_serializing_if = "Option::is_none")]
pub output: Option<String>,
}
impl RealtimeConversationItemWithReference {
/// The item to add to the conversation.
pub fn new() -> RealtimeConversationItemWithReference {
RealtimeConversationItemWithReference {
id: None,
r#type: None,
object: None,
status: None,
role: None,
content: None,
call_id: None,
name: None,
arguments: None,
output: None,
}
}
}
/// The type of the item (`message`, `function_call`, `function_call_output`, `item_reference`).
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "message")]
Message,
#[serde(rename = "function_call")]
FunctionCall,
#[serde(rename = "function_call_output")]
FunctionCallOutput,
}
impl Default for Type {
fn default() -> Type {
Self::Message
}
}
/// Identifier for the API object being returned - always `realtime.item`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
#[serde(rename = "realtime.item")]
RealtimeItem,
}
impl Default for Object {
fn default() -> Object {
Self::RealtimeItem
}
}
/// The status of the item (`completed`, `incomplete`, `in_progress`). These have no effect on the conversation, but are accepted for consistency with the `conversation.item.created` event.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
#[serde(rename = "completed")]
Completed,
#[serde(rename = "incomplete")]
Incomplete,
#[serde(rename = "in_progress")]
InProgress,
}
impl Default for Status {
fn default() -> Status {
Self::Completed
}
}
/// The role of the message sender (`user`, `assistant`, `system`), only applicable for `message` items.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Role {
#[serde(rename = "user")]
User,
#[serde(rename = "assistant")]
Assistant,
#[serde(rename = "system")]
System,
}
impl Default for Role {
fn default() -> Role {
Self::User
}
}
impl std::fmt::Display for RealtimeConversationItemWithReference {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}