|
6 | 6 | package org.opensearch.ml.utils;
|
7 | 7 |
|
8 | 8 | 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; |
9 | 12 | import static org.opensearch.ml.utils.TestHelper.ML_ROLE;
|
10 | 13 |
|
11 | 14 | import java.io.IOException;
|
@@ -68,139 +71,43 @@ public void testValidateSchema() throws IOException {
|
68 | 71 |
|
69 | 72 | @Test
|
70 | 73 | 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"); |
90 | 75 | String json = "{\"text_docs\":[ \"today is sunny\", \"today is sunny\"]}";
|
91 | 76 | MLNodeUtils.validateSchema(schema, json);
|
92 | 77 | }
|
93 | 78 |
|
94 | 79 | @Test
|
95 | 80 | 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"); |
115 | 82 | String json = "{\"parameters\": {\"texts\": [\"Hello\",\"world\"]}}";
|
116 | 83 | MLNodeUtils.validateSchema(schema, json);
|
117 | 84 | }
|
118 | 85 |
|
119 | 86 | @Test
|
120 | 87 | 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"); |
137 | 89 | String json = "{\"text_docs\":[ \"today is sunny\", \"today is sunny\"]}";
|
138 | 90 | MLNodeUtils.validateSchema(schema, json);
|
139 | 91 | }
|
140 | 92 |
|
141 | 93 | @Test
|
142 | 94 | 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"); |
159 | 96 | String json = "{\"parameters\": {\"inputText\": \"Say this is a test\"}}";
|
160 | 97 | MLNodeUtils.validateSchema(schema, json);
|
161 | 98 | }
|
162 | 99 |
|
163 | 100 | @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"); |
181 | 103 | String json = "{\"text_docs\":[ \"today is sunny\", \"today is sunny\"]}";
|
182 | 104 | MLNodeUtils.validateSchema(schema, json);
|
183 | 105 | }
|
184 | 106 |
|
185 | 107 | @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" |
204 | 111 | + " \"parameters\": {\n"
|
205 | 112 | + " \"inputText\": \"Say this is a test\",\n"
|
206 | 113 | + " \"inputImage\": \"/9jk=\"\n"
|
|
0 commit comments