Add delete model endpoint (DELETE /api/delete)

Implement the Ollama DELETE /api/delete endpoint for removing models
from the server.

- Add DeleteRequest type with model field in src/types/delete.rs
- Add OllamaClient::delete() async method in src/lib.rs
- Register delete module in src/types/mod.rs
- Add usage example in examples/delete.rs
This commit is contained in:
2026-02-01 21:14:26 +00:00
parent f15a2c53d6
commit 63c08c484c
4 changed files with 138 additions and 8 deletions

16
examples/delete.rs Normal file
View File

@@ -0,0 +1,16 @@
use std::{env, error::Error};
use ollama_rs::OllamaClient;
use ollama_rs::types::delete::DeleteRequest;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
tracing_subscriber::fmt().init();
let _ = dotenvy::dotenv();
let server_address = env::var("OLLAMA_SERVER")?;
let model = env::args().nth(1).expect("usage: delete <model>");
let ollama_client = OllamaClient::new(server_address);
ollama_client.delete(DeleteRequest::new(&model)).await?;
println!("Model '{}' deleted successfully", model);
Ok(())
}