use anyhow::Result;
use tokio::process::Command as AsyncCommand;
pub fn is_installed() -> bool {
which::which("ollama").is_ok()
}
pub async fn list_models_async() -> Result<Vec<String>> {
let output = AsyncCommand::new("ollama").arg("list").output().await;
match output {
Ok(output) if output.status.success() => {
let stdout = String::from_utf8_lossy(&output.stdout);
let models: Vec<String> = stdout
.lines()
.skip(1) .filter_map(|line| {
line.split_whitespace().next().map(|s| s.to_string())
})
.collect();
Ok(models)
},
_ => Ok(Vec::new()),
}
}