From 410f42ba8f6fc9203c38550f8f222b6ffde92a0e Mon Sep 17 00:00:00 2001 From: zane-neo Date: Wed, 8 May 2024 23:22:48 +0800 Subject: [PATCH] Add check to multi-modal non image case Signed-off-by: zane-neo --- .../preprocess/MultiModalEmbeddingPreProcessFunction.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/org/opensearch/ml/common/connector/functions/preprocess/MultiModalEmbeddingPreProcessFunction.java b/common/src/main/java/org/opensearch/ml/common/connector/functions/preprocess/MultiModalEmbeddingPreProcessFunction.java index a32fccc6cf..6cd3576d7c 100644 --- a/common/src/main/java/org/opensearch/ml/common/connector/functions/preprocess/MultiModalEmbeddingPreProcessFunction.java +++ b/common/src/main/java/org/opensearch/ml/common/connector/functions/preprocess/MultiModalEmbeddingPreProcessFunction.java @@ -27,7 +27,10 @@ public void validate(MLInput mlInput) { @Override public RemoteInferenceInputDataSet process(MLInput mlInput) { TextDocsInputDataSet inputData = (TextDocsInputDataSet) mlInput.getInputDataset(); - Map processedResult = Map.of("parameters", Map.of("inputText", inputData.getDocs().get(0), "inputImage", inputData.getDocs().get(1))); - return RemoteInferenceInputDataSet.builder().parameters(convertScriptStringToJsonString(processedResult)).build(); + if (inputData.getDocs().size() == 1) { + return RemoteInferenceInputDataSet.builder().parameters(convertScriptStringToJsonString(Map.of("inputText", inputData.getDocs().get(0)))).build(); + } else { + return RemoteInferenceInputDataSet.builder().parameters(convertScriptStringToJsonString(Map.of("inputText", inputData.getDocs().get(0), "inputImage", inputData.getDocs().get(1)))).build(); + } } }