Skip to content

Commit 9252146

Browse files
committed
Remove hardcoded test schema
Signed-off-by: b4sjoo <sicheng.song@outlook.com>
1 parent 9ff2d5d commit 9252146

File tree

1 file changed

+12
-105
lines changed

1 file changed

+12
-105
lines changed

plugin/src/test/java/org/opensearch/ml/utils/MLNodeUtilsTests.java

+12-105
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
package org.opensearch.ml.utils;
77

88
import static java.util.Collections.emptyMap;
9+
import static org.opensearch.ml.common.utils.ModelInterfaceUtils.BEDROCK_COHERE_EMBED_ENGLISH_V3_MODEL_INTERFACE;
10+
import static org.opensearch.ml.common.utils.ModelInterfaceUtils.BEDROCK_TITAN_EMBED_MULTI_MODAL_V1_MODEL_INTERFACE;
11+
import static org.opensearch.ml.common.utils.ModelInterfaceUtils.BEDROCK_TITAN_EMBED_TEXT_V1_MODEL_INTERFACE;
912
import static org.opensearch.ml.utils.TestHelper.ML_ROLE;
1013

1114
import java.io.IOException;
@@ -68,139 +71,43 @@ public void testValidateSchema() throws IOException {
6871

6972
@Test
7073
public void testValidateEmbeddingInputWithGeneralEmbeddingRemoteSchema() throws IOException {
71-
String schema = "{\n"
72-
+ " \"type\": \"object\",\n"
73-
+ " \"properties\": {\n"
74-
+ " \"parameters\": {\n"
75-
+ " \"type\": \"object\",\n"
76-
+ " \"properties\": {\n"
77-
+ " \"texts\": {\n"
78-
+ " \"type\": \"array\",\n"
79-
+ " \"items\": {\n"
80-
+ " \"type\": \"string\"\n"
81-
+ " }\n"
82-
+ " }\n"
83-
+ " },\n"
84-
+ " \"required\": [\n"
85-
+ " \"texts\"\n"
86-
+ " ]\n"
87-
+ " }\n"
88-
+ " }\n"
89-
+ "}";
74+
String schema = BEDROCK_COHERE_EMBED_ENGLISH_V3_MODEL_INTERFACE.get("input");
9075
String json = "{\"text_docs\":[ \"today is sunny\", \"today is sunny\"]}";
9176
MLNodeUtils.validateSchema(schema, json);
9277
}
9378

9479
@Test
9580
public void testValidateRemoteInputWithGeneralEmbeddingRemoteSchema() throws IOException {
96-
String schema = "{\n"
97-
+ " \"type\": \"object\",\n"
98-
+ " \"properties\": {\n"
99-
+ " \"parameters\": {\n"
100-
+ " \"type\": \"object\",\n"
101-
+ " \"properties\": {\n"
102-
+ " \"texts\": {\n"
103-
+ " \"type\": \"array\",\n"
104-
+ " \"items\": {\n"
105-
+ " \"type\": \"string\"\n"
106-
+ " }\n"
107-
+ " }\n"
108-
+ " },\n"
109-
+ " \"required\": [\n"
110-
+ " \"texts\"\n"
111-
+ " ]\n"
112-
+ " }\n"
113-
+ " }\n"
114-
+ "}";
81+
String schema = BEDROCK_COHERE_EMBED_ENGLISH_V3_MODEL_INTERFACE.get("input");
11582
String json = "{\"parameters\": {\"texts\": [\"Hello\",\"world\"]}}";
11683
MLNodeUtils.validateSchema(schema, json);
11784
}
11885

11986
@Test
12087
public void testValidateEmbeddingInputWithTitanTextRemoteSchema() throws IOException {
121-
String schema = "{\n"
122-
+ " \"type\": \"object\",\n"
123-
+ " \"properties\": {\n"
124-
+ " \"parameters\": {\n"
125-
+ " \"type\": \"object\",\n"
126-
+ " \"properties\": {\n"
127-
+ " \"inputText\": {\n"
128-
+ " \"type\": \"string\"\n"
129-
+ " }\n"
130-
+ " },\n"
131-
+ " \"required\": [\n"
132-
+ " \"inputText\"\n"
133-
+ " ]\n"
134-
+ " }\n"
135-
+ " }\n"
136-
+ "}";
88+
String schema = BEDROCK_TITAN_EMBED_TEXT_V1_MODEL_INTERFACE.get("input");
13789
String json = "{\"text_docs\":[ \"today is sunny\", \"today is sunny\"]}";
13890
MLNodeUtils.validateSchema(schema, json);
13991
}
14092

14193
@Test
14294
public void testValidateRemoteInputWithTitanTextRemoteSchema() throws IOException {
143-
String schema = "{\n"
144-
+ " \"type\": \"object\",\n"
145-
+ " \"properties\": {\n"
146-
+ " \"parameters\": {\n"
147-
+ " \"type\": \"object\",\n"
148-
+ " \"properties\": {\n"
149-
+ " \"inputText\": {\n"
150-
+ " \"type\": \"string\"\n"
151-
+ " }\n"
152-
+ " },\n"
153-
+ " \"required\": [\n"
154-
+ " \"inputText\"\n"
155-
+ " ]\n"
156-
+ " }\n"
157-
+ " }\n"
158-
+ "}";
95+
String schema = BEDROCK_TITAN_EMBED_TEXT_V1_MODEL_INTERFACE.get("input");
15996
String json = "{\"parameters\": {\"inputText\": \"Say this is a test\"}}";
16097
MLNodeUtils.validateSchema(schema, json);
16198
}
16299

163100
@Test
164-
public void testValidateEmbeddingInputWithTitanImageRemoteSchema() throws IOException {
165-
String schema = "{\n"
166-
+ " \"type\": \"object\",\n"
167-
+ " \"properties\": {\n"
168-
+ " \"parameters\": {\n"
169-
+ " \"type\": \"object\",\n"
170-
+ " \"properties\": {\n"
171-
+ " \"inputText\": {\n"
172-
+ " \"type\": \"string\"\n"
173-
+ " },\n"
174-
+ " \"inputImage\": {\n"
175-
+ " \"type\": \"string\"\n"
176-
+ " }\n"
177-
+ " }\n"
178-
+ " }\n"
179-
+ " }\n"
180-
+ "}";
101+
public void testValidateEmbeddingInputWithTitanMultiModalRemoteSchema() throws IOException {
102+
String schema = BEDROCK_TITAN_EMBED_MULTI_MODAL_V1_MODEL_INTERFACE.get("input");
181103
String json = "{\"text_docs\":[ \"today is sunny\", \"today is sunny\"]}";
182104
MLNodeUtils.validateSchema(schema, json);
183105
}
184106

185107
@Test
186-
public void testValidateRemoteInputWithTitanImageRemoteSchema() throws IOException {
187-
String schema = "{\n"
188-
+ " \"type\": \"object\",\n"
189-
+ " \"properties\": {\n"
190-
+ " \"parameters\": {\n"
191-
+ " \"type\": \"object\",\n"
192-
+ " \"properties\": {\n"
193-
+ " \"inputText\": {\n"
194-
+ " \"type\": \"string\"\n"
195-
+ " },\n"
196-
+ " \"inputImage\": {\n"
197-
+ " \"type\": \"string\"\n"
198-
+ " }\n"
199-
+ " }\n"
200-
+ " }\n"
201-
+ " }\n"
202-
+ "}";
203-
String json = "{{\n"
108+
public void testValidateRemoteInputWithTitanMultiModalRemoteSchema() throws IOException {
109+
String schema = BEDROCK_TITAN_EMBED_MULTI_MODAL_V1_MODEL_INTERFACE.get("input");
110+
String json = "{\n"
204111
+ " \"parameters\": {\n"
205112
+ " \"inputText\": \"Say this is a test\",\n"
206113
+ " \"inputImage\": \"/9jk=\"\n"

0 commit comments

Comments
 (0)