Skip to content

Commit

Permalink
getFirst is not allowed in java 17 (opensearch-project#3226)
Browse files Browse the repository at this point in the history
Signed-off-by: Dhrubo Saha <[email protected]>
  • Loading branch information
dhrubo-os authored Nov 18, 2024
1 parent 7041c22 commit 4f21953
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public CohereMultiModalEmbeddingPreProcessFunction() {
public void validate(MLInput mlInput) {
validateTextDocsInput(mlInput);
List<String> 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
Expand All @@ -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)))
Expand Down

0 comments on commit 4f21953

Please sign in to comment.