Skip to content

Commit

Permalink
Fix parsing model tensors when the input is a list of docs
Browse files Browse the repository at this point in the history
Signed-off-by: Songkan Tang <[email protected]>
  • Loading branch information
songkant-aws authored and yuye-aws committed Aug 5, 2024
1 parent 5afed45 commit 1361127
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/opensearch/agent/tools/RCATool.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ private List<RealVector> getEmbeddedVector(List<String> docs) {
MLInput.builder().algorithm(FunctionName.TEXT_EMBEDDING).inputDataset(inputDataSet).build());
ActionFuture<MLTaskResponse> mlTaskRspFuture = client.execute(MLPredictionTaskAction.INSTANCE, request);
ModelTensorOutput modelTensorOutput = (ModelTensorOutput) mlTaskRspFuture.actionGet().getOutput();
List<ModelTensor> mlModelOutputs = modelTensorOutput.getMlModelOutputs().get(0).getMlModelTensors();
List<ModelTensor> mlModelOutputs = modelTensorOutput.getMlModelOutputs().stream()
.map(modelTensors -> modelTensors.getMlModelTensors().get(0))
.collect(Collectors.toList());
return mlModelOutputs.stream()
.map(tensor -> {
Number[] data = tensor.getData();
Expand Down

0 comments on commit 1361127

Please sign in to comment.