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