Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename the conversation/interaction indices to memory meta/message #1678

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ConversationalIndexConstants {
/** Version of the meta index schema */
public final static Integer META_INDEX_SCHEMA_VERSION = 1;
/** Name of the conversational metadata index */
public final static String META_INDEX_NAME = ".plugins-ml-conversation-meta";
public final static String META_INDEX_NAME = ".plugins-ml-memory-meta";
/** Name of the metadata field for initial timestamp */
public final static String META_CREATED_FIELD = "create_time";
/** Name of the metadata field for name of the conversation */
Expand Down Expand Up @@ -59,7 +59,7 @@ public class ConversationalIndexConstants {
/** Version of the interactions index schema */
public final static Integer INTERACTIONS_INDEX_SCHEMA_VERSION = 1;
/** Name of the conversational interactions index */
public final static String INTERACTIONS_INDEX_NAME = ".plugins-ml-conversation-interactions";
public final static String INTERACTIONS_INDEX_NAME = ".plugins-ml-memory-message";
/** Name of the interaction field for the conversation Id */
public final static String INTERACTIONS_CONVERSATION_ID_FIELD = "conversation_id";
/** Name of the interaction field for the human input */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@

package org.opensearch.ml.engine.tools;

import lombok.Getter;
import lombok.Setter;
import static org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT;
import static org.opensearch.ml.common.utils.StringUtils.gson;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.logging.log4j.util.Strings;
import org.opensearch.action.admin.indices.get.GetIndexRequest;
import org.opensearch.action.admin.indices.get.GetIndexResponse;
Expand All @@ -20,13 +26,9 @@
import org.opensearch.ml.common.spi.tools.Parser;
import org.opensearch.ml.common.spi.tools.Tool;
import org.opensearch.ml.common.spi.tools.ToolAnnotation;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import static org.opensearch.action.support.clustermanager.ClusterManagerNodeRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT;
import static org.opensearch.ml.common.utils.StringUtils.gson;
import lombok.Getter;
import lombok.Setter;

@ToolAnnotation(IndexMappingTool.NAME)
public class IndexMappingTool implements Tool {
Expand Down Expand Up @@ -74,7 +76,7 @@ public <T> void run(Map<String, String> parameters, ActionListener<T> listener)
listener.onResponse(empty);
return;
}

final String[] indices = indexList.toArray(Strings.EMPTY_ARRAY);

final IndicesOptions indicesOptions = IndicesOptions.strictExpand();
Expand All @@ -96,16 +98,16 @@ public void onResponse(GetIndexResponse getIndexResponse) {
StringBuilder sb = new StringBuilder();
for (String index : getIndexResponse.indices()) {
sb.append("index: ").append(index).append("\n\n");

MappingMetadata mapping = getIndexResponse.mappings().get(index);
if (mapping != null) {
sb.append("mappings:\n");
for (Entry<String, Object> entry: mapping.sourceAsMap().entrySet()) {
sb.append(entry.getKey()).append("=").append(entry.getValue()).append('\n');
}
for (Entry<String, Object> entry : mapping.sourceAsMap().entrySet()) {
sb.append(entry.getKey()).append("=").append(entry.getValue()).append('\n');
}
sb.append("\n\n");
}

Settings settings = getIndexResponse.settings().get(index);
if (settings != null) {
sb.append("settings:\n").append(settings.toDelimitedString('\n')).append("\n\n");
Expand All @@ -126,7 +128,8 @@ public void onFailure(final Exception e) {
}

};
final GetIndexRequest getIndexRequest = new GetIndexRequest().indices(indices)
final GetIndexRequest getIndexRequest = new GetIndexRequest()
.indices(indices)
.indicesOptions(indicesOptions)
.local(local)
.clusterManagerNodeTimeout(clusterManagerNodeTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

package org.opensearch.ml.engine.tools;

import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.Strings;
import org.opensearch.ml.common.spi.tools.Tool;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;

import java.util.Arrays;
import java.util.Collections;
Expand All @@ -21,6 +19,11 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opensearch.action.admin.indices.get.GetIndexResponse;
import org.opensearch.client.AdminClient;
import org.opensearch.client.Client;
Expand All @@ -29,13 +32,9 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.XContentHelper;
import org.opensearch.common.xcontent.json.JsonXContent;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.Strings;
import org.opensearch.ml.common.spi.tools.Tool;

public class IndexMappingToolTests {

Expand Down Expand Up @@ -68,7 +67,6 @@ public void setup() {
emptyParams = Collections.emptyMap();
}


@Test
public void testRunAsyncNoIndexParams() throws Exception {
Tool tool = IndexMappingTool.Factory.getInstance().create(Collections.emptyMap());
Expand All @@ -80,7 +78,7 @@ public void testRunAsyncNoIndexParams() throws Exception {
future.join();
assertEquals("There were no results searching the index parameter [null].", future.get());
}

@Test
public void testRunAsyncNoIndices() throws Exception {
Tool tool = IndexMappingTool.Factory.getInstance().create(Collections.emptyMap());
Expand All @@ -92,7 +90,7 @@ public void testRunAsyncNoIndices() throws Exception {
future.join();
assertEquals("There were no results searching the index parameter [null].", future.get());
}

@Test
public void testRunAsyncNoResults() throws Exception {
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -164,9 +162,8 @@ public void testRunAsyncIndexMapping() throws Exception {

assertTrue(responseList.contains("mappings:"));
assertTrue(
responseList.contains(
"mappings={year={full_name=year, mapping={year={type=text}}}, age={full_name=age, mapping={age={type=integer}}}}"
)
responseList
.contains("mappings={year={full_name=year, mapping={year={type=text}}}, age={full_name=age, mapping={age={type=integer}}}}")
);

assertTrue(responseList.contains("settings:"));
Expand Down
Loading