systemprompt_models/artifacts/cli/
mod.rs1use schemars::JsonSchema;
33use serde::{Deserialize, Serialize};
34
35use super::{
36 AudioArtifact, ChartArtifact, CopyPasteTextArtifact, DashboardArtifact, ImageArtifact,
37 ListArtifact, MessageArtifact, PresentationCardArtifact, TableArtifact, TextArtifact,
38 VideoArtifact,
39};
40
41#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
42#[serde(tag = "artifact_type", rename_all = "snake_case")]
43pub enum CliArtifact {
44 Table {
45 #[serde(flatten)]
46 artifact: TableArtifact,
47 },
48 List {
49 #[serde(flatten)]
50 artifact: ListArtifact,
51 },
52 Text {
53 #[serde(flatten)]
54 artifact: TextArtifact,
55 },
56 #[serde(rename = "copy_paste_text")]
57 CopyPasteText {
58 #[serde(flatten)]
59 artifact: CopyPasteTextArtifact,
60 },
61 Dashboard {
62 #[serde(flatten)]
63 artifact: DashboardArtifact,
64 },
65 Chart {
66 #[serde(flatten)]
67 artifact: ChartArtifact,
68 },
69 Audio {
70 #[serde(flatten)]
71 artifact: AudioArtifact,
72 },
73 Image {
74 #[serde(flatten)]
75 artifact: ImageArtifact,
76 },
77 Video {
78 #[serde(flatten)]
79 artifact: VideoArtifact,
80 },
81 #[serde(rename = "presentation_card")]
82 PresentationCard {
83 #[serde(flatten)]
84 artifact: PresentationCardArtifact,
85 },
86 Message {
87 #[serde(flatten)]
88 artifact: MessageArtifact,
89 },
90}
91
92impl CliArtifact {
93 pub const ENVELOPE_TYPE_STR: &'static str = "cli";
94
95 #[must_use]
96 pub const fn artifact_type_str(&self) -> &'static str {
97 match self {
98 Self::Table { .. } => TableArtifact::ARTIFACT_TYPE_STR,
99 Self::List { .. } => ListArtifact::ARTIFACT_TYPE_STR,
100 Self::Text { .. } => TextArtifact::ARTIFACT_TYPE_STR,
101 Self::CopyPasteText { .. } => CopyPasteTextArtifact::ARTIFACT_TYPE_STR,
102 Self::Dashboard { .. } => DashboardArtifact::ARTIFACT_TYPE_STR,
103 Self::Chart { .. } => ChartArtifact::ARTIFACT_TYPE_STR,
104 Self::Audio { .. } => AudioArtifact::ARTIFACT_TYPE_STR,
105 Self::Image { .. } => ImageArtifact::ARTIFACT_TYPE_STR,
106 Self::Video { .. } => VideoArtifact::ARTIFACT_TYPE_STR,
107 Self::PresentationCard { .. } => PresentationCardArtifact::ARTIFACT_TYPE_STR,
108 Self::Message { .. } => MessageArtifact::ARTIFACT_TYPE_STR,
109 }
110 }
111
112 #[must_use]
113 pub fn title(&self) -> Option<String> {
114 match self {
115 Self::Text { artifact } => artifact.title.clone(),
116 Self::CopyPasteText { artifact } => artifact.title.clone(),
117 Self::Dashboard { artifact } => Some(artifact.title.clone()),
118 Self::Audio { artifact } => artifact.title.clone(),
119 Self::PresentationCard { artifact } => Some(artifact.title.clone()),
120 Self::Table { artifact } => artifact.title.clone(),
121 Self::Chart { artifact } => Some(artifact.title.clone()),
125 Self::List { .. } | Self::Image { .. } | Self::Video { .. } | Self::Message { .. } => {
127 None
128 },
129 }
130 }
131
132 #[must_use]
133 pub fn text_body(&self) -> Option<String> {
134 match self {
135 Self::Text { artifact } => Some(artifact.content.clone()),
136 Self::CopyPasteText { artifact } => Some(artifact.content.clone()),
137 _ => None,
138 }
139 }
140
141 #[must_use]
142 pub const fn table(artifact: TableArtifact) -> Self {
143 Self::Table { artifact }
144 }
145
146 #[must_use]
147 pub const fn list(artifact: ListArtifact) -> Self {
148 Self::List { artifact }
149 }
150
151 #[must_use]
152 pub const fn text(artifact: TextArtifact) -> Self {
153 Self::Text { artifact }
154 }
155
156 #[must_use]
157 pub const fn copy_paste_text(artifact: CopyPasteTextArtifact) -> Self {
158 Self::CopyPasteText { artifact }
159 }
160
161 #[must_use]
162 pub const fn dashboard(artifact: DashboardArtifact) -> Self {
163 Self::Dashboard { artifact }
164 }
165
166 #[must_use]
167 pub const fn chart(artifact: ChartArtifact) -> Self {
168 Self::Chart { artifact }
169 }
170
171 #[must_use]
172 pub const fn audio(artifact: AudioArtifact) -> Self {
173 Self::Audio { artifact }
174 }
175
176 #[must_use]
177 pub const fn image(artifact: ImageArtifact) -> Self {
178 Self::Image { artifact }
179 }
180
181 #[must_use]
182 pub const fn video(artifact: VideoArtifact) -> Self {
183 Self::Video { artifact }
184 }
185
186 #[must_use]
187 pub const fn presentation_card(artifact: PresentationCardArtifact) -> Self {
188 Self::PresentationCard { artifact }
189 }
190
191 #[must_use]
192 pub const fn message(artifact: MessageArtifact) -> Self {
193 Self::Message { artifact }
194 }
195}