diff --git a/common/src/main/java/org/opensearch/ml/common/conversation/ActionConstants.java b/common/src/main/java/org/opensearch/ml/common/conversation/ActionConstants.java index 6dc1f1ba6a..783e9c815a 100644 --- a/common/src/main/java/org/opensearch/ml/common/conversation/ActionConstants.java +++ b/common/src/main/java/org/opensearch/ml/common/conversation/ActionConstants.java @@ -26,9 +26,9 @@ public class ActionConstants { public final static String CONVERSATION_ID_FIELD = "memory_id"; /** name of list of conversations in all responses */ - public final static String RESPONSE_CONVERSATION_LIST_FIELD = "conversations"; + public final static String RESPONSE_CONVERSATION_LIST_FIELD = "memories"; /** name of list on interactions in all responses */ - public final static String RESPONSE_INTERACTION_LIST_FIELD = "interactions"; + public final static String RESPONSE_INTERACTION_LIST_FIELD = "messages"; /** name of list on traces in all responses */ public final static String RESPONSE_TRACES_LIST_FIELD = "traces"; /** name of interaction Id field in all responses */ diff --git a/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetConversationsResponseTests.java b/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetConversationsResponseTests.java index 44883bfcaf..a04a022973 100644 --- a/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetConversationsResponseTests.java +++ b/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetConversationsResponseTests.java @@ -73,7 +73,7 @@ public void testToXContent_MoreTokens() throws IOException { XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); response.toXContent(builder, ToXContent.EMPTY_PARAMS); String result = BytesReference.bytes(builder).utf8ToString(); - String expected = "{\"conversations\":[{\"memory_id\":\"0\",\"create_time\":\"" + String expected = "{\"memories\":[{\"memory_id\":\"0\",\"create_time\":\"" + conversation.getCreatedTime() + "\"updated_time\":\"" + conversation.getUpdatedTime() @@ -93,7 +93,7 @@ public void testToXContent_NoMoreTokens() throws IOException { XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); response.toXContent(builder, ToXContent.EMPTY_PARAMS); String result = BytesReference.bytes(builder).utf8ToString(); - String expected = "{\"conversations\":[{\"memory_id\":\"0\",\"create_time\":\"" + String expected = "{\"memories\":[{\"memory_id\":\"0\",\"create_time\":\"" + conversation.getCreatedTime() + "\"updated_time\":\"" + conversation.getUpdatedTime() diff --git a/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetInteractionsResponseTests.java b/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetInteractionsResponseTests.java index 7f8bdfd27f..9bb3a87bc8 100644 --- a/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetInteractionsResponseTests.java +++ b/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetInteractionsResponseTests.java @@ -100,14 +100,11 @@ public void testToXContent_MoreTokens() throws IOException { XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); response.toXContent(builder, ToXContent.EMPTY_PARAMS); String result = BytesReference.bytes(builder).utf8ToString(); - String expected = "{\"interactions\":[{\"memory_id\":\"cid\",\"message_id\":\"id0\",\"create_time\":\"" + String expected = "{\"messages\":[{\"memory_id\":\"cid\",\"message_id\":\"id0\",\"create_time\":\"" + interaction.getCreateTime() + "\",\"input\":\"input\",\"prompt_template\":\"pt\",\"response\":\"response\",\"origin\":\"origin\",\"additional_info\":{\"metadata\":\"some meta\"}}],\"next_token\":2}"; - log.info(result); - log.info(expected); // Sometimes there's an extra trailing 0 in the time stringification, so just assert closeness LevenshteinDistance ld = new LevenshteinDistance(); - log.info(ld.getDistance(result, expected)); assert (ld.getDistance(result, expected) > 0.95); } @@ -117,14 +114,11 @@ public void testToXContent_NoMoreTokens() throws IOException { XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent()); response.toXContent(builder, ToXContent.EMPTY_PARAMS); String result = BytesReference.bytes(builder).utf8ToString(); - String expected = "{\"interactions\":[{\"memory_id\":\"cid\",\"message_id\":\"id0\",\"create_time\":\"" + String expected = "{\"messages\":[{\"memory_id\":\"cid\",\"message_id\":\"id0\",\"create_time\":\"" + interaction.getCreateTime() + "\",\"input\":\"input\",\"prompt_template\":\"pt\",\"response\":\"response\",\"origin\":\"origin\",\"additional_info\":{\"metadata\":\"some meta\"}}]}"; - log.info(result); - log.info(expected); // Sometimes there's an extra trailing 0 in the time stringification, so just assert closeness LevenshteinDistance ld = new LevenshteinDistance(); - log.info(ld.getDistance(result, expected)); assert (ld.getDistance(result, expected) > 0.95); } diff --git a/plugin/src/test/java/org/opensearch/ml/rest/RestMemoryGetConversationsActionIT.java b/plugin/src/test/java/org/opensearch/ml/rest/RestMemoryGetConversationsActionIT.java index 49891cffd1..49619573a5 100644 --- a/plugin/src/test/java/org/opensearch/ml/rest/RestMemoryGetConversationsActionIT.java +++ b/plugin/src/test/java/org/opensearch/ml/rest/RestMemoryGetConversationsActionIT.java @@ -61,9 +61,9 @@ public void testNoConversations_EmptyList() throws IOException { HttpEntity httpEntity = response.getEntity(); String entityString = TestHelper.httpEntityToString(httpEntity); Map map = gson.fromJson(entityString, Map.class); - assert (map.containsKey("conversations")); + assert (map.containsKey(RESPONSE_CONVERSATION_LIST_FIELD)); assert (!map.containsKey("next_token")); - assert (((ArrayList) map.get("conversations")).size() == 0); + assert (((ArrayList) map.get(RESPONSE_CONVERSATION_LIST_FIELD)).size() == 0); } public void testGetConversations_LastPage() throws IOException { diff --git a/plugin/src/test/java/org/opensearch/ml/rest/RestMemoryGetInteractionsActionIT.java b/plugin/src/test/java/org/opensearch/ml/rest/RestMemoryGetInteractionsActionIT.java index 9048f028be..cc2ddefdfc 100644 --- a/plugin/src/test/java/org/opensearch/ml/rest/RestMemoryGetInteractionsActionIT.java +++ b/plugin/src/test/java/org/opensearch/ml/rest/RestMemoryGetInteractionsActionIT.java @@ -62,9 +62,9 @@ public void testGetInteractions_NoConversation() throws IOException { HttpEntity httpEntity = response.getEntity(); String entityString = TestHelper.httpEntityToString(httpEntity); Map map = gson.fromJson(entityString, Map.class); - assert (map.containsKey("interactions")); + assert (map.containsKey(RESPONSE_INTERACTION_LIST_FIELD)); assert (!map.containsKey("next_token")); - assert (((ArrayList) map.get("interactions")).size() == 0); + assert (((ArrayList) map.get(RESPONSE_INTERACTION_LIST_FIELD)).size() == 0); } public void testGetInteractions_NoInteractions() throws IOException { 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 2710b26a57..19b80a838f 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 @@ -48,7 +48,7 @@ public class GenerativeQAParameters implements Writeable, ToXContentObject { // Optional parameter; if provided, conversational memory will be used for RAG // and the current interaction will be saved in the conversation referenced by this id. - private static final ParseField CONVERSATION_ID = new ParseField("conversation_id"); + private static final ParseField CONVERSATION_ID = new ParseField("memory_id"); // Optional parameter; if an LLM model is not set at the search pipeline level, one must be // provided at the search request level. @@ -64,7 +64,7 @@ public class GenerativeQAParameters implements Writeable, ToXContentObject { // Optional parameter; this parameter controls the number of the interactions to include // in the user prompt. - private static final ParseField INTERACTION_SIZE = new ParseField("interaction_size"); + private static final ParseField INTERACTION_SIZE = new ParseField("message_size"); // Optional parameter; this parameter controls how long the search pipeline waits for a response // from a remote inference endpoint before timing out the request.