use std::collections::HashMap;
use crate::ProviderFamily;
pub const BASE: &str = include_str!("base.txt");
pub const ANTHROPIC: &str = include_str!("anthropic.txt");
pub const OPENAI: &str = include_str!("openai.txt");
pub const GEMINI: &str = include_str!("gemini.txt");
pub const GENERIC: &str = include_str!("generic.txt");
pub const VERIFICATION: &str = include_str!("verification.txt");
pub const TOOL_BASH: &str = include_str!("tools/bash.txt");
pub const TOOL_READ_FILE: &str = include_str!("tools/read_file.txt");
pub const TOOL_WRITE_FILE: &str = include_str!("tools/write_file.txt");
pub const TOOL_EDIT_FILE: &str = include_str!("tools/edit_file.txt");
pub const TOOL_GLOB: &str = include_str!("tools/glob.txt");
pub const TOOL_GREP: &str = include_str!("tools/grep.txt");
pub const TOOL_LSP: &str = include_str!("tools/lsp.txt");
#[derive(Debug, Clone)]
pub struct EmbeddedPrompts {
pub base: &'static str,
pub verification: &'static str,
providers: HashMap<ProviderFamily, &'static str>,
tools: HashMap<&'static str, &'static str>,
}
impl EmbeddedPrompts {
pub fn load() -> Self {
let mut providers = HashMap::new();
providers.insert(ProviderFamily::Anthropic, ANTHROPIC);
providers.insert(ProviderFamily::OpenAI, OPENAI);
providers.insert(ProviderFamily::Google, GEMINI);
providers.insert(ProviderFamily::Generic, GENERIC);
let mut tools = HashMap::new();
tools.insert("bash", TOOL_BASH);
tools.insert("read_file", TOOL_READ_FILE);
tools.insert("write_file", TOOL_WRITE_FILE);
tools.insert("edit_file", TOOL_EDIT_FILE);
tools.insert("glob", TOOL_GLOB);
tools.insert("grep", TOOL_GREP);
tools.insert("lsp", TOOL_LSP);
Self {
base: BASE,
verification: VERIFICATION,
providers,
tools,
}
}
pub fn provider(&self, family: ProviderFamily) -> &'static str {
self.providers
.get(&family)
.copied()
.unwrap_or(GENERIC)
}
pub fn tool(&self, name: &str) -> Option<&'static str> {
self.tools.get(name).copied()
}
pub fn tool_names(&self) -> impl Iterator<Item = &&'static str> {
self.tools.keys()
}
}
impl Default for EmbeddedPrompts {
fn default() -> Self {
Self::load()
}
}