Liking cljdoc? Tell your friends :D

vaelii.impl.llm.provider

Which backend a turn runs against — the selection seam.

Stands where vaelii.impl.asp.solver stands for the ASP backends: a keyword names a backend, the backend is lazily resolved so choosing one is what loads it, and an unreachable backend falls back to the deterministic default rather than throwing. vaelii.impl.llm.stub is that default, exactly as vaelii.impl.solve/local-solver is for contradictions — so a build with no credential, no Ollama and no network runs the whole pipeline and opens no socket.

Three kinds:

:stub deterministic, offline, scriptable — the default :ollama a local Ollama (vaelii.impl.llm.ollama), no credential :anthropic the Messages API (vaelii.impl.llm.anthropic), credential required

Select with VAELII_LLM_PROVIDER or -Dvaelii.llm.provider; a caller that already knows what it wants passes the kind (or a built provider) directly.

Resolution is lazy for a reason beyond load time: anthropic/available? may shell out to the ant CLI, and ollama/available? opens a socket. Neither should happen because a namespace was required.

Which backend a turn runs against — the selection seam.

Stands where `vaelii.impl.asp.solver` stands for the ASP backends: a keyword names a
backend, the backend is **lazily resolved** so choosing one is what loads it, and an
unreachable backend falls back to the deterministic default rather than throwing.
`vaelii.impl.llm.stub` is that default, exactly as `vaelii.impl.solve/local-solver`
is for contradictions — so a build with no credential, no Ollama and no network runs
the whole pipeline and opens no socket.

Three kinds:

  :stub       deterministic, offline, scriptable — the default
  :ollama     a local Ollama (`vaelii.impl.llm.ollama`), no credential
  :anthropic  the Messages API (`vaelii.impl.llm.anthropic`), credential required

Select with `VAELII_LLM_PROVIDER` or `-Dvaelii.llm.provider`; a caller that already
knows what it wants passes the kind (or a built provider) directly.

Resolution is lazy for a reason beyond load time: `anthropic/available?` may shell
out to the `ant` CLI, and `ollama/available?` opens a socket.  Neither should happen
because a namespace was required.
raw docstring

active-kindclj

(active-kind)
(active-kind opts)

Which backend (provider) will hand back right now — for diagnostics, and for a UI that wants to say what it is talking to.

Which backend `(provider)` will hand back right now — for diagnostics, and for a
UI that wants to say what it is talking to.
raw docstring

available?clj

(available? kind)
(available? kind opts)

Can this backend actually serve a turn right now? :stub always can; :ollama probes the host; :anthropic looks for a credential. Never throws — an unreachable backend answers false.

Can this backend actually serve a turn right now?  `:stub` always can; `:ollama`
probes the host; `:anthropic` looks for a credential.  Never throws — an
unreachable backend answers false.
raw docstring

buildclj

(build kind)
(build kind opts)

Build the named backend, or nil when it cannot be built. opts is handed to the backend's own provider constructor.

Build the named backend, or nil when it cannot be built.  `opts` is handed to the
backend's own `provider` constructor.
raw docstring

configuredclj

(configured)

The backend named by VAELII_LLM_PROVIDER / -Dvaelii.llm.provider, or nil.

The backend named by `VAELII_LLM_PROVIDER` / `-Dvaelii.llm.provider`, or nil.
raw docstring

first-availableclj

(first-available)
(first-available opts)

The first backend in kinds that can serve a turn — :stub at worst, since it always can. For a caller with no preference that would still rather use a real model than propose nothing.

The first backend in `kinds` that can serve a turn — `:stub` at worst, since it
always can.  For a caller with no preference that would still rather use a real
model than propose nothing.
raw docstring

generation-providerclj

(generation-provider)
(generation-provider kind)
(generation-provider kind opts)

The provider for a generation turn (vaelii.impl.llm.session/propose-page) — provider, except that a backend naming a distinct generation model is built through that name instead. Ollama does: editing shown lines and writing new knowledge are different jobs whose best models differ, and a page turn run on the edit model produces nothing usable. A backend with no such split falls through to its ordinary constructor, and an unreachable one falls back to the stub, exactly as provider does.

The reachability probe carries only :host from opts, never the turn's :timeout-ms — a probe is a health check and keeps its own short deadline, so a caller that allows a turn a minute does not thereby allow the gate a minute on a host that never answers.

The provider for a **generation** turn (`vaelii.impl.llm.session/propose-page`) —
`provider`, except that a backend naming a distinct generation model is built through
that name instead.  Ollama does: editing shown lines and writing new knowledge are
different jobs whose best models differ, and a page turn run on the edit model produces
nothing usable.  A backend with no such split falls through to its ordinary
constructor, and an unreachable one falls back to the stub, exactly as `provider` does.

The reachability probe carries only `:host` from `opts`, never the turn's `:timeout-ms`
— a probe is a health check and keeps its own short deadline, so a caller that allows a
turn a minute does not thereby allow the gate a minute on a host that never answers.
raw docstring

kindsclj

The backends provider knows how to build, in the order first-available tries them: the local one before the remote one, since it costs nothing to ask.

The backends `provider` knows how to build, in the order `first-available` tries
them: the local one before the remote one, since it costs nothing to ask.
raw docstring

providerclj

(provider)
(provider kind)
(provider kind opts)

The Provider to run a turn against.

With no kind, the configured one — and the stub when nothing is configured, when the configured backend is unreachable, or when it cannot be built. Falling back is the point: an application that cannot reach its model degrades to a provider that proposes nothing rather than to an exception, which is how the ASP seam behaves and what makes the pipeline testable everywhere.

Pass a kind to demand one; it still falls back, so a caller that must know asks available? first.

The `Provider` to run a turn against.

With no `kind`, the configured one — and the stub when nothing is configured, when
the configured backend is unreachable, or when it cannot be built.  **Falling back is
the point**: an application that cannot reach its model degrades to a provider that
proposes nothing rather than to an exception, which is how the ASP seam behaves and
what makes the pipeline testable everywhere.

Pass a kind to demand one; it still falls back, so a caller that must know asks
`available?` first.
raw docstring

warmclj

(warm)
(warm kind)

Make a backend ready to answer fast, and hold it that way — what an application calls at start so a reader's first turn is not the one that pays for loading the weights. Returns whatever the backend reports, or nil when it has none to do (the stub is already warm, and a hosted API has no local model to load). Never throws: warming is an optimization, and a host that is down is the ordinary case a fallback already covers.

Make a backend ready to answer fast, and hold it that way — what an application calls
at start so a reader's first turn is not the one that pays for loading the weights.
Returns whatever the backend reports, or nil when it has none to do (the stub is
already warm, and a hosted API has no local model to load).  Never throws: warming is
an optimization, and a host that is down is the ordinary case a fallback already
covers.
raw 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