async_llm/types/
prediction_content.rsuse serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
#[serde(content = "content")]
pub enum PredictionContent {
Content(PredictionContentContent),
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
#[serde(rename_all = "snake_case")]
pub enum PredictionContentContent {
Text(String),
Array(Vec<PredictionContentPart>),
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
pub enum PredictionContentPart {
Text { text: String },
}
impl Default for PredictionContent {
fn default() -> Self {
Self::Content("".into())
}
}
impl From<&str> for PredictionContent {
fn from(value: &str) -> Self {
Self::Content(value.into())
}
}
impl From<&str> for PredictionContentContent {
fn from(value: &str) -> Self {
Self::Text(value.into())
}
}
impl From<Vec<&str>> for PredictionContent {
fn from(value: Vec<&str>) -> Self {
Self::Content(value.into())
}
}
impl From<Vec<&str>> for PredictionContentContent {
fn from(value: Vec<&str>) -> Self {
Self::Array(
value
.into_iter()
.map(|v| PredictionContentPart::Text {
text: v.to_string(),
})
.collect(),
)
}
}