Skip to content

Commit 914e54f

Browse files
committed
rename memory field names in responses
Signed-off-by: Xun Zhang <xunzh@amazon.com>
1 parent c53d586 commit 914e54f

File tree

5 files changed

+10
-16
lines changed

5 files changed

+10
-16
lines changed

common/src/main/java/org/opensearch/ml/common/conversation/ActionConstants.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public class ActionConstants {
2626
public final static String CONVERSATION_ID_FIELD = "memory_id";
2727

2828
/** name of list of conversations in all responses */
29-
public final static String RESPONSE_CONVERSATION_LIST_FIELD = "conversations";
29+
public final static String RESPONSE_CONVERSATION_LIST_FIELD = "memories";
3030
/** name of list on interactions in all responses */
31-
public final static String RESPONSE_INTERACTION_LIST_FIELD = "interactions";
31+
public final static String RESPONSE_INTERACTION_LIST_FIELD = "messages";
3232
/** name of list on traces in all responses */
3333
public final static String RESPONSE_TRACES_LIST_FIELD = "traces";
3434
/** name of interaction Id field in all responses */

memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetConversationsResponseTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void testToXContent_MoreTokens() throws IOException {
7373
XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent());
7474
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
7575
String result = BytesReference.bytes(builder).utf8ToString();
76-
String expected = "{\"conversations\":[{\"memory_id\":\"0\",\"create_time\":\""
76+
String expected = "{\"memories\":[{\"memory_id\":\"0\",\"create_time\":\""
7777
+ conversation.getCreatedTime()
7878
+ "\"updated_time\":\""
7979
+ conversation.getUpdatedTime()
@@ -93,7 +93,7 @@ public void testToXContent_NoMoreTokens() throws IOException {
9393
XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent());
9494
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
9595
String result = BytesReference.bytes(builder).utf8ToString();
96-
String expected = "{\"conversations\":[{\"memory_id\":\"0\",\"create_time\":\""
96+
String expected = "{\"memories\":[{\"memory_id\":\"0\",\"create_time\":\""
9797
+ conversation.getCreatedTime()
9898
+ "\"updated_time\":\""
9999
+ conversation.getUpdatedTime()

memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetInteractionsResponseTests.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,11 @@ public void testToXContent_MoreTokens() throws IOException {
100100
XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent());
101101
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
102102
String result = BytesReference.bytes(builder).utf8ToString();
103-
String expected = "{\"interactions\":[{\"memory_id\":\"cid\",\"message_id\":\"id0\",\"create_time\":\""
103+
String expected = "{\"messages\":[{\"memory_id\":\"cid\",\"message_id\":\"id0\",\"create_time\":\""
104104
+ interaction.getCreateTime()
105105
+ "\",\"input\":\"input\",\"prompt_template\":\"pt\",\"response\":\"response\",\"origin\":\"origin\",\"additional_info\":{\"metadata\":\"some meta\"}}],\"next_token\":2}";
106-
log.info(result);
107-
log.info(expected);
108106
// Sometimes there's an extra trailing 0 in the time stringification, so just assert closeness
109107
LevenshteinDistance ld = new LevenshteinDistance();
110-
log.info(ld.getDistance(result, expected));
111108
assert (ld.getDistance(result, expected) > 0.95);
112109
}
113110

@@ -117,14 +114,11 @@ public void testToXContent_NoMoreTokens() throws IOException {
117114
XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent());
118115
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
119116
String result = BytesReference.bytes(builder).utf8ToString();
120-
String expected = "{\"interactions\":[{\"memory_id\":\"cid\",\"message_id\":\"id0\",\"create_time\":\""
117+
String expected = "{\"messages\":[{\"memory_id\":\"cid\",\"message_id\":\"id0\",\"create_time\":\""
121118
+ interaction.getCreateTime()
122119
+ "\",\"input\":\"input\",\"prompt_template\":\"pt\",\"response\":\"response\",\"origin\":\"origin\",\"additional_info\":{\"metadata\":\"some meta\"}}]}";
123-
log.info(result);
124-
log.info(expected);
125120
// Sometimes there's an extra trailing 0 in the time stringification, so just assert closeness
126121
LevenshteinDistance ld = new LevenshteinDistance();
127-
log.info(ld.getDistance(result, expected));
128122
assert (ld.getDistance(result, expected) > 0.95);
129123
}
130124

plugin/src/test/java/org/opensearch/ml/rest/RestMemoryGetInteractionsActionIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public void testGetInteractions_NoConversation() throws IOException {
6262
HttpEntity httpEntity = response.getEntity();
6363
String entityString = TestHelper.httpEntityToString(httpEntity);
6464
Map map = gson.fromJson(entityString, Map.class);
65-
assert (map.containsKey("interactions"));
65+
assert (map.containsKey(RESPONSE_INTERACTION_LIST_FIELD));
6666
assert (!map.containsKey("next_token"));
67-
assert (((ArrayList) map.get("interactions")).size() == 0);
67+
assert (((ArrayList) map.get(RESPONSE_INTERACTION_LIST_FIELD)).size() == 0);
6868
}
6969

7070
public void testGetInteractions_NoInteractions() throws IOException {

search-processors/src/main/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParameters.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class GenerativeQAParameters implements Writeable, ToXContentObject {
4848

4949
// Optional parameter; if provided, conversational memory will be used for RAG
5050
// and the current interaction will be saved in the conversation referenced by this id.
51-
private static final ParseField CONVERSATION_ID = new ParseField("conversation_id");
51+
private static final ParseField CONVERSATION_ID = new ParseField("memory_id");
5252

5353
// Optional parameter; if an LLM model is not set at the search pipeline level, one must be
5454
// provided at the search request level.
@@ -64,7 +64,7 @@ public class GenerativeQAParameters implements Writeable, ToXContentObject {
6464

6565
// Optional parameter; this parameter controls the number of the interactions to include
6666
// in the user prompt.
67-
private static final ParseField INTERACTION_SIZE = new ParseField("interaction_size");
67+
private static final ParseField INTERACTION_SIZE = new ParseField("message_size");
6868

6969
// Optional parameter; this parameter controls how long the search pipeline waits for a response
7070
// from a remote inference endpoint before timing out the request.

0 commit comments

Comments
 (0)