Liking cljdoc? Tell your friends :D

vaelii.agents.llm.ollama

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.
raw docstring

available?clj

(available?)
(available? opts)

Is an Ollama reachable? opts as version's.

Is an Ollama reachable?  `opts` as `version`'s.
sourceraw docstring

base-urlclj

(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`.
sourceraw docstring

bodyclj

(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.
sourceraw docstring

capabilitiesclj

(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.
sourceraw docstring

configured-generation-modelclj

(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`.
sourceraw docstring

configured-keep-aliveclj

(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`.
sourceraw docstring

configured-modelclj

(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`.
sourceraw docstring

configured-num-ctxclj

(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`.
sourceraw docstring

context-lengthclj

(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.
sourceraw docstring

default-generation-modelclj

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.
sourceraw docstring

default-hostclj

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.
sourceraw docstring

default-keep-aliveclj

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.
sourceraw docstring

default-modelclj

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.
sourceraw docstring

default-num-ctxclj

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.
sourceraw docstring

default-num-predictclj

num_predict when a request carries no :max-tokens.

`num_predict` when a request carries no `:max-tokens`.
sourceraw docstring

generation-providerclj

(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.
sourceraw docstring

normalize-hostclj

(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.
sourceraw docstring

parse-responseclj

(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`).
sourceraw docstring

probe-clientclj

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.
sourceraw docstring

providerclj

(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`.
sourceraw docstring

showclj

(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.
sourceraw docstring

supports-tools?clj

(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.
sourceraw docstring

versionclj

(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).
sourceraw docstring

warmclj

(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`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close