async_llm/types/
content.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4#[serde(untagged)]
5pub enum Content {
6 Text(String),
7 Array(Vec<String>),
8}
9
10impl Default for Content {
11 fn default() -> Self {
12 Self::Text("".into())
13 }
14}
15
16impl From<&str> for Content {
17 fn from(value: &str) -> Self {
18 Self::Text(value.into())
19 }
20}
21
22impl From<String> for Content {
23 fn from(value: String) -> Self {
24 Self::Text(value)
25 }
26}
27
28impl From<Vec<&str>> for Content {
29 fn from(value: Vec<&str>) -> Self {
30 Self::Array(value.iter().map(|v| v.to_string()).collect())
31 }
32}
33
34impl From<Vec<String>> for Content {
35 fn from(array: Vec<String>) -> Self {
36 Self::Array(array)
37 }
38}