use crate::define_tool;
use crate::tools::common::{InstallError, has, run};
define_tool!(LITELLM, {
command: "litellm",
custom_install: install_litellm,
});
fn install_litellm(_min_hint: &str) -> Result<(), InstallError> {
if has("litellm") {
return Ok(());
}
let has_python = has("python3") || has("python");
if !has_python {
return Err(InstallError::Prereq(
"Python not found. Install Python 3.9+ and re-run.",
));
}
if has("pipx") {
run("pipx", &["install", "litellm"])?;
return Ok(());
}
let pip_cmd = if has("pip3") { "pip3" } else { "pip" };
if !has(pip_cmd) {
return Err(InstallError::Prereq(
"pip not found. Install pip and re-run, or install pipx for isolated installation.",
));
}
run(pip_cmd, &["install", "--user", "litellm"])?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn ensure_litellm_no_panic() {
let res = ensure("");
assert!(res.is_ok() || res.is_err());
}
}