ollama-kit 0.2.1

Runtime control (lifecycle + execution guards) for ollama-rs without wrapping its API.
Documentation

ollama-kit

Crates.io Documentation License Crates.io downloads CI

Thin layer on ollama-rs: configured reqwest, optional call / call_stream (timeouts, concurrency, retries), and ensure for β€œis this model local?” (lists; may pull only when auto_pull + Development). Does not start Ollama.

Cargo.toml

ollama-kit = "0.2"
ollama-kit = { version = "0.2", features = ["stream"] }

API sketch

OllamaRuntime::new + RuntimeConfig URL, timeouts, auth; rejects Production + auto_pull.
ensure List local names; pull only if auto_pull and Development.
auto_pull / mode Getters mirroring [RuntimeConfig].
call / call_stream Guarded ollama-rs calls.
client / guard Unguarded; use guard().run for Fn() shapes.

Example

use std::time::Duration;

use ollama_kit::{OllamaRuntime, RuntimeConfig, RuntimeMode};

async fn demo() -> ollama_kit::Result<()> {
    let rt = OllamaRuntime::new(RuntimeConfig {
        base_url: "http://127.0.0.1:11434".into(),
        timeout: Duration::from_secs(120),
        connect_timeout: Duration::from_secs(10),
        max_retries: 2,
        max_concurrent: 4,
        auto_pull: false,
        mode: RuntimeMode::Production,
        auth: None,
    })
    .await?;

    rt.ensure("mistral").await?;
    let _ = rt.call(|c| c.list_local_models()).await?;
    Ok(())
}

Docs / license

cargo doc. MIT β€” LICENSE.