From d4a4232ccff8cb14f008cb96d6b5daf1a1641a78 Mon Sep 17 00:00:00 2001 From: Xun Zhang Date: Fri, 15 Dec 2023 11:31:22 -0800 Subject: [PATCH] comments updated Signed-off-by: Xun Zhang --- .../ml/common/conversation/ActionConstants.java | 5 ++--- .../org/opensearch/ml/common/utils/StringUtils.java | 2 -- .../action/conversation/GetTracesTransportAction.java | 6 ++---- .../conversation/UpdateConversationRequest.java | 2 +- .../conversation/GetTracesTransportActionTests.java | 11 +---------- .../conversation/UpdateConversationRequestTests.java | 1 - 6 files changed, 6 insertions(+), 21 deletions(-) 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 c0cb5d82de..119d5a6659 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 @@ -29,7 +29,7 @@ public class ActionConstants { public final static String RESPONSE_CONVERSATION_LIST_FIELD = "conversations"; /** name of list on interactions in all responses */ public final static String RESPONSE_INTERACTION_LIST_FIELD = "interactions"; - /** name of list on interactions in all responses */ + /** 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 */ public final static String RESPONSE_INTERACTION_ID_FIELD = "interaction_id"; @@ -65,12 +65,11 @@ public class ActionConstants { public final static String GET_CONVERSATIONS_REST_PATH = BASE_REST_PATH + "/_list"; /** path for update conversations */ public final static String UPDATE_CONVERSATIONS_REST_PATH = BASE_REST_PATH + "/{conversation_id}/_update"; - /** path for put interaction */ /** path for create interaction */ public final static String CREATE_INTERACTION_REST_PATH = BASE_REST_PATH + "/{conversation_id}/_create"; /** path for get interactions */ public final static String GET_INTERACTIONS_REST_PATH = BASE_REST_PATH + "/{conversation_id}/_list"; - /** path for get interactions */ + /** path for get traces */ public final static String GET_TRACES_REST_PATH = "/_plugins/_ml/memory/trace" + "/{interaction_id}/_list"; /** path for delete conversation */ public final static String DELETE_CONVERSATION_REST_PATH = BASE_REST_PATH + "/{conversation_id}/_delete"; diff --git a/common/src/main/java/org/opensearch/ml/common/utils/StringUtils.java b/common/src/main/java/org/opensearch/ml/common/utils/StringUtils.java index 58ba84640d..edbd94b37f 100644 --- a/common/src/main/java/org/opensearch/ml/common/utils/StringUtils.java +++ b/common/src/main/java/org/opensearch/ml/common/utils/StringUtils.java @@ -20,8 +20,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; public class StringUtils { diff --git a/memory/src/main/java/org/opensearch/ml/memory/action/conversation/GetTracesTransportAction.java b/memory/src/main/java/org/opensearch/ml/memory/action/conversation/GetTracesTransportAction.java index cd57d1823c..698136fd95 100644 --- a/memory/src/main/java/org/opensearch/ml/memory/action/conversation/GetTracesTransportAction.java +++ b/memory/src/main/java/org/opensearch/ml/memory/action/conversation/GetTracesTransportAction.java @@ -10,7 +10,6 @@ import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.HandledTransportAction; import org.opensearch.client.Client; -import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.core.action.ActionListener; @@ -33,15 +32,13 @@ public class GetTracesTransportAction extends HandledTransportAction internalListener = ActionListener.runBefore(actionListener, () -> context.restore()); ActionListener> al = ActionListener.wrap(tracesList -> { internalListener.onResponse(new GetTracesResponse(tracesList, from + maxResults, tracesList.size() == maxResults)); diff --git a/memory/src/main/java/org/opensearch/ml/memory/action/conversation/UpdateConversationRequest.java b/memory/src/main/java/org/opensearch/ml/memory/action/conversation/UpdateConversationRequest.java index 6fbe1e6a68..d647c02434 100644 --- a/memory/src/main/java/org/opensearch/ml/memory/action/conversation/UpdateConversationRequest.java +++ b/memory/src/main/java/org/opensearch/ml/memory/action/conversation/UpdateConversationRequest.java @@ -36,7 +36,7 @@ public class UpdateConversationRequest extends ActionRequest { private String conversationId; private Map updateContent; - private static final Set allowedList = new HashSet<>(Arrays.asList(META_NAME_FIELD, APPLICATION_TYPE_FIELD)); + private static final Set allowedList = new HashSet<>(Arrays.asList(META_NAME_FIELD)); @Builder public UpdateConversationRequest(String conversationId, Map updateContent) { diff --git a/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetTracesTransportActionTests.java b/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetTracesTransportActionTests.java index d855cd69ac..c6aef01097 100644 --- a/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetTracesTransportActionTests.java +++ b/memory/src/test/java/org/opensearch/ml/memory/action/conversation/GetTracesTransportActionTests.java @@ -17,7 +17,6 @@ import java.time.Instant; import java.util.Collections; import java.util.List; -import java.util.Set; import org.junit.Before; import org.mockito.ArgumentCaptor; @@ -26,8 +25,6 @@ import org.mockito.MockitoAnnotations; import org.opensearch.action.support.ActionFilters; import org.opensearch.client.Client; -import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.core.action.ActionListener; @@ -48,9 +45,6 @@ public class GetTracesTransportActionTests extends OpenSearchTestCase { @Mock Client client; - @Mock - ClusterService clusterService; - @Mock TransportService transportService; @@ -82,11 +76,8 @@ public void setup() throws IOException { this.threadContext = new ThreadContext(settings); when(this.client.threadPool()).thenReturn(this.threadPool); when(this.threadPool.getThreadContext()).thenReturn(this.threadContext); - when(this.clusterService.getSettings()).thenReturn(settings); - when(this.clusterService.getClusterSettings()) - .thenReturn(new ClusterSettings(settings, Set.of(ConversationalIndexConstants.ML_COMMONS_MEMORY_FEATURE_ENABLED))); - this.action = spy(new GetTracesTransportAction(transportService, actionFilters, cmHandler, client, clusterService)); + this.action = spy(new GetTracesTransportAction(transportService, actionFilters, cmHandler, client)); } public void testGetTraces_noMorePages() { diff --git a/memory/src/test/java/org/opensearch/ml/memory/action/conversation/UpdateConversationRequestTests.java b/memory/src/test/java/org/opensearch/ml/memory/action/conversation/UpdateConversationRequestTests.java index 34f76c44f1..3b25f1b174 100644 --- a/memory/src/test/java/org/opensearch/ml/memory/action/conversation/UpdateConversationRequestTests.java +++ b/memory/src/test/java/org/opensearch/ml/memory/action/conversation/UpdateConversationRequestTests.java @@ -101,7 +101,6 @@ public void testParse_Success() throws IOException { UpdateConversationRequest updateConversationRequest = UpdateConversationRequest.parse(parser, "conversationId"); assertEquals(updateConversationRequest.getConversationId(), "conversationId"); assertEquals("new name", updateConversationRequest.getUpdateContent().get("name")); - assertEquals("new type", updateConversationRequest.getUpdateContent().get("application_type")); } @Test