diff --git a/search-processors/src/main/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParameters.java b/search-processors/src/main/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParameters.java index 7dd9444c06..0cf51a8549 100644 --- a/search-processors/src/main/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParameters.java +++ b/search-processors/src/main/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParameters.java @@ -88,7 +88,7 @@ public class GenerativeQAParameters implements Writeable, ToXContentObject { public static final int SIZE_NULL_VALUE = -1; - private static final Version MINIMAL_SUPPORTED_VERSION_FOR_BEDROCK_CONVERSE_LLM_MESSAGES = CommonValue.VERSION_2_18_0; + static final Version MINIMAL_SUPPORTED_VERSION_FOR_BEDROCK_CONVERSE_LLM_MESSAGES = CommonValue.VERSION_2_18_0; @Setter @Getter diff --git a/search-processors/src/test/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParametersTests.java b/search-processors/src/test/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParametersTests.java index 4835b764fe..2ccdb6a8e2 100644 --- a/search-processors/src/test/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParametersTests.java +++ b/search-processors/src/test/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParametersTests.java @@ -26,7 +26,10 @@ import java.util.List; import java.util.Map; +import org.opensearch.Version; import org.opensearch.action.search.SearchRequest; +import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.XContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -179,6 +182,48 @@ public void testWriteTo() throws IOException { assertTrue(timeout == intValues.get(2)); } + public void testWriteToBwcBedrockConverse() throws IOException { + String conversationId = "a"; + String llmModel = "b"; + String llmQuestion = "c"; + String systemPrompt = "s"; + String userInstructions = "u"; + int contextSize = 1; + int interactionSize = 2; + int timeout = 10; + String llmResponseField = "text"; + GenerativeQAParameters expected = new GenerativeQAParameters( + conversationId, + llmModel, + llmQuestion, + systemPrompt, + userInstructions, + contextSize, + interactionSize, + timeout, + llmResponseField, + messageList + ); + + // Version.2_18_0 (MINIMAL_SUPPORTED_VERSION_FOR_BEDROCK_CONVERSE_LLM_MESSAGES) + BytesStreamOutput output = new BytesStreamOutput(); + output.setVersion(GenerativeQAParameters.MINIMAL_SUPPORTED_VERSION_FOR_BEDROCK_CONVERSE_LLM_MESSAGES); + expected.writeTo(output); + StreamInput input = output.bytes().streamInput(); + input.setVersion(GenerativeQAParameters.MINIMAL_SUPPORTED_VERSION_FOR_BEDROCK_CONVERSE_LLM_MESSAGES); + GenerativeQAParameters actual = new GenerativeQAParameters(input); + assertEquals(expected, actual); + + // Version.2_17_0 (LlmMessages should be empty list) + output = new BytesStreamOutput(); + output.setVersion(Version.V_2_17_0); + expected.writeTo(output); + input = output.bytes().streamInput(); + input.setVersion(Version.V_2_17_0); + actual = new GenerativeQAParameters(input); + assertTrue(actual.getLlmMessages().isEmpty()); + } + public void testMisc() { String conversationId = "a"; String llmModel = "b";