The Ollama chat API backend, over java.net.http and cheshire, plus the host
probes. Beyond the neutral request keys it reads :temperature and :keep-alive.
See docs/llm.md § The local backend.
The Ollama chat API backend, over `java.net.http` and `cheshire`, plus the host probes. Beyond the neutral request keys it reads `:temperature` and `:keep-alive`. See docs/llm.md § The local backend.
(available?)(available? opts)Is an Ollama reachable? opts as version's.
Is an Ollama reachable? `opts` as `version`'s.
(base-url)The Ollama base URL: VAELII_OLLAMA_HOST, else OLLAMA_HOST when it names a real
target, else default-host.
The Ollama base URL: `VAELII_OLLAMA_HOST`, else `OLLAMA_HOST` when it names a real target, else `default-host`.
(body {:keys [model system messages tools num-ctx max-tokens temperature
keep-alive think]
fmt :format}
{:keys [stream?]})The neutral request -> Ollama's /api/chat body. keep_alive, num_ctx,
num_predict and temperature (default 0) are always sent; format, tools and
think only when given. :think false stops a thinking model (gemma4, qwen3) from
spending num_predict on thinking and answering nothing; "low" etc. for gpt-oss.
The neutral request -> Ollama's `/api/chat` body. `keep_alive`, `num_ctx`, `num_predict` and `temperature` (default 0) are always sent; `format`, `tools` and `think` only when given. `:think` false stops a thinking model (gemma4, qwen3) from spending `num_predict` on thinking and answering nothing; "low" etc. for gpt-oss.
(capabilities model)(capabilities model opts)The capability keywords a model declares (#{:completion}, #{:completion :tools},
…), or nil when they cannot be read.
The capability keywords a model declares (`#{:completion}`, `#{:completion :tools}`,
…), or nil when they cannot be read.(configured-generation-model)The model a generation turn runs: VAELII_OLLAMA_GENERATION_MODEL when set, else
default-generation-model.
The model a generation turn runs: `VAELII_OLLAMA_GENERATION_MODEL` when set, else `default-generation-model`.
(configured-keep-alive)How long to ask the host to hold the model resident: VAELII_OLLAMA_KEEP_ALIVE when
set, else default-keep-alive.
How long to ask the host to hold the model resident: `VAELII_OLLAMA_KEEP_ALIVE` when set, else `default-keep-alive`.
(configured-model)The model to run: VAELII_OLLAMA_MODEL when set, else default-model.
The model to run: `VAELII_OLLAMA_MODEL` when set, else `default-model`.
(configured-num-ctx)The context length, in tokens, to ask for: VAELII_OLLAMA_NUM_CTX when set and numeric, else
default-num-ctx.
The context length, in tokens, to ask for: `VAELII_OLLAMA_NUM_CTX` when set and numeric, else `default-num-ctx`.
(context-length model)(context-length model opts)The model's native context length from /api/show's model_info, or nil.
The model's native context length from `/api/show`'s `model_info`, or nil.
The model a generation turn runs on, a turn that writes new content rather than
rewriting lines it was shown, when VAELII_OLLAMA_GENERATION_MODEL is unset.
The model a generation turn runs on, a turn that writes new content rather than rewriting lines it was shown, when `VAELII_OLLAMA_GENERATION_MODEL` is unset.
The host base-url answers when neither variable names one: Ollama's own default.
The host `base-url` answers when neither variable names one: Ollama's own default.
How long the host holds the model resident after a turn, when
VAELII_OLLAMA_KEEP_ALIVE and :keep-alive are unset.
How long the host holds the model resident after a turn, when `VAELII_OLLAMA_KEEP_ALIVE` and `:keep-alive` are unset.
The model a turn runs when VAELII_OLLAMA_MODEL and :model are unset.
The model a turn runs when `VAELII_OLLAMA_MODEL` and `:model` are unset.
The context length, in tokens, a request asks for when VAELII_OLLAMA_NUM_CTX and :num-ctx are
unset.
The context length, in tokens, a request asks for when `VAELII_OLLAMA_NUM_CTX` and `:num-ctx` are unset.
num_predict when a request carries no :max-tokens.
`num_predict` when a request carries no `:max-tokens`.
(generation-provider)(generation-provider opts)provider on configured-generation-model, for a generation turn; an opts
:model still wins.
`provider` on `configured-generation-model`, for a generation turn; an `opts` `:model` still wins.
(normalize-host host)A host string -> the base URL to call, read as Ollama reads OLLAMA_HOST: a host with
no scheme gets http://, and :11434 when it names no port, while a host with a scheme
keeps that scheme's own port. The scheme is matched in any case and written in lower
case, an empty host is 127.0.0.1, an unbracketed IPv6 address is bracketed and names
no port, and trailing slashes are dropped.
A host string -> the base URL to call, read as Ollama reads `OLLAMA_HOST`: a host with no scheme gets `http://`, and `:11434` when it names no port, while a host with a scheme keeps that scheme's own port. The scheme is matched in any case and written in lower case, an empty host is `127.0.0.1`, an unbracketed IPv6 address is bracketed and names no port, and trailing slashes are dropped.
(parse-response m)Ollama's chat JSON -> the neutral response map (vaelii.agents.llm.protocol).
Ollama's chat JSON -> the neutral response map (`vaelii.agents.llm.protocol`).
The one HttpClient, delayed, that version, show and warm send on. See
docs/llm.md § What both HTTP backends share.
The one `HttpClient`, delayed, that `version`, `show` and `warm` send on. See docs/llm.md § What both HTTP backends share.
(provider)(provider {:keys [host model num-ctx keep-alive timeout-ms think]
:or {timeout-ms 300000}})An Ollama-backed Provider. opts:
:host default base-url
:model default VAELII_OLLAMA_MODEL, else default-model
:num-ctx default VAELII_OLLAMA_NUM_CTX, else default-num-ctx
:keep-alive default configured-keep-alive
:timeout-ms default 300000; bounds the whole turn, the body included
:think sent as Ollama's think when given: false, true, or "low"/"medium"/"high"
A request's :model, :num-ctx, :keep-alive and :think override these. Building one opens
no socket; available? is the reachability check. meta carries :conn.
An Ollama-backed `Provider`. `opts`: :host default `base-url` :model default `VAELII_OLLAMA_MODEL`, else `default-model` :num-ctx default `VAELII_OLLAMA_NUM_CTX`, else `default-num-ctx` :keep-alive default `configured-keep-alive` :timeout-ms default 300000; bounds the whole turn, the body included :think sent as Ollama's `think` when given: false, true, or "low"/"medium"/"high" A request's `:model`, `:num-ctx`, `:keep-alive` and `:think` override these. Building one opens no socket; `available?` is the reachability check. `meta` carries `:conn`.
(show model)(show model {:keys [host timeout-ms] :or {timeout-ms 10000}})/api/show for one model — its template, parameters, and declared capabilities.
nil when the host or the model is not reachable.
`/api/show` for one model — its template, parameters, and declared capabilities. nil when the host or the model is not reachable.
(supports-tools? model)(supports-tools? model opts)Does this model declare :tools? False when the host cannot be reached.
Does this model declare `:tools`? False when the host cannot be reached.
(version)(version {:keys [host timeout-ms] :or {timeout-ms 2000}})The Ollama server's version string, or nil when it is not reachable within
:timeout-ms (default 2000).
The Ollama server's version string, or nil when it is not reachable within `:timeout-ms` (default 2000).
(warm)(warm model)(warm model
{:keys [host timeout-ms keep-alive num-ctx prefill-tokens]
:or {timeout-ms 300000 prefill-tokens 2048}})Load model (default configured-generation-model) and hold it resident: one
:prefill-tokens (2048) prefill at the request's context length, generating one token. Returns
{:loaded? bool :elapsed-ms n :model m :prefill-tokens n} and never throws.
opts: :host, :timeout-ms (300000), :keep-alive, :num-ctx, :prefill-tokens.
Load `model` (default `configured-generation-model`) and hold it resident: one
`:prefill-tokens` (2048) prefill at the request's context length, generating one token. Returns
`{:loaded? bool :elapsed-ms n :model m :prefill-tokens n}` and never throws.
`opts`: `:host`, `:timeout-ms` (300000), `:keep-alive`, `:num-ctx`, `:prefill-tokens`.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |