From 4f21953157cd4e04672e034dab5c9b401a2c07a2 Mon Sep 17 00:00:00 2001 From: Dhrubo Saha Date: Mon, 18 Nov 2024 11:48:05 -0800 Subject: [PATCH] getFirst is not allowed in java 17 (#3226) Signed-off-by: Dhrubo Saha --- .../CohereMultiModalEmbeddingPreProcessFunction.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/org/opensearch/ml/common/connector/functions/preprocess/CohereMultiModalEmbeddingPreProcessFunction.java b/common/src/main/java/org/opensearch/ml/common/connector/functions/preprocess/CohereMultiModalEmbeddingPreProcessFunction.java index 80c615cb10..7d25fa7202 100644 --- a/common/src/main/java/org/opensearch/ml/common/connector/functions/preprocess/CohereMultiModalEmbeddingPreProcessFunction.java +++ b/common/src/main/java/org/opensearch/ml/common/connector/functions/preprocess/CohereMultiModalEmbeddingPreProcessFunction.java @@ -25,9 +25,10 @@ public CohereMultiModalEmbeddingPreProcessFunction() { public void validate(MLInput mlInput) { validateTextDocsInput(mlInput); List docs = ((TextDocsInputDataSet) mlInput.getInputDataset()).getDocs(); - if (docs.isEmpty() || (docs.size() == 1 && docs.getFirst() == null)) { + if (docs == null || docs.isEmpty() || (docs.size() == 1 && docs.get(0) == null)) { throw new IllegalArgumentException("No image provided"); } + } @Override @@ -41,7 +42,7 @@ public RemoteInferenceInputDataSet process(MLInput mlInput) { * connector.pre_process.cohere.embedding * Cohere expects An array of image data URIs for the model to embed. Maximum number of images per call is 1. */ - parametersMap.put("images", inputData.getDocs().getFirst()); + parametersMap.put("images", inputData.getDocs().get(0)); return RemoteInferenceInputDataSet .builder() .parameters(convertScriptStringToJsonString(Map.of("parameters", parametersMap)))