systemprompt_models/artifacts/copy_paste_text/
mod.rs1use crate::artifacts::metadata::ExecutionMetadata;
2use crate::artifacts::traits::Artifact;
3use crate::artifacts::types::ArtifactType;
4use crate::execution::context::RequestContext;
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7use serde_json::{json, Value as JsonValue};
8use systemprompt_identifiers::SkillId;
9
10fn default_artifact_type() -> String {
11 "copy_paste_text".to_string()
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
15pub struct CopyPasteTextArtifact {
16 #[serde(rename = "x-artifact-type")]
17 #[serde(default = "default_artifact_type")]
18 pub artifact_type: String,
19 pub content: String,
20 #[serde(skip_serializing_if = "Option::is_none")]
21 pub title: Option<String>,
22 #[serde(skip_serializing_if = "Option::is_none")]
23 pub language: Option<String>,
24 #[serde(skip)]
25 #[schemars(skip)]
26 metadata: ExecutionMetadata,
27}
28
29impl CopyPasteTextArtifact {
30 pub const ARTIFACT_TYPE_STR: &'static str = "copy_paste_text";
31
32 pub fn new(content: impl Into<String>, ctx: &RequestContext) -> Self {
33 Self {
34 artifact_type: "copy_paste_text".to_string(),
35 content: content.into(),
36 title: None,
37 language: None,
38 metadata: ExecutionMetadata::with_request(ctx),
39 }
40 }
41
42 pub fn with_title(mut self, title: impl Into<String>) -> Self {
43 self.title = Some(title.into());
44 self
45 }
46
47 pub fn with_language(mut self, language: impl Into<String>) -> Self {
48 self.language = Some(language.into());
49 self
50 }
51
52 pub fn with_execution_id(mut self, id: impl Into<String>) -> Self {
53 self.metadata.execution_id = Some(id.into());
54 self
55 }
56
57 pub fn with_skill(
58 mut self,
59 skill_id: impl Into<SkillId>,
60 skill_name: impl Into<String>,
61 ) -> Self {
62 self.metadata.skill_id = Some(skill_id.into());
63 self.metadata.skill_name = Some(skill_name.into());
64 self
65 }
66}
67
68impl Artifact for CopyPasteTextArtifact {
69 fn artifact_type(&self) -> ArtifactType {
70 ArtifactType::CopyPasteText
71 }
72
73 fn to_schema(&self) -> JsonValue {
74 json!({
75 "type": "object",
76 "properties": {
77 "content": {
78 "type": "string",
79 "description": "Text content to be copied"
80 },
81 "title": {
82 "type": "string",
83 "description": "Optional title for the content"
84 },
85 "language": {
86 "type": "string",
87 "description": "Optional language for syntax highlighting"
88 }
89 },
90 "required": ["content"],
91 "x-artifact-type": "copy_paste_text"
92 })
93 }
94}