Java-friendly wrapper for org.llm4s.types.Result, which is an Either[LLMError, A].
Rather than requiring Java callers to deal with Scala's Either, Option, or Left/Right, this class surfaces a familiar API modelled after java.util.Optional and CompletableFuture.
LlmResult<String> result = client.complete("What is 2+2?");
result.ifSuccess(System.out::println)
.ifFailure(e -> System.err.println(e.getMessage()));
Attributes
- Companion
- object
- Source
- LlmResult.scala
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Returns the value on success, or throws LlmException on failure.
Returns the LlmException on failure, or null on success.
Returns the value on success, or null on failure.
Returns the value on success, or null on failure.
Intended for reference types only (String, Completion, ...), which is what every Java-facing API here returns. If A were ever a primitive mapping (int, boolean), the failure case would yield 0/false instead of null, so prefer toOptional or isSuccess there.
Attributes
- Source
- LlmResult.scala
Invokes action with the exception if this result is a failure. Returns this to allow chaining with ifSuccess.
Invokes action with the exception if this result is a failure. Returns this to allow chaining with ifSuccess.
Attributes
- Source
- LlmResult.scala
Invokes action with the value if this result is a success. Returns this to allow chaining with ifFailure.
Invokes action with the value if this result is a success. Returns this to allow chaining with ifFailure.
Attributes
- Source
- LlmResult.scala
Returns true if this result holds an error, so get throws LlmException and getError returns it. Exactly one of isSuccess and isFailure is true.
Returns true if this result holds an error, so get throws LlmException and getError returns it. Exactly one of isSuccess and isFailure is true.
Attributes
- Source
- LlmResult.scala
Returns true if this result holds a value, so get returns it without throwing. Exactly one of isSuccess and isFailure is true.
Returns true if this result holds a value, so get returns it without throwing. Exactly one of isSuccess and isFailure is true.
Attributes
- Source
- LlmResult.scala
Transforms the success value; failures pass through unchanged.
Returns an already-completed CompletableFuture wrapping the result.
Returns an already-completed CompletableFuture wrapping the result.
Attributes
- Source
- LlmResult.scala
Returns Optional.of(value) on success, Optional.empty() on failure, and also Optional.empty() when the success value is null (never throws).
Returns Optional.of(value) on success, Optional.empty() on failure, and also Optional.empty() when the success value is null (never throws).
Attributes
- Source
- LlmResult.scala
