Skip to content

Commit 149880a

Browse files
committed
spotless
Signed-off-by: Pavan Yekbote <[email protected]>
1 parent 1bbb717 commit 149880a

File tree

6 files changed

+44
-38
lines changed

6 files changed

+44
-38
lines changed

ml-algorithms/src/main/java/org/opensearch/ml/engine/tools/IndexMappingTool.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public class IndexMappingTool implements Tool {
4747
"The mappings are in JSON format under the key 'properties' which includes the field name as a key and a JSON object with field type under the key 'type'.",
4848
"The settings are in flattened map with 'index' as the top element and key-value pairs for each setting."
4949
);
50-
public static final String DEFAULT_INPUT_SCHEMA = "{\"type\":\"object\",\"" +
51-
"properties\":{\"index\":{\"type\":\"array\",\"description\":\"OpenSearch index name list, separated by comma. " +
52-
"for example: [\\\"index1\\\", \\\"index2\\\"]\"," +
53-
"\"items\":{\"type\":\"string\"}}}," +
54-
"\"required\":[\"index\"]," +
55-
"\"additionalProperties\":false}";
50+
public static final String DEFAULT_INPUT_SCHEMA = "{\"type\":\"object\",\""
51+
+ "properties\":{\"index\":{\"type\":\"array\",\"description\":\"OpenSearch index name list, separated by comma. "
52+
+ "for example: [\\\"index1\\\", \\\"index2\\\"]\","
53+
+ "\"items\":{\"type\":\"string\"}}},"
54+
+ "\"required\":[\"index\"],"
55+
+ "\"additionalProperties\":false}";
5656

5757
@Setter
5858
@Getter
@@ -76,8 +76,7 @@ public IndexMappingTool(Client client) {
7676
this.client = client;
7777

7878
this.attributes = new HashMap<>();
79-
attributes
80-
.put(INPUT_SCHEMA_FIELD, DEFAULT_INPUT_SCHEMA);
79+
attributes.put(INPUT_SCHEMA_FIELD, DEFAULT_INPUT_SCHEMA);
8180
attributes.put(STRICT_FIELD, true);
8281

8382
outputParser = new Parser<>() {

ml-algorithms/src/main/java/org/opensearch/ml/engine/tools/ListIndexTool.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ public class ListIndexTool implements Tool {
8080
"and `local` which means whether to return information from the local node only instead of the cluster manager node (default is false).",
8181
"The tool returns the indices information, including `health`, `status`, `index`, `uuid`, `pri`, `rep`, `docs.count`, `docs.deleted`, `store.size`, `pri.store. size `, `pri.store.size`, `pri.store`."
8282
);
83-
public static final String DEFAULT_INPUT_SCHEMA = "{\"type\":\"object\"," +
84-
"\"properties\":{\"indices\":{\"type\":\"array\",\"items\": {\"type\": \"string\"}," +
85-
"\"description\":\"OpenSearch index name list, separated by comma. " +
86-
"for example: [\\\"index1\\\", \\\"index2\\\"], use empty array [] to list all indices in the cluster\"}}," +
87-
"\"additionalProperties\":false}";
83+
public static final String DEFAULT_INPUT_SCHEMA = "{\"type\":\"object\","
84+
+ "\"properties\":{\"indices\":{\"type\":\"array\",\"items\": {\"type\": \"string\"},"
85+
+ "\"description\":\"OpenSearch index name list, separated by comma. "
86+
+ "for example: [\\\"index1\\\", \\\"index2\\\"], use empty array [] to list all indices in the cluster\"}},"
87+
+ "\"additionalProperties\":false}";
8888

8989
@Setter
9090
@Getter
@@ -120,8 +120,7 @@ public Object parse(Object o) {
120120
};
121121

122122
this.attributes = new HashMap<>();
123-
attributes
124-
.put(INPUT_SCHEMA_FIELD, DEFAULT_INPUT_SCHEMA);
123+
attributes.put(INPUT_SCHEMA_FIELD, DEFAULT_INPUT_SCHEMA);
125124
attributes.put(STRICT_FIELD, false);
126125
}
127126

ml-algorithms/src/main/java/org/opensearch/ml/engine/tools/SearchIndexTool.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public class SearchIndexTool implements Tool {
5555
private static final String DEFAULT_DESCRIPTION =
5656
"Use this tool to search an index by providing two parameters: 'index' for the index name, and 'query' for the OpenSearch DSL formatted query. Only use this tool when both index name and DSL query is available.";
5757

58-
public static final String DEFAULT_INPUT_SCHEMA = "{\"type\":\"object\"," +
59-
"\"properties\":{\"index\":{\"type\":\"string\",\"description\":\"OpenSearch index name. for example: index1\"}," +
60-
"\"query\":{\"type\":\"object\",\"description\":\"OpenSearch search index query. You need to get index mapping to write correct search query. It must be a valid OpenSearch query." +
61-
" Valid value:\\n{\\\"query\\\":{\\\"match\\\":{\\\"population_description\\\":\\\"seattle 2023 population\\\"}},\\\"size\\\":2,\\\"_source\\\":\\\"population_description\\\"}\\n" +
62-
"Invalid value: \\n{\\\"match\\\":{\\\"population_description\\\":\\\"seattle 2023 population\\\"}}\\nThe value is invalid because the match not wrapped by \\\"query\\\".\"," +
63-
"\"additionalProperties\":false}},\"required\":[\"index\",\"query\"],\"additionalProperties\":false}";
58+
public static final String DEFAULT_INPUT_SCHEMA = "{\"type\":\"object\","
59+
+ "\"properties\":{\"index\":{\"type\":\"string\",\"description\":\"OpenSearch index name. for example: index1\"},"
60+
+ "\"query\":{\"type\":\"object\",\"description\":\"OpenSearch search index query. You need to get index mapping to write correct search query. It must be a valid OpenSearch query."
61+
+ " Valid value:\\n{\\\"query\\\":{\\\"match\\\":{\\\"population_description\\\":\\\"seattle 2023 population\\\"}},\\\"size\\\":2,\\\"_source\\\":\\\"population_description\\\"}\\n"
62+
+ "Invalid value: \\n{\\\"match\\\":{\\\"population_description\\\":\\\"seattle 2023 population\\\"}}\\nThe value is invalid because the match not wrapped by \\\"query\\\".\","
63+
+ "\"additionalProperties\":false}},\"required\":[\"index\",\"query\"],\"additionalProperties\":false}";
6464

6565
private String name = TYPE;
6666
private Map<String, Object> attributes;

ml-algorithms/src/test/java/org/opensearch/ml/engine/tools/IndexMappingToolTests.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,13 @@ public void testTool() {
193193
@Test
194194
public void test_getDefaultAttributes() {
195195
Map<String, Object> attributes = IndexMappingTool.Factory.getInstance().create(Collections.emptyMap()).getAttributes();
196-
assertEquals("{\"type\":\"object\",\"properties\":{\"index\":{\"type\":\"array\"," +
197-
"\"description\":\"OpenSearch index name list, separated by comma. " +
198-
"for example: [\\\"index1\\\", \\\"index2\\\"]\",\"items\":{\"type\":\"string\"}}},\"required\":[\"index\"]," +
199-
"\"additionalProperties\":false}", attributes.get(INPUT_SCHEMA_FIELD));
196+
assertEquals(
197+
"{\"type\":\"object\",\"properties\":{\"index\":{\"type\":\"array\","
198+
+ "\"description\":\"OpenSearch index name list, separated by comma. "
199+
+ "for example: [\\\"index1\\\", \\\"index2\\\"]\",\"items\":{\"type\":\"string\"}}},\"required\":[\"index\"],"
200+
+ "\"additionalProperties\":false}",
201+
attributes.get(INPUT_SCHEMA_FIELD)
202+
);
200203
assertEquals(true, attributes.get(STRICT_FIELD));
201204
}
202205
}

ml-algorithms/src/test/java/org/opensearch/ml/engine/tools/ListIndexToolTests.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import java.util.Iterator;
1717
import java.util.Map;
1818

19-
import lombok.SneakyThrows;
2019
import org.junit.Before;
2120
import org.junit.Test;
2221
import org.mockito.ArgumentCaptor;
@@ -108,11 +107,14 @@ public void test_getType() {
108107
@Test
109108
public void test_getDefaultAttributes() {
110109
Map<String, Object> attributes = ListIndexTool.Factory.getInstance().create(Collections.emptyMap()).getAttributes();
111-
assertEquals("{\"type\":\"object\",\"properties\":" +
112-
"{\"indices\":{\"type\":\"array\",\"items\": {\"type\": \"string\"}," +
113-
"\"description\":\"OpenSearch index name list, separated by comma. " +
114-
"for example: [\\\"index1\\\", \\\"index2\\\"], use empty array [] to list all indices in the cluster\"}}," +
115-
"\"additionalProperties\":false}", attributes.get(INPUT_SCHEMA_FIELD));
110+
assertEquals(
111+
"{\"type\":\"object\",\"properties\":"
112+
+ "{\"indices\":{\"type\":\"array\",\"items\": {\"type\": \"string\"},"
113+
+ "\"description\":\"OpenSearch index name list, separated by comma. "
114+
+ "for example: [\\\"index1\\\", \\\"index2\\\"], use empty array [] to list all indices in the cluster\"}},"
115+
+ "\"additionalProperties\":false}",
116+
attributes.get(INPUT_SCHEMA_FIELD)
117+
);
116118
assertEquals(false, attributes.get(STRICT_FIELD));
117119
}
118120

ml-algorithms/src/test/java/org/opensearch/ml/engine/tools/SearchIndexToolTests.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,16 @@ public void testGetType() {
8080
@SneakyThrows
8181
public void testDefaultAttributes() {
8282
Map<String, Object> attributes = mockedSearchIndexTool.getAttributes();
83-
assertEquals("{\"type\":\"object\",\"properties\":" +
84-
"{\"index\":{\"type\":\"string\",\"description\":\"OpenSearch index name. for example: index1\"}," +
85-
"\"query\":{\"type\":\"object\",\"description\":\"OpenSearch search index query. " +
86-
"You need to get index mapping to write correct search query. It must be a valid OpenSearch query. " +
87-
"Valid value:\\n{\\\"query\\\":{\\\"match\\\":{\\\"population_description\\\":\\\"seattle 2023 population\\\"}},\\\"size\\\":2,\\\"_source\\\":\\\"population_description\\\"}" +
88-
"\\nInvalid value: \\n{\\\"match\\\":{\\\"population_description\\\":\\\"seattle 2023 population\\\"}}\\nThe value is invalid because the match not wrapped by \\\"query\\\".\"," +
89-
"\"additionalProperties\":false}},\"required\":[\"index\",\"query\"],\"additionalProperties\":false}", attributes.get(INPUT_SCHEMA_FIELD));
83+
assertEquals(
84+
"{\"type\":\"object\",\"properties\":"
85+
+ "{\"index\":{\"type\":\"string\",\"description\":\"OpenSearch index name. for example: index1\"},"
86+
+ "\"query\":{\"type\":\"object\",\"description\":\"OpenSearch search index query. "
87+
+ "You need to get index mapping to write correct search query. It must be a valid OpenSearch query. "
88+
+ "Valid value:\\n{\\\"query\\\":{\\\"match\\\":{\\\"population_description\\\":\\\"seattle 2023 population\\\"}},\\\"size\\\":2,\\\"_source\\\":\\\"population_description\\\"}"
89+
+ "\\nInvalid value: \\n{\\\"match\\\":{\\\"population_description\\\":\\\"seattle 2023 population\\\"}}\\nThe value is invalid because the match not wrapped by \\\"query\\\".\","
90+
+ "\"additionalProperties\":false}},\"required\":[\"index\",\"query\"],\"additionalProperties\":false}",
91+
attributes.get(INPUT_SCHEMA_FIELD)
92+
);
9093
assertEquals(false, attributes.get(STRICT_FIELD));
9194
}
9295

0 commit comments

Comments
 (0)