feat: add unload endpoint
CI / Rust CI (push) Successful in 1m24s

This commit is contained in:
2026-04-10 12:48:14 +02:00
parent 7e430bcf00
commit 686f9ff747
4 changed files with 194 additions and 0 deletions
+25
View File
@@ -107,6 +107,31 @@ impl OllamaProvider {
}))
}
pub async fn unload_model(&self, model: &str) -> Result<Value, OllamaError> {
self.validate_model(model).await?;
let payload = json!({
"model": model,
"prompt": "",
"keep_alive": "0",
"stream": false,
});
let res = self
.client
.post(format!("{}/api/generate", self.base_url))
.json(&payload)
.send()
.await?
.json::<Value>()
.await?;
Ok(json!({
"model": res.get("model"),
"status": "unloaded",
}))
}
pub async fn completions(&self, body: Value) -> Result<Value, OllamaError> {
let prompt = body
.get("prompt")