use crate::{chat, error};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ChatCompletionChunk {
pub index: u64,
#[serde(flatten)]
pub inner: chat::completions::response::streaming::ChatCompletionChunk,
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<error::ResponseError>,
}
impl ChatCompletionChunk {
pub fn push(&mut self, other: &ChatCompletionChunk) {
self.inner.push(&other.inner);
match (&mut self.error, &other.error) {
(None, Some(other_error)) => {
self.error = Some(other_error.clone());
}
_ => {}
}
}
}