systemprompt_models/artifacts/
research.rs1use crate::artifacts::card::PresentationCardResponse;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
6pub struct ResearchArtifact {
7 #[serde(flatten)]
8 pub card: PresentationCardResponse,
9 pub topic: String,
10 pub sources: Vec<SourceCitation>,
11 pub query_count: u32,
12 pub source_count: u32,
13}
14
15impl ResearchArtifact {
16 pub const ARTIFACT_TYPE: &'static str = "presentation_card";
17
18 pub fn new(
19 topic: impl Into<String>,
20 card: PresentationCardResponse,
21 sources: Vec<SourceCitation>,
22 ) -> Self {
23 let source_count = u32::try_from(sources.len()).unwrap_or(u32::MAX);
24 Self {
25 card,
26 topic: topic.into(),
27 sources,
28 query_count: 0,
29 source_count,
30 }
31 }
32
33 pub const fn with_query_count(mut self, count: u32) -> Self {
34 self.query_count = count;
35 self
36 }
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
40pub struct SourceCitation {
41 pub title: String,
42 pub uri: String,
43 pub relevance: f32,
44}
45
46impl SourceCitation {
47 pub fn new(title: impl Into<String>, uri: impl Into<String>, relevance: f32) -> Self {
48 Self {
49 title: title.into(),
50 uri: uri.into(),
51 relevance,
52 }
53 }
54}