|
13 | 13 | import org.elasticsearch.client.ResponseException; |
14 | 14 | import org.elasticsearch.common.settings.Settings; |
15 | 15 | import org.elasticsearch.inference.TaskType; |
16 | | -import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceFeature; |
17 | 16 |
|
18 | 17 | import java.io.IOException; |
19 | | -import java.util.ArrayList; |
20 | | -import java.util.Arrays; |
21 | 18 | import java.util.List; |
22 | 19 | import java.util.Map; |
23 | 20 | import java.util.Objects; |
@@ -131,153 +128,6 @@ public void testApisWithoutTaskType() throws IOException { |
131 | 128 | deleteModel(modelId); |
132 | 129 | } |
133 | 130 |
|
134 | | - @SuppressWarnings("unchecked") |
135 | | - public void testGetServicesWithoutTaskType() throws IOException { |
136 | | - List<Object> services = getAllServices(); |
137 | | - if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) { |
138 | | - assertThat(services.size(), equalTo(18)); |
139 | | - } else { |
140 | | - assertThat(services.size(), equalTo(17)); |
141 | | - } |
142 | | - |
143 | | - String[] providers = new String[services.size()]; |
144 | | - for (int i = 0; i < services.size(); i++) { |
145 | | - Map<String, Object> serviceConfig = (Map<String, Object>) services.get(i); |
146 | | - providers[i] = (String) serviceConfig.get("provider"); |
147 | | - } |
148 | | - |
149 | | - Arrays.sort(providers); |
150 | | - |
151 | | - var providerList = new ArrayList<>( |
152 | | - Arrays.asList( |
153 | | - "alibabacloud-ai-search", |
154 | | - "amazonbedrock", |
155 | | - "anthropic", |
156 | | - "azureaistudio", |
157 | | - "azureopenai", |
158 | | - "cohere", |
159 | | - "elasticsearch", |
160 | | - "googleaistudio", |
161 | | - "googlevertexai", |
162 | | - "hugging_face", |
163 | | - "mistral", |
164 | | - "openai", |
165 | | - "streaming_completion_test_service", |
166 | | - "test_reranking_service", |
167 | | - "test_service", |
168 | | - "text_embedding_test_service", |
169 | | - "watsonxai" |
170 | | - ) |
171 | | - ); |
172 | | - if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) { |
173 | | - providerList.add(6, "elastic"); |
174 | | - } |
175 | | - assertArrayEquals(providers, providerList.toArray()); |
176 | | - } |
177 | | - |
178 | | - @SuppressWarnings("unchecked") |
179 | | - public void testGetServicesWithTextEmbeddingTaskType() throws IOException { |
180 | | - List<Object> services = getServices(TaskType.TEXT_EMBEDDING); |
181 | | - assertThat(services.size(), equalTo(13)); |
182 | | - |
183 | | - String[] providers = new String[services.size()]; |
184 | | - for (int i = 0; i < services.size(); i++) { |
185 | | - Map<String, Object> serviceConfig = (Map<String, Object>) services.get(i); |
186 | | - providers[i] = (String) serviceConfig.get("provider"); |
187 | | - } |
188 | | - |
189 | | - Arrays.sort(providers); |
190 | | - assertArrayEquals( |
191 | | - providers, |
192 | | - List.of( |
193 | | - "alibabacloud-ai-search", |
194 | | - "amazonbedrock", |
195 | | - "azureaistudio", |
196 | | - "azureopenai", |
197 | | - "cohere", |
198 | | - "elasticsearch", |
199 | | - "googleaistudio", |
200 | | - "googlevertexai", |
201 | | - "hugging_face", |
202 | | - "mistral", |
203 | | - "openai", |
204 | | - "text_embedding_test_service", |
205 | | - "watsonxai" |
206 | | - ).toArray() |
207 | | - ); |
208 | | - } |
209 | | - |
210 | | - @SuppressWarnings("unchecked") |
211 | | - public void testGetServicesWithRerankTaskType() throws IOException { |
212 | | - List<Object> services = getServices(TaskType.RERANK); |
213 | | - assertThat(services.size(), equalTo(5)); |
214 | | - |
215 | | - String[] providers = new String[services.size()]; |
216 | | - for (int i = 0; i < services.size(); i++) { |
217 | | - Map<String, Object> serviceConfig = (Map<String, Object>) services.get(i); |
218 | | - providers[i] = (String) serviceConfig.get("provider"); |
219 | | - } |
220 | | - |
221 | | - Arrays.sort(providers); |
222 | | - assertArrayEquals( |
223 | | - providers, |
224 | | - List.of("alibabacloud-ai-search", "cohere", "elasticsearch", "googlevertexai", "test_reranking_service").toArray() |
225 | | - ); |
226 | | - } |
227 | | - |
228 | | - @SuppressWarnings("unchecked") |
229 | | - public void testGetServicesWithCompletionTaskType() throws IOException { |
230 | | - List<Object> services = getServices(TaskType.COMPLETION); |
231 | | - assertThat(services.size(), equalTo(9)); |
232 | | - |
233 | | - String[] providers = new String[services.size()]; |
234 | | - for (int i = 0; i < services.size(); i++) { |
235 | | - Map<String, Object> serviceConfig = (Map<String, Object>) services.get(i); |
236 | | - providers[i] = (String) serviceConfig.get("provider"); |
237 | | - } |
238 | | - |
239 | | - Arrays.sort(providers); |
240 | | - assertArrayEquals( |
241 | | - providers, |
242 | | - List.of( |
243 | | - "alibabacloud-ai-search", |
244 | | - "amazonbedrock", |
245 | | - "anthropic", |
246 | | - "azureaistudio", |
247 | | - "azureopenai", |
248 | | - "cohere", |
249 | | - "googleaistudio", |
250 | | - "openai", |
251 | | - "streaming_completion_test_service" |
252 | | - ).toArray() |
253 | | - ); |
254 | | - } |
255 | | - |
256 | | - @SuppressWarnings("unchecked") |
257 | | - public void testGetServicesWithSparseEmbeddingTaskType() throws IOException { |
258 | | - List<Object> services = getServices(TaskType.SPARSE_EMBEDDING); |
259 | | - |
260 | | - if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) { |
261 | | - assertThat(services.size(), equalTo(5)); |
262 | | - } else { |
263 | | - assertThat(services.size(), equalTo(4)); |
264 | | - } |
265 | | - |
266 | | - String[] providers = new String[services.size()]; |
267 | | - for (int i = 0; i < services.size(); i++) { |
268 | | - Map<String, Object> serviceConfig = (Map<String, Object>) services.get(i); |
269 | | - providers[i] = (String) serviceConfig.get("provider"); |
270 | | - } |
271 | | - |
272 | | - Arrays.sort(providers); |
273 | | - |
274 | | - var providerList = new ArrayList<>(Arrays.asList("alibabacloud-ai-search", "elasticsearch", "hugging_face", "test_service")); |
275 | | - if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) { |
276 | | - providerList.add(1, "elastic"); |
277 | | - } |
278 | | - assertArrayEquals(providers, providerList.toArray()); |
279 | | - } |
280 | | - |
281 | 131 | public void testSkipValidationAndStart() throws IOException { |
282 | 132 | String openAiConfigWithBadApiKey = """ |
283 | 133 | { |
|
0 commit comments