Liking cljdoc? Tell your friends :D

vaelii.agents.llm.pool

A yes/no question put to a model several times across a pool of Ollama hosts, and the vote over the answers. See docs/llm.md § The vote pool.

A yes/no question put to a model several times across a pool of Ollama hosts, and
the vote over the answers.  See docs/llm.md § The vote pool.
raw docstring

acquire-timeout-msclj

How long with-provider waits for a free provider, in ms.

How long `with-provider` waits for a free provider, in ms.
sourceraw docstring

ask-yes-noclj

(ask-yes-no p question & [opts])

One yes/no turn. Returns :yes, :no, or nil when the model refused, was cut off, answered something that is not a vote, or could not be asked (no provider freed up, or the call threw).

One yes/no turn. Returns `:yes`, `:no`, or nil when the model refused, was cut off,
answered something that is not a vote, or could not be asked (no provider freed up, or
the call threw).
sourceraw docstring

configured-hostsclj

(configured-hosts)

VAELII_OLLAMA_HOSTS parsed when set, else the one host vaelii.agents.llm.ollama is configured with ({:host nil}).

`VAELII_OLLAMA_HOSTS` parsed when set, else the one host
[[vaelii.agents.llm.ollama]] is configured with (`{:host nil}`).
sourceraw docstring

default-tokensclj

How many calls one host takes at once when its spec does not say.

How many calls one host takes at once when its spec does not say.
sourceraw docstring

default-votesclj

source

outstandingclj

(outstanding p)

How many providers are checked out now, from the pool's own counter. Nonzero on an idle pool means a leaked token.

How many providers are checked out now, from the pool's own counter.  Nonzero on an
idle pool means a leaked token.
sourceraw docstring

parse-hostsclj

(parse-hosts s)

"gpu1*4,gpu2:8080,localhost" → [{:host "gpu1" :tokens 4} {:host "gpu2:8080" :tokens 2} {:host "localhost" :tokens 2}]: each entry is host[*n], the host as vaelii.agents.llm.ollama/normalize-host reads it. A blank or nil string is no hosts; an entry with a blank host or an n that is not a positive whole number a long holds throws :llm-bad-hosts.

`"gpu1*4,gpu2:8080,localhost"` → `[{:host "gpu1" :tokens 4} {:host "gpu2:8080"
:tokens 2} {:host "localhost" :tokens 2}]`: each entry is `host[*n]`, the host as
`vaelii.agents.llm.ollama/normalize-host` reads it.  A blank or nil string is no hosts;
an entry with a blank host or an `n` that is not a positive whole number a `long` holds
throws `:llm-bad-hosts`.
sourceraw docstring

poolclj

(pool hosts & [opts])

A pool over hosts, each entry {:host :tokens}: a channel holding one provider per token, with a capacity fixed at construction. An empty hosts throws :llm-bad-hosts, since every call on a pool of none would wait out acquire-timeout-ms.

A pool over `hosts`, each entry `{:host :tokens}`: a channel holding one provider per
token, with a capacity fixed at construction.  An empty `hosts` throws
`:llm-bad-hosts`, since every call on a pool of none would wait out
`acquire-timeout-ms`.
sourceraw docstring

read-yes-noclj

(read-yes-no text)

:yes or :no when the answer's first word is yes or no, ignoring case and leading punctuation, else nil.

`:yes` or `:no` when the answer's first word is `yes` or `no`, ignoring case and
leading punctuation, else nil.
sourceraw docstring

stub-poolclj

(stub-pool & [opts])

A pool of one stub provider built with opts.

A pool of one stub provider built with `opts`.
sourceraw docstring

voteclj

(vote p question & [{:keys [votes] :as opts}])

Ask question :votes times (default default-votes) and compare the counted votes.

Returns {:verdict :yes|:no|:abstain :votes [..] :tally {..} :calls n :failed n}: :yes when more counted votes say yes than no, :no for the reverse, :abstain on a tie. A turn that is not a vote (a refusal, a truncation, prose) is not counted, and neither is one that failed (no provider freed up, or the call threw), which :failed counts. A caller does not mark its target on :abstain.

Ask `question` `:votes` times (default `default-votes`) and compare the counted votes.

Returns `{:verdict :yes|:no|:abstain :votes [..] :tally {..} :calls n :failed n}`:
`:yes` when more counted votes say yes than no, `:no` for the reverse, `:abstain` on a
tie.  A turn that is not a vote (a refusal, a truncation, prose) is not counted, and
neither is one that failed (no provider freed up, or the call threw), which `:failed`
counts.  A caller does not mark its target on `:abstain`.
sourceraw docstring

with-providerclj

(with-provider p f)

Take a provider from p, return (f provider), and offer the provider back on every exit. {:status :no-host} when none frees up within acquire-timeout-ms.

Take a provider from `p`, return `(f provider)`, and offer the provider back on every
exit.  `{:status :no-host}` when none frees up within `acquire-timeout-ms`.
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