The part of an HTTP provider's transport that is not its wire format: the connect and
read deadlines, the typed send, the not-JSON refusal, the bounded excerpt. Each fn
takes an endpoint
{:label :slug}: :label names the far end in a message, :slug in a thread name.
See docs/llm.md § What both HTTP backends share.
The part of an HTTP provider's transport that is not its wire format: the connect and
read deadlines, the typed send, the not-JSON refusal, the bounded excerpt. Each fn
takes an endpoint
`{:label :slug}`: `:label` names the far end in a message, `:slug` in a thread name.
See docs/llm.md § What both HTTP backends share.The connect deadline, TCP and TLS handshakes included, in ms: every provider's client
is built on it, whatever :timeout-ms the turn allows.
The connect deadline, TCP and TLS handshakes included, in ms: every provider's client is built on it, whatever `:timeout-ms` the turn allows.
(decode {:keys [label]} text status)A JSON body -> data. A body that is not JSON throws :llm-bad-response with
:status and the bounded :excerpt; the text stays out of the message.
A JSON body -> data. A body that is not JSON throws `:llm-bad-response` with `:status` and the bounded `:excerpt`; the text stays out of the message.
(excerpt s)The first 200 characters of s, or nil.
The first 200 characters of `s`, or nil.
(send-for-text endpoint client request ms)Send request and read its whole body as UTF-8 text, both inside ms of the call:
[status text]. The send fails as send-request does, and a body that stops arriving
after the headers is under-read-deadline's :llm-timeout.
Send `request` and read its whole body as UTF-8 text, both inside `ms` of the call: `[status text]`. The send fails as `send-request` does, and a body that stops arriving after the headers is `under-read-deadline`'s `:llm-timeout`.
(send-request {:keys [label]} client request handler)(.send client request handler), with the send's own failures typed and the original
as the cause: no response inside the request's .timeout is :llm-timeout carrying
:timeout-ms, and a connect timeout or any other IOException (refused, reset,
unresolved) is :llm-unreachable.
`(.send client request handler)`, with the send's own failures typed and the original as the cause: no response inside the request's `.timeout` is `:llm-timeout` carrying `:timeout-ms`, and a connect timeout or any other `IOException` (refused, reset, unresolved) is `:llm-unreachable`.
(under-read-deadline {:keys [label] :as endpoint} ms on-expiry f)Return (f), with a watchdog that runs on-expiry (which closes the body) once ms
have passed. Any Throwable from f after expiry is rethrown as :llm-timeout
carrying :timeout-ms and the original as its cause; before expiry it is rethrown
unchanged. The watchdog is cancelled on every exit. f reads the body eagerly.
Return `(f)`, with a watchdog that runs `on-expiry` (which closes the body) once `ms` have passed. Any `Throwable` from `f` after expiry is rethrown as `:llm-timeout` carrying `:timeout-ms` and the original as its cause; before expiry it is rethrown unchanged. The watchdog is cancelled on every exit. `f` reads the body eagerly.
(watchdog {:keys [slug]} ms on-expiry)A started daemon thread that runs on-expiry once ms have passed; interrupt it to
cancel.
A started daemon thread that runs `on-expiry` once `ms` have passed; interrupt it to cancel.
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 |