Class BatchResponse<T>
java.lang.Object
dev.langchain4j.model.batch.BatchResponse<T>
- Type Parameters:
T- the type of the responses payload (e.g.,ChatResponse,Embedding)
Represents the responses of a batch operation.
A batch response contains the batch identifier, current state, and the per-request
results once the batch has reached a terminal state.
The results() preserve the order of the submitted requests, so the i-th result
corresponds to the i-th request, allowing the caller to correlate every outcome (success or
failure) with its originating request. The responses() and errors() methods
are convenience views over those results.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbatchId()Returns the unique identifier for this batch operation.static <T> BatchResponse.Builder<T> builder()Returns a new builder for constructingBatchResponseinstances.booleanerrors()Convenience view returning only the errors, in submission order.inthashCode()Convenience view returning only the successful responses, in submission order.results()Returns the per-request results in submission order, or an empty list if the batch has not produced any results yet (e.g., it is still in progress).state()Returns the current state of the batch job.toString()
-
Constructor Details
-
BatchResponse
-
-
Method Details
-
batchId
Returns the unique identifier for this batch operation. -
state
Returns the current state of the batch job. -
results
Returns the per-request results in submission order, or an empty list if the batch has not produced any results yet (e.g., it is still in progress).The i-th element corresponds to the i-th submitted request. Each result is either a
BatchItemResult.Successor aBatchItemResult.Failure. A batch-level failure (the whole operation failing) is represented as a singleBatchItemResult.Failure. -
responses
-
errors
Convenience view returning only the errors, in submission order.To correlate errors with their originating requests, use
results()instead. -
equals
-
hashCode
-
toString
-
builder
Returns a new builder for constructingBatchResponseinstances.- Type Parameters:
T- the type of the responses payload- Returns:
- a new builder instance
-