use super::client::MediaFile;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ChatRole {
System,
User,
Assistant,
}
impl ChatRole {
pub fn as_str(&self) -> &'static str {
match self {
ChatRole::System => "system",
ChatRole::User => "user",
ChatRole::Assistant => "assistant",
}
}
}
#[derive(Debug, Clone)]
pub struct ChatMessage {
pub role: ChatRole,
pub content: String,
pub media: Vec<MediaFile>,
}
impl ChatMessage {
pub fn new(role: ChatRole, content: impl Into<String>) -> Self {
Self {
role,
content: content.into(),
media: Vec::new(),
}
}
pub fn user(content: impl Into<String>) -> Self {
Self::new(ChatRole::User, content)
}
pub fn user_with_media(content: impl Into<String>, media: Vec<MediaFile>) -> Self {
let mut msg = Self::new(ChatRole::User, content);
msg.media = media;
msg
}
pub fn assistant(content: impl Into<String>) -> Self {
Self::new(ChatRole::Assistant, content)
}
pub fn system(content: impl Into<String>) -> Self {
Self::new(ChatRole::System, content)
}
}
#[derive(Debug)]
pub struct MaterializeInternalOutput<T> {
pub data: T,
#[allow(dead_code)]
pub raw_response: String,
pub usage: Option<crate::backend::TokenUsage>,
}
impl<T> MaterializeInternalOutput<T> {
pub fn new(data: T, raw_response: String, usage: Option<crate::backend::TokenUsage>) -> Self {
Self {
data,
raw_response,
usage,
}
}
}
#[derive(Debug, Clone)]
pub struct ValidationFailureContext {
pub error_message: String,
pub raw_response: String,
}
impl ValidationFailureContext {
pub fn new(error_message: impl Into<String>, raw_response: impl Into<String>) -> Self {
Self {
error_message: error_message.into(),
raw_response: raw_response.into(),
}
}
}