use std::collections::HashMap;
#[derive(Debug, Clone, Default)]
pub struct ModelAliases {
map: HashMap<String, String>,
}
impl ModelAliases {
pub fn new() -> Self {
Self::default()
}
pub fn with_defaults() -> Self {
let mut m = Self::new();
m.set("fast", "gpt-4o-mini");
m.set("smart", "claude-sonnet-4-6");
m.set("cheap", "gpt-4o-mini");
m.set("local", "llama3.1");
m
}
pub fn set(&mut self, alias: impl Into<String>, model: impl Into<String>) {
self.map.insert(alias.into(), model.into());
}
pub fn resolve<'a>(&'a self, name: &'a str) -> &'a str {
self.map.get(name).map(String::as_str).unwrap_or(name)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn resolves_defaults_and_passthrough() {
let a = ModelAliases::with_defaults();
assert_eq!(a.resolve("fast"), "gpt-4o-mini");
assert_eq!(a.resolve("smart"), "claude-sonnet-4-6");
assert_eq!(a.resolve("gpt-4o"), "gpt-4o");
}
}