1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct InstructionPreset {
    pub name: String,
    pub description: String,
    pub instructions: String,
    pub emoji: String, // New field for emoji
}

#[derive(Debug, Serialize, Deserialize)]
pub struct InstructionPresetLibrary {
    presets: HashMap<String, InstructionPreset>,
}

impl InstructionPresetLibrary {
    pub fn new() -> Self {
        let mut presets = HashMap::new();

        presets.insert(
            "default".to_string(),
            InstructionPreset {
                name: "Default".to_string(),
                description: "Standard professional style".to_string(),
                instructions: "Provide clear, concise, and professional responses. Focus on accuracy and relevance.".to_string(),
                emoji: "📝".to_string(),
            },
        );

        presets.insert(
            "detailed".to_string(),
            InstructionPreset {
                name: "Detailed".to_string(),
                description: "Provide more context and explanation".to_string(),
                instructions: "Offer comprehensive explanations, including background information, potential impacts, and related considerations. Aim for thoroughness while maintaining clarity.".to_string(),
                emoji: "🔍".to_string(),
            },
        );

        presets.insert(
            "concise".to_string(),
            InstructionPreset {
                name: "Concise".to_string(),
                description: "Short and to-the-point responses".to_string(),
                instructions: "Keep responses brief and focused on the core information. Prioritize essential details and avoid unnecessary elaboration.".to_string(),
                emoji: "🎯".to_string(),
            },
        );

        presets.insert(
            "technical".to_string(),
            InstructionPreset {
                name: "Technical".to_string(),
                description: "Focus on technical details".to_string(),
                instructions: "Emphasize technical aspects in your responses. Include specific terminology, methodologies, or performance impacts where relevant. Assume a technically proficient audience.".to_string(),
                emoji: "⚙️".to_string(),
            },
        );

        presets.insert(
            "storyteller".to_string(),
            InstructionPreset {
                name: "Storyteller".to_string(),
                description: "Frame information as part of an ongoing narrative".to_string(),
                instructions: "Present information as if it's part of a larger story. Use narrative elements to describe changes, developments, or features. Connect individual elements to create a cohesive narrative arc.".to_string(),
                emoji: "📚".to_string(),
            },
        );

        presets.insert(
            "emoji-lover".to_string(),
            InstructionPreset {
                name: "Emoji Enthusiast".to_string(),
                description: "Use emojis to enhance communication".to_string(),
                instructions: "Incorporate relevant emojis throughout your responses to add visual flair and quickly convey the nature of the information. Ensure emojis complement rather than replace clear communication.".to_string(),
                emoji: "😍".to_string(),
            },
        );

        presets.insert(
            "formal".to_string(),
            InstructionPreset {
                name: "Formal".to_string(),
                description: "Maintain a highly professional and formal tone".to_string(),
                instructions: "Use formal language and structure in your responses. Avoid colloquialisms and maintain a respectful, business-like tone throughout.".to_string(),
                emoji: "🎩".to_string(),
            },
        );

        presets.insert(
            "explanatory".to_string(),
            InstructionPreset {
                name: "Explanatory".to_string(),
                description: "Focus on explaining concepts and changes".to_string(),
                instructions: "Prioritize explaining the 'why' behind information or changes. Provide context, rationale, and potential implications to foster understanding.".to_string(),
                emoji: "💡".to_string(),
            },
        );

        presets.insert(
            "user-focused".to_string(),
            InstructionPreset {
                name: "User-Focused".to_string(),
                description: "Emphasize user impact and benefits".to_string(),
                instructions: "Frame information in terms of its impact on users or stakeholders. Highlight benefits, improvements, and how changes affect the user experience.".to_string(),
                emoji: "👥".to_string(),
            },
        );

        presets.insert(
            "cosmic".to_string(),
            InstructionPreset {
                name: "Cosmic Oracle".to_string(),
                description: "Channel mystical and cosmic energy".to_string(),
                instructions: "Envision yourself as a cosmic entity, peering into the vast expanse of possibilities. Describe information as if they are celestial events or shifts in the fabric of reality. Use mystical and space-themed language to convey the essence and impact of each element.".to_string(),
                emoji: "🔮".to_string(),
            },
        );

        presets.insert(
            "academic".to_string(),
            InstructionPreset {
                name: "Academic".to_string(),
                description: "Scholarly and research-oriented style".to_string(),
                instructions: "Adopt an academic tone, citing relevant sources or methodologies where applicable. Use precise language and maintain a formal, analytical approach to the subject matter.".to_string(),
                emoji: "🎓".to_string(),
            },
        );

        presets.insert(
            "comparative".to_string(),
            InstructionPreset {
                name: "Comparative".to_string(),
                description: "Highlight differences and similarities".to_string(),
                instructions: "Focus on comparing and contrasting elements. Identify key differences and similarities, and explain their significance or implications.".to_string(),
                emoji: "⚖️".to_string(),
            },
        );

        presets.insert(
            "future-oriented".to_string(),
            InstructionPreset {
                name: "Future-Oriented".to_string(),
                description: "Emphasize future implications and possibilities".to_string(),
                instructions: "Frame information in terms of its future impact. Discuss potential developments, long-term consequences, and how current changes might shape future scenarios.".to_string(),
                emoji: "🔮".to_string(),
            },
        );

        presets.insert(
            "time-traveler".to_string(),
            InstructionPreset {
                name: "Time Traveler".to_string(),
                description: "Narrate from different points in time".to_string(),
                instructions: "Imagine you're a time traveler, jumping between past, present, and future. Describe current information as if you're reporting from different time periods. Use appropriate historical or futuristic language and references, and highlight how perspectives change across time.".to_string(),
                emoji: "⏳".to_string(),
            },
        );

        presets.insert(
            "chef-special".to_string(),
            InstructionPreset {
                name: "Chef's Special".to_string(),
                description: "Present information as a culinary experience".to_string(),
                instructions: "Treat the information as ingredients in a gourmet meal. Describe changes or updates as if you're crafting a recipe or presenting a dish. Use culinary terms, cooking metaphors, and sensory descriptions to make the content more flavorful and engaging.".to_string(),
                emoji: "👩‍🍳".to_string(),
            },
        );

        presets.insert(
            "superhero-saga".to_string(),
            InstructionPreset {
                name: "Superhero Saga".to_string(),
                description: "Frame information in a superhero universe".to_string(),
                instructions: "Imagine the project or product as a superhero universe. Describe features, changes, or updates as if they're superpowers, epic battles, or heroic adventures. Use dramatic, comic-book style language and frame developments in terms of heroes, villains, and saving the day.".to_string(),
                emoji: "🦸".to_string(),
            },
        );

        presets.insert(
            "nature-documentary".to_string(),
            InstructionPreset {
                name: "Nature Documentary".to_string(),
                description: "Narrate as if observing a natural phenomenon".to_string(),
                instructions: "Channel your inner David Attenborough and describe the information as if you're narrating a nature documentary. Treat code, features, or processes as flora and fauna in a complex ecosystem. Use a tone of fascination and wonder, and explain interactions and developments as if observing them in their natural habitat.".to_string(),
                emoji: "🌿".to_string(),
            },
        );

        presets.insert(
            "chill".to_string(),
            InstructionPreset {
                name: "Chill".to_string(),
                description: "Professional but fun commit messages".to_string(),
                instructions: "Use a style that's professionally informative but with a touch of clever humor. Keep it light and engaging while still conveying the essential information.".to_string(),
                emoji: "😎".to_string(),
            }
        );

        presets.insert(
            "hater".to_string(),
            InstructionPreset {
                name: "Hater".to_string(),
                description: "Hyper-critical and brutally honest style".to_string(),
                instructions: "Adopt a hyper-critical approach. Focus on finding flaws, weaknesses, and potential issues. Provide brutally honest feedback and don't hesitate to point out even minor imperfections.".to_string(),
                emoji: "💢".to_string(),
            },
        );

        InstructionPresetLibrary { presets }
    }

    pub fn get_preset(&self, key: &str) -> Option<&InstructionPreset> {
        self.presets.get(key)
    }

    pub fn list_presets(&self) -> Vec<(&String, &InstructionPreset)> {
        self.presets.iter().collect()
    }
}

pub fn get_instruction_preset_library() -> InstructionPresetLibrary {
    InstructionPresetLibrary::new()
}

pub fn list_presets_formatted(library: &InstructionPresetLibrary) -> String {
    let mut presets: Vec<_> = library.list_presets();
    presets.sort_by(|a, b| {
        if a.1.name == "Default" {
            std::cmp::Ordering::Less
        } else if b.1.name == "Default" {
            std::cmp::Ordering::Greater
        } else {
            a.1.name.cmp(&b.1.name)
        }
    });

    presets
        .iter()
        .map(|(key, preset)| format!("{} - {} - {} - {}", key, preset.emoji, preset.name, preset.description))
        .collect::<Vec<String>>()
        .join("\n")
}