/*
* 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};
/// RealtimeBetaServerEventConversationItemCreated : Returned when a conversation item is created. There are several scenarios that produce this event: - The server is generating a Response, which if successful will produce either one or two Items, which will be of type `message` (role `assistant`) or type `function_call`. - The input audio buffer has been committed, either by the client or the server (in `server_vad` mode). The server will take the content of the input audio buffer and add it to a new user message Item. - The client has sent a `conversation.item.create` event to add a new Item to the Conversation.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeBetaServerEventConversationItemCreated {
/// The unique ID of the server event.
#[serde(rename = "event_id")]
pub event_id: String,
/// The event type, must be `conversation.item.created`.
#[serde(rename = "type")]
pub r#type: Type,
/// The ID of the preceding item in the Conversation context, allows the client to understand the order of the conversation. Can be `null` if the item has no predecessor.
#[serde(
rename = "previous_item_id",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub previous_item_id: Option<Option<String>>,
#[serde(rename = "item")]
pub item: Box<models::RealtimeConversationItem>,
}
impl RealtimeBetaServerEventConversationItemCreated {
/// Returned when a conversation item is created. There are several scenarios that produce this event: - The server is generating a Response, which if successful will produce either one or two Items, which will be of type `message` (role `assistant`) or type `function_call`. - The input audio buffer has been committed, either by the client or the server (in `server_vad` mode). The server will take the content of the input audio buffer and add it to a new user message Item. - The client has sent a `conversation.item.create` event to add a new Item to the Conversation.
pub fn new(
event_id: String,
r#type: Type,
item: models::RealtimeConversationItem,
) -> RealtimeBetaServerEventConversationItemCreated {
RealtimeBetaServerEventConversationItemCreated {
event_id,
r#type,
previous_item_id: None,
item: Box::new(item),
}
}
}
/// The event type, must be `conversation.item.created`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "conversation.item.created")]
ConversationItemCreated,
}
impl Default for Type {
fn default() -> Type {
Self::ConversationItemCreated
}
}
impl std::fmt::Display for RealtimeBetaServerEventConversationItemCreated {
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),
}
}
}