Skip to main content

Crate chat_ollama

Crate chat_ollama 

Source
Expand description

Ollama provider for chat-rs.

Thin wrapper around chat_completions — Ollama serves an OpenAI-compatible /v1/chat/completions endpoint, so all chat, streaming, tools, structured output, and embedding logic lives in the chat-completions crate.

What this crate adds on top:

  • Default base URL pointing at the local daemon
  • OLLAMA_HOST env var support
  • OllamaBuilder::pull to ensure the model is present before the first request, hitting Ollama’s native /api/pull. Returns the builder so it slots into the normal chain.
use chat_ollama::OllamaBuilder;

let client = OllamaBuilder::new()
    .with_model("llama3.2")
    .pull().await?
    .build();

Structs§

OllamaBuilder
Ollama-flavored builder. Wraps CompletionsBuilder and adds /api/pull integration so a model can be fetched at build time.
WithModel
WithoutModel

Constants§

DEFAULT_OLLAMA_HOST
Default Ollama base host when OLLAMA_HOST is not set.