From 792814b49b2047a58705b6f92fb1efbe5867c39e Mon Sep 17 00:00:00 2001 From: Yaliang Wu Date: Tue, 3 Oct 2023 21:15:31 -0700 Subject: [PATCH 1/2] support bwc for process function Signed-off-by: Yaliang Wu --- .../opensearch/ml/engine/algorithms/remote/ConnectorUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java index c481725057..deb0f8c45d 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java @@ -94,7 +94,8 @@ private static RemoteInferenceInputDataSet processTextDocsInput(TextDocsInputDat List docs = new ArrayList<>(); for (String doc : inputDataSet.getDocs()) { if (doc != null) { - docs.add(gson.toJson(doc)); + String gsonString = gson.toJson(doc); + docs.add(gsonString.substring(1, gsonString.length() - 1)); } else { docs.add(null); } From fee505504a84ebfad7dd2cb65420d5dcf1d4d582 Mon Sep 17 00:00:00 2001 From: Yaliang Wu Date: Wed, 4 Oct 2023 12:17:30 -0700 Subject: [PATCH 2/2] add comment Signed-off-by: Yaliang Wu --- .../opensearch/ml/engine/algorithms/remote/ConnectorUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java index deb0f8c45d..ab4ed7fd6c 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ConnectorUtils.java @@ -95,6 +95,8 @@ private static RemoteInferenceInputDataSet processTextDocsInput(TextDocsInputDat for (String doc : inputDataSet.getDocs()) { if (doc != null) { String gsonString = gson.toJson(doc); + // in 2.9, user will add " before and after string + // gson.toString(string) will add extra " before after string, so need to remove docs.add(gsonString.substring(1, gsonString.length() - 1)); } else { docs.add(null);