mur_common/companion/
content_seed.rs1use crate::companion::Situation;
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
9pub struct SituationFile {
10 pub situation: Situation,
11 pub locale: String,
12 pub templates: Vec<TemplateSeed>,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
16pub struct TemplateSeed {
17 pub id: String,
18 #[serde(default = "default_weight")]
19 pub weight: f32,
20 pub cooldown_days: u32,
21 #[serde(default)]
22 pub tags: Vec<String>,
23 pub source: String,
24 pub reviewed_by: String,
25 pub prompt_seed: String,
26}
27
28fn default_weight() -> f32 {
29 1.0
30}
31
32pub const MORNING_GREETING_ZH_TW: &str = include_str!("content/morning_greeting.zh-TW.yaml");
33pub const MORNING_GREETING_EN_US: &str = include_str!("content/morning_greeting.en-US.yaml");
34pub const GENTLE_CHECK_IN_ZH_TW: &str = include_str!("content/gentle_check_in.zh-TW.yaml");
35pub const GENTLE_CHECK_IN_EN_US: &str = include_str!("content/gentle_check_in.en-US.yaml");
36pub const SHARE_QUOTE_ZH_TW: &str = include_str!("content/share_quote.zh-TW.yaml");
37pub const SHARE_QUOTE_EN_US: &str = include_str!("content/share_quote.en-US.yaml");
38pub const SHARE_LINK_ZH_TW: &str = include_str!("content/share_link.zh-TW.yaml");
39pub const SHARE_LINK_EN_US: &str = include_str!("content/share_link.en-US.yaml");
40
41pub fn all_seeds() -> Vec<(Situation, &'static str, &'static str)> {
44 use Situation::*;
45 vec![
46 (MorningGreeting, "zh-TW", MORNING_GREETING_ZH_TW),
47 (MorningGreeting, "en-US", MORNING_GREETING_EN_US),
48 (GentleCheckIn, "zh-TW", GENTLE_CHECK_IN_ZH_TW),
49 (GentleCheckIn, "en-US", GENTLE_CHECK_IN_EN_US),
50 (ShareQuote, "zh-TW", SHARE_QUOTE_ZH_TW),
51 (ShareQuote, "en-US", SHARE_QUOTE_EN_US),
52 (ShareLink, "zh-TW", SHARE_LINK_ZH_TW),
53 (ShareLink, "en-US", SHARE_LINK_EN_US),
54 ]
55}
56
57pub fn parse(yaml: &str) -> Result<SituationFile, serde_yaml_ng::Error> {
59 serde_yaml_ng::from_str(yaml)
60}