Skip to main content

Crate blazen_llm_ollama

Crate blazen_llm_ollama 

Source
Expand description

Ollama HTTP-proxy backend for Blazen.

OllamaProvider forwards inference, embedding, and adapter operations to a running Ollama server over its native HTTP API. The endpoints exercised here, as of Ollama 0.3:

  • POST /api/generate — completion (NDJSON stream or single).
  • POST /api/chat — chat completion (NDJSON stream or single).
  • POST /api/embeddings — embed one or more inputs.
  • GET /api/tags — list installed models.
  • POST /api/show — model metadata (template, parameters, …).
  • POST /api/pull — pull a model from the registry (NDJSON progress stream).
  • POST /api/create — create a derived model from a Modelfile. Used here to mount a LoRA adapter via the ADAPTER directive.
  • DELETE /api/delete — remove an installed model.

Unlike vLLM, Ollama does not expose a runtime adapter mount/unmount pair. Adapters become full derived models via /api/create + a Modelfile, which is the contract the upstream supports. See OllamaProvider::load_adapter for the strategy.

This crate is intentionally a leaf — it does not depend on blazen-llm. The trait-impl bridge lives in crates/blazen-llm/src/backends/ollama.rs behind the ollama Cargo feature on blazen-llm.

Structs§

MountedAdapter
One adapter currently mounted on the upstream Ollama server, tracked client-side so the bridge can answer list_adapters without re-querying /api/tags for every call.
OllamaClient
Reusable HTTP client wrapping reqwest::Client.
OllamaModelEntry
One row from GET /api/tags. Ollama returns more fields (size, digest, modified_at, …) but the proxy only needs the name.
OllamaOptions
Options for constructing a crate::OllamaProvider.
OllamaProvider
Ollama proxy provider.
OllamaPullProgress
One frame from an /api/pull NDJSON stream.
OllamaShowResponse
Response from POST /api/show. Only the fields the bridge actually reads are typed; Ollama may emit additional keys we forward as serde_json::Value via Self::raw.
OllamaStreamPart
One frame from a /api/generate or /api/chat NDJSON stream.

Enums§

OllamaAdapterTransport
How a crate::OllamaProvider hands adapters off to the upstream Ollama server.
OllamaError
Failures emitted by crate::OllamaClient and crate::OllamaProvider.