org.llm4s.http.Llm4sHttpClient
See theLlm4sHttpClient companion object
@Stable
trait Llm4sHttpClient extends AutoCloseable
The HTTP client provider modules and built-in tools use, abstracted so it can be injected and replaced by a test double.
Every request method returns a Result and never throws for a transport failure:
- a request that times out is a
Left(org.llm4s.error.TimeoutError); - a connection failure, unknown host or other I/O error is a
Left(org.llm4s.error.NetworkError); - an invalid URL, header or timeout, or an unreadable multipart file, is a
Left(org.llm4s.error.ValidationError); - an interrupted request, or a stream read interrupted mid-body, is a
Left(org.llm4s.error.CancelledError), with the thread's interrupt flag kept.
A non-2xx status is '''not''' an error at this layer: it is a Right response, which the caller inspects (HttpResponse.ensureSuccess, or org.llm4s.llmconnect.provider.HttpErrorMapper.mapHttpError with the response headers).
Headers are passed as single-valued maps. Response headers are multi-valued, keyed in lower case; look one up with header(name).
The trait is deliberately not sealed, so tests can implement it. Methods added to it after 1.0 will have default implementations, so a test double keeps compiling.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait AutoCloseableclass Objecttrait Matchableclass Any
Members list
In this article