diff --git a/docs/changelog/114176.yaml b/docs/changelog/114176.yaml new file mode 100644 index 0000000000000..9b8fac91d403d --- /dev/null +++ b/docs/changelog/114176.yaml @@ -0,0 +1,10 @@ +pr: 114176 +summary: "[Inference API] Deprecate task_settings, renamed to parameters" +area: Machine Learning +type: deprecation +issues: [] +deprecation: + title: "[Inference API] Deprecate task_settings, renamed to parameters" + area: REST API + details: In 8.16 the inference API is renaming the `task_settings` component of inference endpoints (used in the Create _inference API, and GET _inference API) to `parameters`. Users are asked to update any code accessing or creating `task_settings` to use `parameters` instead. Support for requests and responses including `task_settings` will be removed in 9.0. + impact: The inference API is maintaing backwards compatibility until 9.0, but we now recommend replacing usages of `task_settings` with `parameters`. diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index 2095ba47ee377..1402bc7e8244e 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -237,6 +237,7 @@ static TransportVersion def(int id) { public static final TransportVersion DATE_TIME_DOC_VALUES_LOCALES = def(8_761_00_0); public static final TransportVersion FAST_REFRESH_RCO = def(8_762_00_0); public static final TransportVersion TEXT_SIMILARITY_RERANKER_QUERY_REWRITE = def(8_763_00_0); + public static final TransportVersion INFERENCE_API_PARAMATERS_INTRODUCED = def(8_764_00_0); /* * STOP! READ THIS FIRST! No, really, diff --git a/server/src/main/java/org/elasticsearch/inference/InferenceService.java b/server/src/main/java/org/elasticsearch/inference/InferenceService.java index cbbfef2cc65fa..f3a2baf06c102 100644 --- a/server/src/main/java/org/elasticsearch/inference/InferenceService.java +++ b/server/src/main/java/org/elasticsearch/inference/InferenceService.java @@ -36,10 +36,10 @@ default void init(Client client) {} * If the map contains unrecognized configuration option an * {@code ElasticsearchStatusException} is thrown. * - * @param modelId Model Id - * @param taskType The model task type - * @param config Configuration options including the secrets - * @param parsedModelListener A listener which will handle the resulting model or failure + * @param modelId Model Id + * @param taskType The model task type + * @param config Configuration options including the secrets + * @param parsedModelListener A listener which will handle the resulting model or failure */ void parseRequestConfig(String modelId, TaskType taskType, Map config, ActionListener parsedModelListener); @@ -47,13 +47,13 @@ default void init(Client client) {} * Parse model configuration from {@code config map} from persisted storage and return the parsed {@link Model}. This requires that * secrets and service settings be in two separate maps. * This function modifies {@code config map}, fields are removed from the map as they are read. - * + *

* If the map contains unrecognized configuration options, no error is thrown. * - * @param modelId Model Id - * @param taskType The model task type - * @param config Configuration options - * @param secrets Sensitive configuration options (e.g. api key) + * @param modelId Model Id + * @param taskType The model task type + * @param config Configuration options + * @param secrets Sensitive configuration options (e.g. api key) * @return The parsed {@link Model} */ Model parsePersistedConfigWithSecrets(String modelId, TaskType taskType, Map config, Map secrets); @@ -61,12 +61,12 @@ default void init(Client client) {} /** * Parse model configuration from {@code config map} from persisted storage and return the parsed {@link Model}. * This function modifies {@code config map}, fields are removed from the map as they are read. - * + *

* If the map contains unrecognized configuration options, no error is thrown. * - * @param modelId Model Id - * @param taskType The model task type - * @param config Configuration options + * @param modelId Model Id + * @param taskType The model task type + * @param config Configuration options * @return The parsed {@link Model} */ Model parsePersistedConfig(String modelId, TaskType taskType, Map config); diff --git a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java index 9f7a247d00a3a..d59bc1b3f79bc 100644 --- a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java +++ b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java @@ -25,10 +25,11 @@ public class ModelConfigurations implements ToFilteredXContentObject, VersionedN // is returned as part of a GetInferenceModelAction public static final String INDEX_ONLY_ID_FIELD_NAME = "model_id"; public static final String INFERENCE_ID_FIELD_NAME = "inference_id"; - public static final String USE_ID_FOR_INDEX = "for_index"; + public static final String FOR_INDEX = "for_index"; // true if writing to index public static final String SERVICE = "service"; public static final String SERVICE_SETTINGS = "service_settings"; public static final String TASK_SETTINGS = "task_settings"; + public static final String PARAMETERS = "parameters"; public static final String CHUNKING_SETTINGS = "chunking_settings"; private static final String NAME = "inference_model"; @@ -165,7 +166,7 @@ public ChunkingSettings getChunkingSettings() { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - if (params.paramAsBoolean(USE_ID_FOR_INDEX, false)) { + if (params.paramAsBoolean(FOR_INDEX, false)) { builder.field(INDEX_ONLY_ID_FIELD_NAME, inferenceEntityId); } else { builder.field(INFERENCE_ID_FIELD_NAME, inferenceEntityId); @@ -177,6 +178,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } + if (params.paramAsBoolean(FOR_INDEX, false)) { + // Don't write parameter to index, but do write parameters the rest of the time + } else { + builder.field(PARAMETERS, taskSettings); + } builder.endObject(); return builder; } @@ -184,7 +190,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - if (params.paramAsBoolean(USE_ID_FOR_INDEX, false)) { + if (params.paramAsBoolean(FOR_INDEX, false)) { builder.field(INDEX_ONLY_ID_FIELD_NAME, inferenceEntityId); } else { builder.field(INFERENCE_ID_FIELD_NAME, inferenceEntityId); @@ -196,6 +202,11 @@ public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } + if (params.paramAsBoolean(FOR_INDEX, false)) { + // Don't write parameter to index, but do write parameters the rest of the time + } else { + builder.field(PARAMETERS, taskSettings); + } builder.endObject(); return builder; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/action/PutInferenceModelAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/action/PutInferenceModelAction.java index 3768de9b4debe..9978bbfd59eba 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/action/PutInferenceModelAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/action/PutInferenceModelAction.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.core.inference.action; +import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; @@ -14,22 +15,31 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; +import org.elasticsearch.rest.RestStatus; import org.elasticsearch.xcontent.ToXContentObject; import org.elasticsearch.xcontent.XContentBuilder; +import org.elasticsearch.xcontent.XContentFactory; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.core.ml.job.messages.Messages; import org.elasticsearch.xpack.core.ml.utils.MlStrings; import java.io.IOException; +import java.util.Map; import java.util.Objects; +import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; +import static org.elasticsearch.inference.ModelConfigurations.TASK_SETTINGS; + public class PutInferenceModelAction extends ActionType { public static final PutInferenceModelAction INSTANCE = new PutInferenceModelAction(); public static final String NAME = "cluster:admin/xpack/inference/put"; + private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(PutInferenceModelAction.class); public PutInferenceModelAction() { super(NAME); @@ -40,6 +50,7 @@ public static class Request extends AcknowledgedRequest { private final TaskType taskType; private final String inferenceEntityId; private final BytesReference content; + private BytesReference rewrittenContent; private final XContentType contentType; public Request(TaskType taskType, String inferenceEntityId, BytesReference content, XContentType contentType) { @@ -70,6 +81,36 @@ public BytesReference getContent() { return content; } + public BytesReference getRewrittenContent() { + if (rewrittenContent == null) { // rewrittenContent is deterministic on content, so we only need to calculate it once + Map newContent = XContentHelper.convertToMap(content, false, contentType).v2(); + if (newContent.containsKey(PARAMETERS) && newContent.containsKey(TASK_SETTINGS)) { + throw new ElasticsearchStatusException( + "Request cannot contain both [task_settings] and [parameters], use only [parameters]", + RestStatus.BAD_REQUEST + ); + } else if (newContent.containsKey(TASK_SETTINGS)) { + DEPRECATION_LOGGER.critical( + DeprecationCategory.API, + "inference_api_task_settings_deprecated_use_parameters", + "The [task_settings] field is deprecated and will be removed in a future release. " + + "Please use only the [parameters] field instead." + ); + } else if (newContent.containsKey(PARAMETERS)) { + newContent.put(TASK_SETTINGS, newContent.get(PARAMETERS)); + newContent.remove(PARAMETERS); + } + + try (XContentBuilder builder = XContentFactory.contentBuilder(this.contentType)) { + builder.map(newContent); + this.rewrittenContent = BytesReference.bytes(builder); + } catch (IOException e) { + throw new ElasticsearchStatusException("Failed to parse rewritten request", RestStatus.INTERNAL_SERVER_ERROR, e); + } + } + return rewrittenContent; + } + public XContentType getContentType() { return contentType; } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/inference/action/PutInferenceModelActionTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/inference/action/PutInferenceModelActionTests.java index e0b04c6fe8769..bc2eba83e391e 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/inference/action/PutInferenceModelActionTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/inference/action/PutInferenceModelActionTests.java @@ -7,16 +7,25 @@ package org.elasticsearch.xpack.core.inference.action; +import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.xcontent.XContentBuilder; +import org.elasticsearch.xcontent.XContentFactory; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.core.ml.utils.MlStringsTests; import org.junit.Before; +import java.io.IOException; import java.util.Locale; +import java.util.Map; + +import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; +import static org.elasticsearch.inference.ModelConfigurations.TASK_SETTINGS; public class PutInferenceModelActionTests extends ESTestCase { public static TaskType TASK_TYPE; @@ -57,4 +66,55 @@ public void testValidate() { validationException = invalidRequest3.validate(); assertNotNull(validationException); } + + public void testWithParameters() throws IOException { + XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + Map parametersValues = Map.of("top_n", 1, "top_p", 0.1); + Map serviceSettingsValues = Map.of("model_id", "embed", "dimensions", 1024); + builder.map(Map.of(PARAMETERS, parametersValues, "service", "elasticsearch", "service_settings", serviceSettingsValues)); + var request = new PutInferenceModelAction.Request(TASK_TYPE, MODEL_ID, BytesReference.bytes(builder), XContentType.JSON); + Map map = XContentHelper.convertToMap(request.getRewrittenContent(), false, request.getContentType()).v2(); + assertEquals(parametersValues, map.get(TASK_SETTINGS)); + assertNull(map.get(PARAMETERS)); + assertEquals("elasticsearch", map.get("service")); + assertEquals(serviceSettingsValues, map.get("service_settings")); + } + + public void testWithParametersAndTaskSettings() throws IOException { + XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + Map parametersValues = Map.of("top_n", 1, "top_p", 0.1); + Map taskSettingsValues = Map.of("top_n", 2, "top_p", 0.2); + Map serviceSettingsValues = Map.of("model_id", "embed", "dimensions", 1024); + builder.map( + Map.of( + PARAMETERS, + parametersValues, + TASK_SETTINGS, + taskSettingsValues, + "service", + "elasticsearch", + "service_settings", + serviceSettingsValues + ) + ); + assertThrows( + ElasticsearchStatusException.class, + () -> new PutInferenceModelAction.Request(TASK_TYPE, MODEL_ID, BytesReference.bytes(builder), XContentType.JSON) + .getRewrittenContent() + ); + + } + + public void testWithTaskSettings() throws IOException { + XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + Map taskSettingsValues = Map.of("top_n", 2, "top_p", 0.2); + Map serviceSettingsValues = Map.of("model_id", "embed", "dimensions", 1024); + builder.map(Map.of(TASK_SETTINGS, taskSettingsValues, "service", "elasticsearch", "service_settings", serviceSettingsValues)); + var request = new PutInferenceModelAction.Request(TASK_TYPE, MODEL_ID, BytesReference.bytes(builder), XContentType.JSON); + Map map = XContentHelper.convertToMap(request.getContent(), false, request.getContentType()).v2(); + assertEquals(taskSettingsValues, map.get(TASK_SETTINGS)); + assertNull(map.get(PARAMETERS)); + assertEquals("elasticsearch", map.get("service")); + assertEquals(serviceSettingsValues, map.get("service_settings")); + } } diff --git a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceBaseRestTest.java b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceBaseRestTest.java index f82b6f155c0a0..e717117eaa1ca 100644 --- a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceBaseRestTest.java +++ b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceBaseRestTest.java @@ -12,6 +12,7 @@ import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseListener; +import org.elasticsearch.client.WarningsHandler; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; @@ -81,6 +82,45 @@ static String mockSparseServiceModelConfig(@Nullable TaskType taskTypeInBody) { """, taskType); } + static String mockSparseServiceModelConfigWithParameters(@Nullable TaskType taskTypeInBody) { + var taskType = taskTypeInBody == null ? "" : "\"task_type\": \"" + taskTypeInBody + "\","; + return Strings.format(""" + { + %s + "service": "test_service", + "service_settings": { + "model": "my_model", + "hidden_field": "my_hidden_value", + "api_key": "abc64" + }, + "parameters": { + "temperature": 3 + } + } + """, taskType); + } + + static String mockSparseServiceModelConfigWithParametersAndTaskSettings(@Nullable TaskType taskTypeInBody) { + var taskType = taskTypeInBody == null ? "" : "\"task_type\": \"" + taskTypeInBody + "\","; + return Strings.format(""" + { + %s + "service": "test_service", + "service_settings": { + "model": "my_model", + "hidden_field": "my_hidden_value", + "api_key": "abc64" + }, + "parameters": { + "temperature": 3 + }, + "task_settings": { + "temperature": 3 + } + } + """, taskType); + } + static String mockCompletionServiceModelConfig(@Nullable TaskType taskTypeInBody) { var taskType = taskTypeInBody == null ? "" : "\"task_type\": \"" + taskTypeInBody + "\","; return Strings.format(""" @@ -230,6 +270,8 @@ protected Map putModel(String modelId, String modelConfig) throw Map putRequest(String endpoint, String body) throws IOException { var request = new Request("PUT", endpoint); request.setJsonEntity(body); + request.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build()); // TODO remove + // permissive warnings once the deprecation warnings are removed in 9.0 var response = client().performRequest(request); assertOkOrCreated(response); return entityAsMap(response); diff --git a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceCrudIT.java b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceCrudIT.java index 5a84fd8985504..7a72e274a735a 100644 --- a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceCrudIT.java +++ b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceCrudIT.java @@ -66,6 +66,49 @@ public void testGet() throws IOException { } } + public void testGetWithParameters() throws IOException { + + putModel("se_model_" + 1, mockSparseServiceModelConfigWithParameters(null), TaskType.SPARSE_EMBEDDING); + + putModel("te_model_" + 1, mockSparseServiceModelConfigWithParameters(null), TaskType.TEXT_EMBEDDING); + + var getAllModels = getAllModels(); + int numModels = 2 + 1; // 2 above + default model + assertThat(getAllModels, hasSize(numModels)); + + var getSparseModels = getModels("_all", TaskType.SPARSE_EMBEDDING); + int numSparseModels = 1 + 1; // 1 above + default model + assertThat(getSparseModels, hasSize(numSparseModels)); + for (var sparseModel : getSparseModels) { + assertEquals("sparse_embedding", sparseModel.get("task_type")); + } + + var getDenseModels = getModels("_all", TaskType.TEXT_EMBEDDING); + assertThat(getDenseModels, hasSize(1)); + for (var denseModel : getDenseModels) { + assertEquals("text_embedding", denseModel.get("task_type")); + } + + var singleModel = getModels("se_model_1", TaskType.SPARSE_EMBEDDING); + assertThat(singleModel, hasSize(1)); + assertEquals("se_model_1", singleModel.get(0).get("inference_id")); + + deleteModel("se_model_" + 1, TaskType.SPARSE_EMBEDDING); + + deleteModel("te_model_" + 1, TaskType.TEXT_EMBEDDING); + } + + public void testGetWithParametersAndTaskSettingsFails() throws IOException { + assertThrows( + ResponseException.class, + () -> putModel("se_model_" + 1, mockSparseServiceModelConfigWithParametersAndTaskSettings(null), TaskType.SPARSE_EMBEDDING) + ); + assertThrows( + ResponseException.class, + () -> putModel("te_model_" + 1, mockSparseServiceModelConfigWithParametersAndTaskSettings(null), TaskType.TEXT_EMBEDDING) + ); + } + public void testGetModelWithWrongTaskType() throws IOException { putModel("sparse_embedding_model", mockSparseServiceModelConfig(), TaskType.SPARSE_EMBEDDING); var e = expectThrows(ResponseException.class, () -> getModels("sparse_embedding_model", TaskType.TEXT_EMBEDDING)); @@ -123,6 +166,7 @@ public void testSkipValidationAndStart() throws IOException { // We would expect an error about the invalid API key if the validation occurred putModel("unvalidated", openAiConfigWithBadApiKey, TaskType.TEXT_EMBEDDING); + deleteModel("unvalidated"); } public void testDeleteEndpointWhileReferencedByPipeline() throws IOException { diff --git a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferencePermissionsIT.java b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferencePermissionsIT.java index cc8096831f598..44a20d859dc44 100644 --- a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferencePermissionsIT.java +++ b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferencePermissionsIT.java @@ -9,9 +9,11 @@ import org.apache.http.HttpHost; import org.elasticsearch.client.Request; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.WarningsHandler; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; @@ -56,11 +58,15 @@ protected Settings restClientSettings() { public void testPermissions() throws IOException { var putRequest = new Request("PUT", "_inference/sparse_embedding/permissions_test"); putRequest.setJsonEntity(InferenceBaseRestTest.mockSparseServiceModelConfig()); + putRequest.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build()); + // TODO remove permissive handling after the deprecation warning for task_settings is removed in 9.0 var getAllRequest = new Request("GET", "_inference/sparse_embedding/_all"); var deleteRequest = new Request("DELETE", "_inference/sparse_embedding/permissions_test"); var putModelForTestingInference = new Request("PUT", "_inference/sparse_embedding/model_to_test_user_priv"); putModelForTestingInference.setJsonEntity(InferenceBaseRestTest.mockSparseServiceModelConfig()); + putModelForTestingInference.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build()); + // TODO remove permissive handling after the deprecation warning for task_settings is removed in 9.0 var inferRequest = new Request("POST", "_inference/sparse_embedding/model_to_test_user_priv"); var bodyBuilder = new StringBuilder("{\"input\": ["); diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/BaseMixedTestCase.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/BaseMixedTestCase.java index 2c47578f466e3..c8a7483cfdcb9 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/BaseMixedTestCase.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/BaseMixedTestCase.java @@ -9,7 +9,9 @@ import org.apache.http.util.EntityUtils; import org.elasticsearch.client.Request; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; +import org.elasticsearch.client.WarningsHandler; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; @@ -105,9 +107,9 @@ protected void put(String inferenceId, String modelConfig, TaskType taskType) th String endpoint = Strings.format("_inference/%s/%s?error_trace", taskType, inferenceId); var request = new Request("PUT", endpoint); request.setJsonEntity(modelConfig); + request.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build()); + // TODO remove permissive handling after the deprecation warning for task_settings is removed in 9.0 var response = ESRestTestCase.client().performRequest(request); - logger.warn("PUT response: {}", response.toString()); - System.out.println("PUT response: " + response.toString()); ESRestTestCase.assertOKAndConsume(response); } diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java index ca1dd5a71ea2f..18c1322e98b89 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java @@ -32,6 +32,7 @@ public class OpenAIServiceMixedIT extends BaseMixedTestCase { private static final String OPEN_AI_EMBEDDINGS_CHUNKING_SETTINGS_ADDED = "8.16.0"; private static final String OPEN_AI_COMPLETIONS_ADDED = "8.14.0"; private static final String MINIMUM_SUPPORTED_VERSION = "8.15.0"; + private static final String ENDPOINT_VERSION_ADDED = "8.16.0"; private static MockWebServer openAiEmbeddingsServer; private static MockWebServer openAiChatCompletionsServer; @@ -115,8 +116,19 @@ public void testOpenAiCompletions() throws IOException { // queue a response as PUT will call the service openAiChatCompletionsServer.enqueue(new MockResponse().setResponseCode(200).setBody(chatCompletionsResponse())); - put(inferenceId, chatCompletionsConfig(getUrl(openAiChatCompletionsServer)), TaskType.COMPLETION); - + try { + put(inferenceId, chatCompletionsConfig(getUrl(openAiChatCompletionsServer)), TaskType.COMPLETION); + } catch (Exception e) { + if (bwcVersion.before(Version.fromString(ENDPOINT_VERSION_ADDED))) { + // endpoint version was added in 8.16.0. if the version is before that, an exception will be thrown if the index mapping + // was created based on a mapping from an old node + assertThat( + e.getMessage(), + containsString("Please update all nodes in your cluster to the latest version to put inference endpoints.") + ); + return; + } + } var configsMap = get(TaskType.COMPLETION, inferenceId); logger.warn("Configs: {}", configsMap); var configs = (List>) configsMap.get("endpoints"); diff --git a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/InferenceUpgradeTestCase.java b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/InferenceUpgradeTestCase.java index 58335eb53b366..4b46d6ada3e77 100644 --- a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/InferenceUpgradeTestCase.java +++ b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/InferenceUpgradeTestCase.java @@ -10,6 +10,8 @@ import com.carrotsearch.randomizedtesting.annotations.Name; import org.elasticsearch.client.Request; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.WarningsHandler; import org.elasticsearch.common.Strings; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.http.MockWebServer; @@ -105,6 +107,8 @@ protected void put(String inferenceId, String modelConfig, TaskType taskType) th String endpoint = Strings.format("_inference/%s/%s?error_trace", taskType, inferenceId); var request = new Request("PUT", endpoint); request.setJsonEntity(modelConfig); + request.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build()); // TODO remove + // permissive warnings once the deprecation warnings are removed in 9.0 var response = client().performRequest(request); assertOKAndConsume(response); } diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestDenseInferenceServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestDenseInferenceServiceExtension.java index cd9a773f49f44..db836af18f247 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestDenseInferenceServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestDenseInferenceServiceExtension.java @@ -46,7 +46,7 @@ public List getInferenceServiceFactories() { } public static class TestDenseModel extends Model { - public TestDenseModel(String inferenceEntityId, TestDenseInferenceServiceExtension.TestServiceSettings serviceSettings) { + public TestDenseModel(String inferenceEntityId, TestServiceSettings serviceSettings) { super( new ModelConfigurations( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/ModelRegistryIT.java b/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/ModelRegistryIT.java index 8e68ca9dfa565..d2904e3f73423 100644 --- a/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/ModelRegistryIT.java +++ b/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/ModelRegistryIT.java @@ -517,8 +517,8 @@ private static Model buildModelWithUnknownField(String inferenceEntityId) { ); } - public static Model createModel(String inferenceEntityId, TaskType taskType, String service) { - return new Model(new ModelConfigurations(inferenceEntityId, taskType, service, new TestModelOfAnyKind.TestModelServiceSettings())); + public static Model createModel(String inferenceEntityId, TaskType taskType, String services) { + return new Model(new ModelConfigurations(inferenceEntityId, taskType, services, new TestModelOfAnyKind.TestModelServiceSettings())); } public static Model createModelWithSecrets(String inferenceEntityId, TaskType taskType, String service, String secret) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportPutInferenceModelAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportPutInferenceModelAction.java index 49d65b6e0dc59..80edbfffdff67 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportPutInferenceModelAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportPutInferenceModelAction.java @@ -177,7 +177,15 @@ private void parseAndStoreModel( new ElasticsearchStatusException( "One or more nodes in your cluster does not support chunking_settings. " + "Please update all nodes in your cluster to the latest version to use chunking_settings.", - RestStatus.BAD_REQUEST + RestStatus.CONFLICT + ) + ); + } else if (e.getCause() instanceof StrictDynamicMappingException) { + delegate.onFailure( + new ElasticsearchStatusException( + "One or more nodes in your cluster is not on the latest version " + + "Please update all nodes in your cluster to the latest version to put inference endpoints.", + RestStatus.CONFLICT ) ); } else { @@ -210,7 +218,7 @@ private Map requestToMap(PutInferenceModelAction.Request request try ( XContentParser parser = XContentHelper.createParser( XContentParserConfiguration.EMPTY, - request.getContent(), + request.getRewrittenContent(), // to account for model version upgrades with BWC we need to rewrite the content request.getContentType() ) ) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/registry/ModelRegistry.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/registry/ModelRegistry.java index d756c0ef26f14..e6b580f65cb51 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/registry/ModelRegistry.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/registry/ModelRegistry.java @@ -418,7 +418,7 @@ private static IndexRequest createIndexRequest(String docId, String indexName, T var request = new IndexRequest(indexName); XContentBuilder source = body.toXContent( builder, - new ToXContent.MapParams(Map.of(ModelConfigurations.USE_ID_FOR_INDEX, Boolean.TRUE.toString())) + new ToXContent.MapParams(Map.of(ModelConfigurations.FOR_INDEX, Boolean.TRUE.toString())) ); var operation = allowOverwriting ? DocWriteRequest.OpType.INDEX : DocWriteRequest.OpType.CREATE; diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilterTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilterTests.java index 770e6e3cb9cf4..14e4e58bf2ce7 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilterTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilterTests.java @@ -277,6 +277,7 @@ private static ShardBulkInferenceActionFilter createFilter(ThreadPool threadPool model.getServiceSettings().model(), XContentHelper.convertToMap(JsonXContent.jsonXContent, Strings.toString(model.getTaskSettings()), false), XContentHelper.convertToMap(JsonXContent.jsonXContent, Strings.toString(model.getSecretSettings()), false) + ) ); } else { diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityTestPlugin.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityTestPlugin.java index 120527f489549..90a73a1813808 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityTestPlugin.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityTestPlugin.java @@ -147,6 +147,7 @@ private void handleGetInferenceModelActionRequ CohereService.NAME, new CohereRerankServiceSettings("uri", "model", null), topN == null ? new EmptyTaskSettings() : new CohereRerankTaskSettings(topN, null, null) + ) ) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/SenderServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/SenderServiceTests.java index a063a398a4947..a27d735057dfa 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/SenderServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/SenderServiceTests.java @@ -147,7 +147,7 @@ public Model parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secretss ) { return null; } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModelTests.java index 57218a5cf45a9..21de79b9eb058 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModelTests.java @@ -48,6 +48,7 @@ public static AlibabaCloudSearchCompletionModel createModel( taskSettings, secrets, null + ); } @@ -65,6 +66,7 @@ public static AlibabaCloudSearchCompletionModel createModel( serviceSettings, taskSettings, secretSettings + ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModelTests.java index fca0ee11e5c78..e7e36e9d8c72f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModelTests.java @@ -49,6 +49,7 @@ public static AlibabaCloudSearchEmbeddingsModel createModel( taskSettings, secrets, null + ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModelTests.java index 4e9179b66c36f..e3e03140386a4 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModelTests.java @@ -49,6 +49,7 @@ public static AlibabaCloudSearchSparseModel createModel( taskSettings, secrets, null + ); } @@ -66,6 +67,7 @@ public static AlibabaCloudSearchSparseModel createModel( serviceSettings, taskSettings, secretSettings + ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModelTests.java index 85535b1400b86..0a01a33d52d21 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModelTests.java @@ -53,6 +53,7 @@ public static AnthropicChatCompletionModel createChatCompletionModel(String url, new AnthropicChatCompletionServiceSettings(modelName, null), new AnthropicChatCompletionTaskSettings(maxTokens, null, null, null), new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } @@ -64,6 +65,7 @@ public static AnthropicChatCompletionModel createChatCompletionModel(String apiK new AnthropicChatCompletionServiceSettings(modelName, null), new AnthropicChatCompletionTaskSettings(maxTokens, null, null, null), new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioServiceTests.java index 9c3afc68306b2..063bf0fc83040 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioServiceTests.java @@ -800,6 +800,7 @@ public void testCheckModelConfig_WorksForChatCompletionsModel() throws IOExcepti null, AzureAiStudioChatCompletionTaskSettings.DEFAULT_MAX_NEW_TOKENS, null + ) ) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModelTests.java index 93d948a5bdcf3..c3c017fdde4fe 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModelTests.java @@ -46,7 +46,16 @@ public void testOverrideWith_UpdatedTaskSettings_OverridesUser() { } public void testOverrideWith_EmptyMap_OverridesNothing() { - var model = createCompletionModel("resource", "deployment", "api version", "user", "api key", "entra id", "inference entity id"); + var model = createCompletionModel( + "resource", + "deployment", + "api version", + "user", + "api key", + "entra id", + "inference entity id" + + ); var requestTaskSettingsMap = Map.of(); var overriddenModel = AzureOpenAiCompletionModel.of(model, requestTaskSettingsMap); @@ -54,7 +63,16 @@ public void testOverrideWith_EmptyMap_OverridesNothing() { } public void testOverrideWith_NullMap_OverridesNothing() { - var model = createCompletionModel("resource", "deployment", "api version", "user", "api key", "entra id", "inference entity id"); + var model = createCompletionModel( + "resource", + "deployment", + "api version", + "user", + "api key", + "entra id", + "inference entity id" + + ); var overriddenModel = AzureOpenAiCompletionModel.of(model, null); assertThat(overriddenModel, sameInstance(model)); @@ -108,6 +126,7 @@ public static AzureOpenAiCompletionModel createModelWithRandomValues() { randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10) + ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModelTests.java index b9fc7ee7b9952..2b47a195e919f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModelTests.java @@ -31,6 +31,7 @@ public void testCreateModel_AlwaysWithEmptyTaskSettings() { new HashMap<>(Map.of("model", "overridden model")), null, ConfigurationParseContext.PERSISTENT + ); assertThat(model.getTaskSettings(), is(EmptyTaskSettings.INSTANCE)); @@ -44,6 +45,7 @@ public static CohereCompletionModel createModel(String url, String apiKey, @Null new CohereCompletionServiceSettings(url, model, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModelTests.java index 093283c0b37d6..29bc8c8c2a438 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModelTests.java @@ -246,6 +246,7 @@ public static CohereEmbeddingsModel createModel( ), taskSettings, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModelTests.java index f4c13db78c4bc..a4f1e4006ef87 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModelTests.java @@ -63,6 +63,7 @@ public static GoogleAiStudioCompletionModel createModel(String model, String url new GoogleAiStudioCompletionServiceSettings(model, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModelTests.java index 32bd95c954292..eb260fc8c9760 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModelTests.java @@ -58,6 +58,7 @@ public static GoogleAiStudioEmbeddingsModel createModel( new GoogleAiStudioEmbeddingsServiceSettings(model, null, dimensions, similarityMeasure, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } @@ -75,6 +76,7 @@ public static GoogleAiStudioEmbeddingsModel createModel( EmptyTaskSettings.INSTANCE, null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModelTests.java index ca38bdb6e2c6c..9a6bc312e607b 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModelTests.java @@ -60,6 +60,7 @@ public static GoogleVertexAiEmbeddingsModel createModel( new GoogleVertexAiEmbeddingsServiceSettings(location, projectId, modelId, false, null, null, null, null), new GoogleVertexAiEmbeddingsTaskSettings(Boolean.FALSE), new GoogleVertexAiSecretSettings(new SecureString(serviceAccountJson.toCharArray())) + ); } @@ -80,6 +81,7 @@ public static GoogleVertexAiEmbeddingsModel createModel(String modelId, @Nullabl ), new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate), new GoogleVertexAiSecretSettings(new SecureString(randomAlphaOfLength(8).toCharArray())) + ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModelTests.java index dff4e223cf9f4..b0f2a73e3ea07 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModelTests.java @@ -46,6 +46,7 @@ public static GoogleVertexAiRerankModel createModel(@Nullable String modelId, @N new GoogleVertexAiRerankServiceSettings(randomAlphaOfLength(10), modelId, null), new GoogleVertexAiRerankTaskSettings(topN), new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)) + ); } @@ -58,6 +59,7 @@ public static GoogleVertexAiRerankModel createModel(String url, @Nullable String new GoogleVertexAiRerankServiceSettings(randomAlphaOfLength(10), modelId, null), new GoogleVertexAiRerankTaskSettings(topN), new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)) + ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModelTests.java index b81eabb20edc3..10268c9895410 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModelTests.java @@ -44,6 +44,7 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey, new HuggingFaceServiceSettings(createUri(url), null, null, tokenLimit, null), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } @@ -55,6 +56,7 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey, new HuggingFaceServiceSettings(createUri(url), null, dimensions, tokenLimit, null), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } @@ -72,6 +74,7 @@ public static HuggingFaceEmbeddingsModel createModel( new HuggingFaceServiceSettings(createUri(url), similarityMeasure, dimensions, tokenLimit, null), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); } } diff --git a/x-pack/plugin/ml/qa/ml-inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceBaseRestTest.java b/x-pack/plugin/ml/qa/ml-inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceBaseRestTest.java index a99969d5755eb..d081801c60763 100644 --- a/x-pack/plugin/ml/qa/ml-inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceBaseRestTest.java +++ b/x-pack/plugin/ml/qa/ml-inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceBaseRestTest.java @@ -8,6 +8,8 @@ package org.elasticsearch.xpack.ml.integration; import org.elasticsearch.client.Request; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.WarningsHandler; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; @@ -51,6 +53,8 @@ protected Map putInferenceServiceModel(String modelId, TaskType var request = new Request("PUT", endpoint); var modelConfig = ExampleModels.mockServiceModelConfig(); request.setJsonEntity(modelConfig); + request.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build()); // TODO remove + // permissive warnings once the deprecation warnings are removed in 9.0 var response = client().performRequest(request); return entityAsMap(response); }