use of org.kie.kogito.explainability.local.LocalExplainer in project kogito-apps by kiegroup.
the class LocalExplainerServiceHandler method explainAsyncWithResults.
/**
* Requests calculation of an explanation decorated with both "success" and "failure" result handlers.
* See:
* - {@link LocalExplainer#explainAsync}
* - {@link LocalExplainerServiceHandler#createSucceededResult(BaseExplainabilityRequest, Object)}
* - {@link LocalExplainerServiceHandler#createFailedResult(BaseExplainabilityRequest, Throwable)}
*
* @param request The explanation request.
* @param intermediateResultsConsumer A consumer for intermediate results provided by the explainer.
* @return
*/
default CompletableFuture<BaseExplainabilityResult> explainAsyncWithResults(R request, Consumer<BaseExplainabilityResult> intermediateResultsConsumer) {
Prediction prediction = getPrediction(request);
PredictionProvider predictionProvider = getPredictionProvider(request);
return explainAsync(prediction, predictionProvider, s -> intermediateResultsConsumer.accept(createIntermediateResult(request, s))).thenApply(input -> createSucceededResult(request, input)).exceptionally(e -> createFailedResult(request, e));
}
Aggregations