Skip to content

Commit 96ac05e

Browse files
Revert "Add application_type to ConversationMeta; update tests (opensearch-project#3282)" (opensearch-project#3315)
This reverts commit d09374c. Signed-off-by: rithin-pullela-aws <[email protected]>
1 parent 32a5788 commit 96ac05e

File tree

7 files changed

+20
-40
lines changed

7 files changed

+20
-40
lines changed

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

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ public class ConversationMeta implements Writeable, ToXContentObject {
5151
@Getter
5252
private String user;
5353
@Getter
54-
private String applicationType;
55-
@Getter
5654
private Map<String, String> additionalInfos;
5755

5856
/**
@@ -76,9 +74,8 @@ public static ConversationMeta fromMap(String id, Map<String, Object> docFields)
7674
Instant updated = Instant.parse((String) docFields.get(ConversationalIndexConstants.META_UPDATED_TIME_FIELD));
7775
String name = (String) docFields.get(ConversationalIndexConstants.META_NAME_FIELD);
7876
String user = (String) docFields.get(ConversationalIndexConstants.USER_FIELD);
79-
String applicationType = (String) docFields.get(ConversationalIndexConstants.APPLICATION_TYPE_FIELD);
8077
Map<String, String> additionalInfos = (Map<String, String>) docFields.get(ConversationalIndexConstants.META_ADDITIONAL_INFO_FIELD);
81-
return new ConversationMeta(id, created, updated, name, user, applicationType, additionalInfos);
78+
return new ConversationMeta(id, created, updated, name, user, additionalInfos);
8279
}
8380

8481
/**
@@ -94,14 +91,13 @@ public static ConversationMeta fromStream(StreamInput in) throws IOException {
9491
Instant updated = in.readInstant();
9592
String name = in.readString();
9693
String user = in.readOptionalString();
97-
String applicationType = in.readOptionalString();
9894
Map<String, String> additionalInfos = null;
9995
if (in.getVersion().onOrAfter(MINIMAL_SUPPORTED_VERSION_FOR_ADDITIONAL_INFO)) {
10096
if (in.readBoolean()) {
10197
additionalInfos = in.readMap(StreamInput::readString, StreamInput::readString);
10298
}
10399
}
104-
return new ConversationMeta(id, created, updated, name, user, applicationType, additionalInfos);
100+
return new ConversationMeta(id, created, updated, name, user, additionalInfos);
105101
}
106102

107103
@Override
@@ -111,7 +107,6 @@ public void writeTo(StreamOutput out) throws IOException {
111107
out.writeInstant(updatedTime);
112108
out.writeString(name);
113109
out.writeOptionalString(user);
114-
out.writeOptionalString(applicationType);
115110
if (out.getVersion().onOrAfter(MINIMAL_SUPPORTED_VERSION_FOR_ADDITIONAL_INFO)) {
116111
if (additionalInfos == null) {
117112
out.writeBoolean(false);
@@ -134,10 +129,6 @@ public String toString() {
134129
+ updatedTime.toString()
135130
+ ", user="
136131
+ user
137-
+ ", applicationType="
138-
+ applicationType
139-
+ ", additionalInfos="
140-
+ additionalInfos
141132
+ "}";
142133
}
143134

@@ -151,10 +142,7 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContentObject.Para
151142
if (this.user != null) {
152143
builder.field(ConversationalIndexConstants.USER_FIELD, this.user);
153144
}
154-
if (this.applicationType != null && !this.applicationType.trim().isEmpty()) {
155-
builder.field(ConversationalIndexConstants.APPLICATION_TYPE_FIELD, this.applicationType);
156-
}
157-
if (this.additionalInfos != null && !additionalInfos.isEmpty()) {
145+
if (this.additionalInfos != null) {
158146
builder.field(ConversationalIndexConstants.META_ADDITIONAL_INFO_FIELD, this.additionalInfos);
159147
}
160148
builder.endObject();
@@ -171,9 +159,7 @@ public boolean equals(Object other) {
171159
&& Objects.equals(this.user, otherConversation.user)
172160
&& Objects.equals(this.createdTime, otherConversation.createdTime)
173161
&& Objects.equals(this.updatedTime, otherConversation.updatedTime)
174-
&& Objects.equals(this.name, otherConversation.name)
175-
&& Objects.equals(this.applicationType, otherConversation.applicationType)
176-
&& Objects.equals(this.additionalInfos, otherConversation.additionalInfos);
162+
&& Objects.equals(this.name, otherConversation.name);
177163
}
178164

179165
}

common/src/test/java/org/opensearch/ml/common/conversation/ConversationMetaTests.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class ConversationMetaTests {
3030
@Before
3131
public void setUp() {
3232
time = Instant.now();
33-
conversationMeta = new ConversationMeta("test_id", time, time, "test_name", "admin", "conversational-search", null);
33+
conversationMeta = new ConversationMeta("test_id", time, time, "test_name", "admin", null);
3434
}
3535

3636
@Test
@@ -41,7 +41,6 @@ public void test_fromSearchHit() throws IOException {
4141
content.field(ConversationalIndexConstants.META_UPDATED_TIME_FIELD, time);
4242
content.field(ConversationalIndexConstants.META_NAME_FIELD, "meta name");
4343
content.field(ConversationalIndexConstants.USER_FIELD, "admin");
44-
content.field(ConversationalIndexConstants.APPLICATION_TYPE_FIELD, "conversational-search");
4544
content.field(ConversationalIndexConstants.META_ADDITIONAL_INFO_FIELD, Map.of("test_key", "test_value"));
4645
content.endObject();
4746

@@ -52,7 +51,6 @@ public void test_fromSearchHit() throws IOException {
5251
assertEquals(conversationMeta.getId(), "cId");
5352
assertEquals(conversationMeta.getName(), "meta name");
5453
assertEquals(conversationMeta.getUser(), "admin");
55-
assertEquals(conversationMeta.getApplicationType(), "conversational-search");
5654
assertEquals(conversationMeta.getAdditionalInfos().get("test_key"), "test_value");
5755
}
5856

@@ -85,7 +83,6 @@ public void test_fromStream() throws IOException {
8583
assertEquals(meta.getId(), conversationMeta.getId());
8684
assertEquals(meta.getName(), conversationMeta.getName());
8785
assertEquals(meta.getUser(), conversationMeta.getUser());
88-
assertEquals(meta.getApplicationType(), conversationMeta.getApplicationType());
8986
}
9087

9188
@Test
@@ -96,15 +93,14 @@ public void test_ToXContent() throws IOException {
9693
Instant.ofEpochMilli(123),
9794
"test meta",
9895
"admin",
99-
"neural-search",
10096
null
10197
);
10298
XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent());
10399
conversationMeta.toXContent(builder, EMPTY_PARAMS);
104100
String content = TestHelper.xContentBuilderToString(builder);
105101
assertEquals(
106102
content,
107-
"{\"memory_id\":\"test_id\",\"create_time\":\"1970-01-01T00:00:00.123Z\",\"updated_time\":\"1970-01-01T00:00:00.123Z\",\"name\":\"test meta\",\"user\":\"admin\",\"application_type\":\"neural-search\"}"
103+
"{\"memory_id\":\"test_id\",\"create_time\":\"1970-01-01T00:00:00.123Z\",\"updated_time\":\"1970-01-01T00:00:00.123Z\",\"name\":\"test meta\",\"user\":\"admin\"}"
108104
);
109105
}
110106

@@ -116,11 +112,10 @@ public void test_toString() {
116112
Instant.ofEpochMilli(123),
117113
"test meta",
118114
"admin",
119-
"conversational-search",
120115
null
121116
);
122117
assertEquals(
123-
"{id=test_id, name=test meta, created=1970-01-01T00:00:00.123Z, updated=1970-01-01T00:00:00.123Z, user=admin, applicationType=conversational-search, additionalInfos=null}",
118+
"{id=test_id, name=test meta, created=1970-01-01T00:00:00.123Z, updated=1970-01-01T00:00:00.123Z, user=admin}",
124119
conversationMeta.toString()
125120
);
126121
}
@@ -133,7 +128,6 @@ public void test_equal() {
133128
Instant.ofEpochMilli(123),
134129
"test meta",
135130
"admin",
136-
"conversational-search",
137131
null
138132
);
139133
assertEquals(meta.equals(conversationMeta), false);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
public class GetConversationResponseTests extends OpenSearchTestCase {
3939

4040
public void testGetConversationResponseStreaming() throws IOException {
41-
ConversationMeta convo = new ConversationMeta("cid", Instant.now(), Instant.now(), "name", null, null, null);
41+
ConversationMeta convo = new ConversationMeta("cid", Instant.now(), Instant.now(), "name", null, null);
4242
GetConversationResponse response = new GetConversationResponse(convo);
4343
assert (response.getConversation().equals(convo));
4444

@@ -51,7 +51,7 @@ public void testGetConversationResponseStreaming() throws IOException {
5151
}
5252

5353
public void testToXContent() throws IOException {
54-
ConversationMeta convo = new ConversationMeta("cid", Instant.now(), Instant.now(), "name", null, null, null);
54+
ConversationMeta convo = new ConversationMeta("cid", Instant.now(), Instant.now(), "name", null, null);
5555
GetConversationResponse response = new GetConversationResponse(convo);
5656
XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent());
5757
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
@@ -68,7 +68,7 @@ public void testToXContent() throws IOException {
6868

6969
public void testToXContent_withAdditionalInfo() throws IOException {
7070
Map<String, String> additionalInfos = Map.of("key1", "value1");
71-
ConversationMeta convo = new ConversationMeta("cid", Instant.now(), Instant.now(), "name", null, null, additionalInfos);
71+
ConversationMeta convo = new ConversationMeta("cid", Instant.now(), Instant.now(), "name", null, additionalInfos);
7272
GetConversationResponse response = new GetConversationResponse(convo);
7373
XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent());
7474
response.toXContent(builder, ToXContent.EMPTY_PARAMS);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void setup() throws IOException {
107107
}
108108

109109
public void testGetConversation() {
110-
ConversationMeta result = new ConversationMeta("test-cid", Instant.now(), Instant.now(), "name", null, null, null);
110+
ConversationMeta result = new ConversationMeta("test-cid", Instant.now(), Instant.now(), "name", null, null);
111111
doAnswer(invocation -> {
112112
ActionListener<ConversationMeta> listener = invocation.getArgument(1);
113113
listener.onResponse(result);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public class GetConversationsResponseTests extends OpenSearchTestCase {
4646
public void setup() {
4747
conversations = List
4848
.of(
49-
new ConversationMeta("0", Instant.now(), Instant.now(), "name0", "user0", null, null),
50-
new ConversationMeta("1", Instant.now(), Instant.now(), "name1", "user0", null, null),
51-
new ConversationMeta("2", Instant.now(), Instant.now(), "name2", "user2", null, null)
49+
new ConversationMeta("0", Instant.now(), Instant.now(), "name0", "user0", null),
50+
new ConversationMeta("1", Instant.now(), Instant.now(), "name1", "user0", null),
51+
new ConversationMeta("2", Instant.now(), Instant.now(), "name2", "user2", null)
5252
);
5353
}
5454

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ public void testGetConversations() {
114114
log.info("testing get conversations transport");
115115
List<ConversationMeta> testResult = List
116116
.of(
117-
new ConversationMeta("testcid1", Instant.now(), Instant.now(), "", null, null, null),
118-
new ConversationMeta("testcid2", Instant.now(), Instant.now(), "testname", null, null, null)
117+
new ConversationMeta("testcid1", Instant.now(), Instant.now(), "", null, null),
118+
new ConversationMeta("testcid2", Instant.now(), Instant.now(), "testname", null, null)
119119
);
120120
doAnswer(invocation -> {
121121
ActionListener<List<ConversationMeta>> listener = invocation.getArgument(2);
@@ -132,9 +132,9 @@ public void testGetConversations() {
132132
public void testPagination() {
133133
List<ConversationMeta> testResult = List
134134
.of(
135-
new ConversationMeta("testcid1", Instant.now(), Instant.now(), "", null, null, null),
136-
new ConversationMeta("testcid2", Instant.now(), Instant.now(), "testname", null, null, null),
137-
new ConversationMeta("testcid3", Instant.now(), Instant.now(), "testname", null, null, null)
135+
new ConversationMeta("testcid1", Instant.now(), Instant.now(), "", null, null),
136+
new ConversationMeta("testcid2", Instant.now(), Instant.now(), "testname", null, null),
137+
new ConversationMeta("testcid3", Instant.now(), Instant.now(), "testname", null, null)
138138
);
139139
doAnswer(invocation -> {
140140
ActionListener<List<ConversationMeta>> listener = invocation.getArgument(2);

memory/src/test/java/org/opensearch/ml/memory/index/OpenSearchConversationalMemoryHandlerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public void testSearchInteractions_Future() {
315315
}
316316

317317
public void testGetAConversation_Future() {
318-
ConversationMeta response = new ConversationMeta("cid", Instant.now(), Instant.now(), "boring name", null, null, null);
318+
ConversationMeta response = new ConversationMeta("cid", Instant.now(), Instant.now(), "boring name", null, null);
319319
doAnswer(invocation -> {
320320
ActionListener<ConversationMeta> listener = invocation.getArgument(1);
321321
listener.onResponse(response);

0 commit comments

Comments
 (0)