From 50d8912db877954d501aef92d691fb32b84d2f69 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Fri, 4 Oct 2024 11:19:16 -0400 Subject: [PATCH 01/15] Add parameters to ModeConfigurations; rename task_settings constant --- .../inference/ModelConfigurations.java | 14 +++++++++++--- .../mock/AbstractTestInferenceService.java | 4 ++-- .../inference/integration/ModelRegistryIT.java | 4 ++-- .../xpack/inference/registry/ModelRegistry.java | 9 ++++++++- .../AlibabaCloudSearchService.java | 6 +++--- .../AlibabaCloudSearchEmbeddingsTaskSettings.java | 2 +- .../AlibabaCloudSearchSparseTaskSettings.java | 2 +- .../amazonbedrock/AmazonBedrockService.java | 6 +++--- ...onBedrockChatCompletionRequestTaskSettings.java | 8 ++++---- .../AmazonBedrockChatCompletionTaskSettings.java | 8 ++++---- .../services/anthropic/AnthropicService.java | 6 +++--- .../AnthropicChatCompletionTaskSettings.java | 2 +- .../azureaistudio/AzureAiStudioService.java | 6 +++--- ...eAiStudioChatCompletionRequestTaskSettings.java | 6 +++--- .../AzureAiStudioChatCompletionTaskSettings.java | 6 +++--- ...AzureAiStudioEmbeddingsRequestTaskSettings.java | 2 +- .../AzureAiStudioEmbeddingsTaskSettings.java | 2 +- .../services/azureopenai/AzureOpenAiService.java | 6 +++--- .../AzureOpenAiCompletionRequestTaskSettings.java | 2 +- .../AzureOpenAiCompletionTaskSettings.java | 2 +- .../AzureOpenAiEmbeddingsRequestTaskSettings.java | 2 +- .../AzureOpenAiEmbeddingsTaskSettings.java | 2 +- .../inference/services/cohere/CohereService.java | 6 +++--- .../embeddings/CohereEmbeddingsTaskSettings.java | 4 ++-- .../cohere/rerank/CohereRerankTaskSettings.java | 4 ++-- .../services/elastic/ElasticInferenceService.java | 6 +++--- .../ElasticsearchInternalService.java | 4 ++-- .../googleaistudio/GoogleAiStudioService.java | 6 +++--- .../googlevertexai/GoogleVertexAiService.java | 6 +++--- .../GoogleVertexAiRerankRequestTaskSettings.java | 2 +- .../rerank/GoogleVertexAiRerankTaskSettings.java | 2 +- .../services/ibmwatsonx/IbmWatsonxService.java | 6 +++--- .../inference/services/mistral/MistralService.java | 6 +++--- .../inference/services/openai/OpenAiService.java | 6 +++--- .../OpenAiChatCompletionRequestTaskSettings.java | 2 +- .../OpenAiChatCompletionTaskSettings.java | 2 +- .../OpenAiEmbeddingsRequestTaskSettings.java | 2 +- .../embeddings/OpenAiEmbeddingsTaskSettings.java | 2 +- .../org/elasticsearch/xpack/inference/Utils.java | 10 +++++++--- .../AlibabaCloudSearchServiceTests.java | 2 +- .../amazonbedrock/AmazonBedrockServiceTests.java | 6 ++++-- .../azureaistudio/AzureAiStudioServiceTests.java | 2 +- .../azureopenai/AzureOpenAiServiceTests.java | 2 +- .../services/cohere/CohereServiceTests.java | 2 +- .../ElasticsearchInternalServiceTests.java | 4 ++-- .../googleaistudio/GoogleAiStudioServiceTests.java | 2 +- .../googlevertexai/GoogleVertexAiServiceTests.java | 2 +- .../ibmwatsonx/IbmWatsonxServiceTests.java | 2 +- .../services/mistral/MistralServiceTests.java | 2 +- 49 files changed, 115 insertions(+), 94 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java index 9f7a247d00a3a..a95d67e3369ad 100644 --- a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java +++ b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java @@ -28,8 +28,10 @@ public class ModelConfigurations implements ToFilteredXContentObject, VersionedN public static final String USE_ID_FOR_INDEX = "for_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 OLD_TASK_SETTINGS = "task_settings"; + public static final String PARAMETERS = "parameters"; public static final String CHUNKING_SETTINGS = "chunking_settings"; + public static final String INCLUDE_PARAMETERS = "include_parameters"; private static final String NAME = "inference_model"; public static ModelConfigurations of(Model model, TaskSettings taskSettings) { @@ -173,10 +175,13 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TaskType.NAME, taskType.toString()); builder.field(SERVICE, service); builder.field(SERVICE_SETTINGS, serviceSettings); - builder.field(TASK_SETTINGS, taskSettings); + builder.field(OLD_TASK_SETTINGS, taskSettings); if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } + if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters + builder.field(PARAMETERS, taskSettings); + } builder.endObject(); return builder; } @@ -192,10 +197,13 @@ public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params builder.field(TaskType.NAME, taskType.toString()); builder.field(SERVICE, service); builder.field(SERVICE_SETTINGS, serviceSettings.getFilteredXContentObject()); - builder.field(TASK_SETTINGS, taskSettings); + builder.field(OLD_TASK_SETTINGS, taskSettings); if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } + if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters + builder.field(PARAMETERS, taskSettings); + } builder.endObject(); return builder; } diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java index 1bde3704864d5..aa75b58e3ff40 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java @@ -44,8 +44,8 @@ public TransportVersion getMinimalSupportedVersion() { protected static Map getTaskSettingsMap(Map settings) { Map taskSettingsMap; // task settings are optional - if (settings.containsKey(ModelConfigurations.TASK_SETTINGS)) { - taskSettingsMap = (Map) settings.remove(ModelConfigurations.TASK_SETTINGS); + if (settings.containsKey(ModelConfigurations.OLD_TASK_SETTINGS)) { + taskSettingsMap = (Map) settings.remove(ModelConfigurations.OLD_TASK_SETTINGS); } else { taskSettingsMap = Map.of(); } 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..d001e07d0d3db 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 @@ -631,7 +631,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TaskType.NAME, getTaskType().toString()); builder.field(SERVICE, getService()); builder.field(SERVICE_SETTINGS, getServiceSettings()); - builder.field(TASK_SETTINGS, getTaskSettings()); + builder.field(OLD_TASK_SETTINGS, getTaskSettings()); builder.endObject(); return builder; } @@ -657,7 +657,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TaskType.NAME, getTaskType().toString()); builder.field(SERVICE, getService()); builder.field(SERVICE_SETTINGS, getServiceSettings()); - builder.field(TASK_SETTINGS, getTaskSettings()); + builder.field(OLD_TASK_SETTINGS, getTaskSettings()); builder.endObject(); return builder; } 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..c6a5019783507 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,14 @@ 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.USE_ID_FOR_INDEX, + Boolean.TRUE.toString(), + ModelConfigurations.INCLUDE_PARAMETERS, // we are going to continue to write the parameters field as `task_settings` + Boolean.FALSE.toString() + ) + ) ); var operation = allowOverwriting ? DocWriteRequest.OpType.INDEX : DocWriteRequest.OpType.CREATE; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java index 0bd0eee1aa9a1..709973115cefa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java @@ -72,7 +72,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); AlibabaCloudSearchModel model = createModel( inferenceEntityId, @@ -171,7 +171,7 @@ public AlibabaCloudSearchModel parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); return createModelWithoutLoggingDeprecations( @@ -187,7 +187,7 @@ public AlibabaCloudSearchModel parsePersistedConfigWithSecrets( @Override public AlibabaCloudSearchModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); return createModelWithoutLoggingDeprecations( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java index abfd49940b67b..ece60cc1df2a0 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java @@ -53,7 +53,7 @@ public static AlibabaCloudSearchEmbeddingsTaskSettings fromMap(Map m InputType inputType = extractOptionalEnum( map, INPUT_TYPE, - ModelConfigurations.TASK_SETTINGS, + ModelConfigurations.OLD_TASK_SETTINGS, InputType::fromString, VALID_REQUEST_VALUES, validationException diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java index bc0d10279ae44..5264133f76402 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java @@ -124,7 +124,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); AmazonBedrockModel model = createModel( modelId, @@ -154,7 +154,7 @@ public Model parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModel( @@ -171,7 +171,7 @@ public Model parsePersistedConfigWithSecrets( @Override public Model parsePersistedConfig(String modelId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); return createModel( modelId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionRequestTaskSettings.java index 5985dcd56c5d2..2b90320ab746b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionRequestTaskSettings.java @@ -55,7 +55,7 @@ public static AmazonBedrockChatCompletionRequestTaskSettings fromMap(Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); AnthropicModel model = createModel( inferenceEntityId, @@ -133,7 +133,7 @@ public AnthropicModel parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -149,7 +149,7 @@ public AnthropicModel parsePersistedConfigWithSecrets( @Override public AnthropicModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java index a1457dda64e40..f49e3b60f32f9 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java @@ -62,7 +62,7 @@ private static AnthropicChatCompletionTaskSettings fromPersistedMap(Map map, ValidationException validationException) { - Integer maxTokens = extractRequiredPositiveInteger(map, MAX_TOKENS, ModelConfigurations.TASK_SETTINGS, validationException); + Integer maxTokens = extractRequiredPositiveInteger(map, MAX_TOKENS, ModelConfigurations.OLD_TASK_SETTINGS, validationException); // At the time of writing the allowed values for the temperature field are -1, and range 0-1. // I'm intentionally not validating the values here, we'll let Anthropic return an error when we send it instead. diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java index 7981fb393a842..84c357ba8bda8 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java @@ -113,7 +113,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); AzureAiStudioModel model = createModel( inferenceEntityId, @@ -143,7 +143,7 @@ public AzureAiStudioModel parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -159,7 +159,7 @@ public AzureAiStudioModel parsePersistedConfigWithSecrets( @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionRequestTaskSettings.java index 2eef059e3fae1..80c8a297ad201 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionRequestTaskSettings.java @@ -55,7 +55,7 @@ public static AzureAiStudioChatCompletionRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER_FIELD, ModelConfigurations.TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER_FIELD, ModelConfigurations.OLD_TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java index 96399bb954cd2..24d62464f08cd 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java @@ -68,7 +68,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); AzureOpenAiModel model = createModel( inferenceEntityId, @@ -153,7 +153,7 @@ public AzureOpenAiModel parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -169,7 +169,7 @@ public AzureOpenAiModel parsePersistedConfigWithSecrets( @Override public AzureOpenAiModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionRequestTaskSettings.java index 5dd42bb1b911f..b0bb519cdad92 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionRequestTaskSettings.java @@ -27,7 +27,7 @@ public static AzureOpenAiCompletionRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsRequestTaskSettings.java index ffb8c844ac89f..6a2a65baa054c 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsRequestTaskSettings.java @@ -40,7 +40,7 @@ public static AzureOpenAiEmbeddingsRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java index 728a4ac137dff..212cf756dd206 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java @@ -73,7 +73,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); CohereModel model = createModel( inferenceEntityId, @@ -155,7 +155,7 @@ public CohereModel parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); return createModelWithoutLoggingDeprecations( @@ -171,7 +171,7 @@ public CohereModel parsePersistedConfigWithSecrets( @Override public CohereModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); return createModelWithoutLoggingDeprecations( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java index 0a42df8c0bb41..c585f607f5a94 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java @@ -57,7 +57,7 @@ public static CohereEmbeddingsTaskSettings fromMap(Map map) { InputType inputType = extractOptionalEnum( map, INPUT_TYPE, - ModelConfigurations.TASK_SETTINGS, + ModelConfigurations.OLD_TASK_SETTINGS, InputType::fromString, VALID_REQUEST_VALUES, validationException @@ -65,7 +65,7 @@ public static CohereEmbeddingsTaskSettings fromMap(Map map) { CohereTruncation truncation = extractOptionalEnum( map, TRUNCATE, - ModelConfigurations.TASK_SETTINGS, + ModelConfigurations.OLD_TASK_SETTINGS, CohereTruncation::fromString, EnumSet.allOf(CohereTruncation.class), validationException diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java index a01f6a4e65b8f..db3c16f07a2a5 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java @@ -53,13 +53,13 @@ public static CohereRerankTaskSettings fromMap(Map map) { Integer topNDocumentsOnly = extractOptionalPositiveInteger( map, TOP_N_DOCS_ONLY, - ModelConfigurations.TASK_SETTINGS, + ModelConfigurations.OLD_TASK_SETTINGS, validationException ); Integer maxChunksPerDoc = extractOptionalPositiveInteger( map, MAX_CHUNKS_PER_DOC, - ModelConfigurations.TASK_SETTINGS, + ModelConfigurations.OLD_TASK_SETTINGS, validationException ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java index 7cfbc272aac5a..37c2876b45a15 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java @@ -120,7 +120,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); ElasticInferenceServiceModel model = createModel( inferenceEntityId, @@ -176,7 +176,7 @@ public Model parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -192,7 +192,7 @@ public Model parsePersistedConfigWithSecrets( @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java index 9b4c0e50bdebe..2c9d04ac16f61 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java @@ -116,7 +116,7 @@ public void parseRequestConfig( try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMap(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMap(config, ModelConfigurations.OLD_TASK_SETTINGS); String serviceName = (String) config.remove(ModelConfigurations.SERVICE); // required for elser service in elasticsearch service throwIfNotEmptyMap(config, name()); @@ -386,7 +386,7 @@ public Model parsePersistedConfigWithSecrets( @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMap(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMap(config, ModelConfigurations.OLD_TASK_SETTINGS); String modelId = (String) serviceSettingsMap.get(ElasticsearchInternalServiceSettings.MODEL_ID); if (modelId == null) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java index 9a04edf138996..0a5997a2a3037 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java @@ -72,7 +72,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { @@ -145,7 +145,7 @@ public GoogleAiStudioModel parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -188,7 +188,7 @@ private static GoogleAiStudioModel createModelFromPersistent( @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java index d9d8850048564..b8a393c093758 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java @@ -68,7 +68,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); GoogleVertexAiModel model = createModel( inferenceEntityId, @@ -98,7 +98,7 @@ public Model parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -114,7 +114,7 @@ public Model parsePersistedConfigWithSecrets( @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankRequestTaskSettings.java index 5cb1acd8038f7..44344e6c0dd60 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankRequestTaskSettings.java @@ -29,7 +29,7 @@ public static GoogleVertexAiRerankRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - Integer topN = extractOptionalPositiveInteger(map, TOP_N, ModelConfigurations.TASK_SETTINGS, validationException); + Integer topN = extractOptionalPositiveInteger(map, TOP_N, ModelConfigurations.OLD_TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java index 14be1a70b5daa..6507afe7302dd 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java @@ -68,7 +68,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); IbmWatsonxModel model = createModel( inferenceEntityId, @@ -122,7 +122,7 @@ public IbmWatsonxModel parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -157,7 +157,7 @@ private static IbmWatsonxModel createModelFromPersistent( @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java index 8af817d06fefa..f4f0309b64fee 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java @@ -126,7 +126,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { @@ -164,7 +164,7 @@ public Model parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -186,7 +186,7 @@ public Model parsePersistedConfigWithSecrets( @Override public Model parsePersistedConfig(String modelId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java index fd5f7197475aa..077d4b52268eb 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java @@ -73,7 +73,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { @@ -168,7 +168,7 @@ public OpenAiModel parsePersistedConfigWithSecrets( Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -192,7 +192,7 @@ public OpenAiModel parsePersistedConfigWithSecrets( @Override public OpenAiModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionRequestTaskSettings.java index 8029d8579baba..bf30792d96b58 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionRequestTaskSettings.java @@ -40,7 +40,7 @@ public static OpenAiChatCompletionRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettings.java index b3b94f7584563..7cbc6f5f0b64b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettings.java @@ -40,7 +40,7 @@ public static OpenAiEmbeddingsRequestTaskSettings fromMap(Map ma ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java index b4cf9b27d0ff1..158c163a989f4 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java @@ -38,7 +38,7 @@ public class OpenAiEmbeddingsTaskSettings implements TaskSettings { public static OpenAiEmbeddingsTaskSettings fromMap(Map map, ConfigurationParseContext context) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java index 5abb9000f4d04..8928fdc79e815 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java @@ -194,7 +194,9 @@ public static PersistedConfig getPersistedConfigMap( var secrets = secretSettings == null ? null : new HashMap(Map.of(ModelSecrets.SECRET_SETTINGS, secretSettings)); return new PersistedConfig( - new HashMap<>(Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings)), + new HashMap<>( + Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + ), secrets ); } @@ -205,7 +207,9 @@ public static PersistedConfig getPersistedConfigMap(Map serviceS public static PersistedConfig getPersistedConfigMap(Map serviceSettings, Map taskSettings) { return new PersistedConfig( - new HashMap<>(Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings)), + new HashMap<>( + Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + ), null ); } @@ -232,7 +236,7 @@ public static Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java index e8c34eec96171..ec4120881521a 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java @@ -254,7 +254,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java index 0b3cf533d818f..eee4eb33ab453 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java @@ -1116,7 +1116,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } @@ -1127,7 +1127,9 @@ private Utils.PersistedConfig getPersistedConfigMap( ) { return new Utils.PersistedConfig( - new HashMap<>(Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings)), + new HashMap<>( + Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + ), new HashMap<>(Map.of(ModelSecrets.SECRET_SETTINGS, secretSettings)) ); } 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..8ba10b50c8058 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 @@ -1031,7 +1031,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java index 098e41b72ea8f..8d5c590518fa8 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java @@ -1155,7 +1155,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java index 22503108b5262..b0b1252116a9e 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java @@ -1359,7 +1359,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java index cd6da4c0ad8d8..513a62e057e3f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java @@ -387,7 +387,7 @@ public void testParseRequestConfig_Rerank() { ); var returnDocs = randomBoolean(); settings.put( - ModelConfigurations.TASK_SETTINGS, + ModelConfigurations.OLD_TASK_SETTINGS, new HashMap<>(Map.of(CustomElandRerankTaskSettings.RETURN_DOCUMENTS, returnDocs)) ); @@ -885,7 +885,7 @@ public void testParsePersistedConfig_Rerank() { settings.put(ElasticsearchInternalServiceSettings.MODEL_ID, "foo"); var returnDocs = randomBoolean(); settings.put( - ModelConfigurations.TASK_SETTINGS, + ModelConfigurations.OLD_TASK_SETTINGS, new HashMap<>(Map.of(CustomElandRerankTaskSettings.RETURN_DOCUMENTS, returnDocs)) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java index e8382876868c5..00ca67ccdeab3 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java @@ -1255,7 +1255,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java index 6a96d289a8190..3ec6c08082ba0 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java @@ -566,7 +566,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java index f8f08e6f880ab..58f1d158468e0 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java @@ -781,7 +781,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java index c4a91260d89a0..b1e55b8bf24f9 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java @@ -853,7 +853,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) ); } From 714535e27a6d230cec11d8a92a74fb4e1b3f884f Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Fri, 4 Oct 2024 16:42:52 -0400 Subject: [PATCH 02/15] Add endpointVersion exceptin in index mappings --- .../org/elasticsearch/TransportVersions.java | 1 + .../inference/InferenceService.java | 47 +++-- .../inference/ModelConfigurations.java | 50 ++++- .../inference/UnparsedModel.java | 3 +- .../action/PutInferenceModelAction.java | 38 ++++ .../action/PutInferenceModelActionTests.java | 62 ++++++ .../mock/AbstractTestInferenceService.java | 17 +- .../TestDenseInferenceServiceExtension.java | 10 +- .../mock/TestRerankingServiceExtension.java | 9 +- .../TestSparseInferenceServiceExtension.java | 15 +- ...stStreamingCompletionServiceExtension.java | 5 +- .../integration/ModelRegistryIT.java | 175 +++++++++++++--- .../TransportGetInferenceModelAction.java | 14 +- .../action/TransportInferenceAction.java | 3 +- .../TransportPutInferenceModelAction.java | 6 +- .../ShardBulkInferenceActionFilter.java | 3 +- .../inference/registry/ModelRegistry.java | 20 +- .../AlibabaCloudSearchService.java | 41 ++-- .../AlibabaCloudSearchCompletionModel.java | 11 +- .../AlibabaCloudSearchEmbeddingsModel.java | 11 +- .../rerank/AlibabaCloudSearchRerankModel.java | 11 +- .../sparse/AlibabaCloudSearchSparseModel.java | 11 +- .../amazonbedrock/AmazonBedrockService.java | 24 ++- .../AmazonBedrockChatCompletionModel.java | 14 +- .../AmazonBedrockEmbeddingsModel.java | 11 +- .../services/anthropic/AnthropicService.java | 32 ++- .../AnthropicChatCompletionModel.java | 16 +- .../azureaistudio/AzureAiStudioService.java | 30 ++- .../AzureAiStudioChatCompletionModel.java | 14 +- .../AzureAiStudioEmbeddingsModel.java | 14 +- .../azureopenai/AzureOpenAiService.java | 35 +++- .../AzureOpenAiCompletionModel.java | 11 +- .../AzureOpenAiEmbeddingsModel.java | 11 +- .../services/cohere/CohereService.java | 46 ++++- .../completion/CohereCompletionModel.java | 11 +- .../embeddings/CohereEmbeddingsModel.java | 11 +- .../cohere/rerank/CohereRerankModel.java | 11 +- .../elastic/ElasticInferenceService.java | 27 ++- ...InferenceServiceSparseEmbeddingsModel.java | 11 +- .../CustomElandEmbeddingModel.java | 5 +- .../elasticsearch/CustomElandModel.java | 10 +- .../elasticsearch/CustomElandRerankModel.java | 5 +- .../ElasticsearchInternalModel.java | 10 +- .../ElasticsearchInternalService.java | 88 +++++--- .../elasticsearch/ElserInternalModel.java | 5 +- .../MultilingualE5SmallModel.java | 5 +- .../googleaistudio/GoogleAiStudioService.java | 30 ++- .../GoogleAiStudioCompletionModel.java | 16 +- .../GoogleAiStudioEmbeddingsModel.java | 21 +- .../googlevertexai/GoogleVertexAiService.java | 30 ++- .../GoogleVertexAiEmbeddingsModel.java | 16 +- .../rerank/GoogleVertexAiRerankModel.java | 16 +- .../huggingface/HuggingFaceBaseService.java | 23 ++- .../huggingface/HuggingFaceService.java | 16 +- .../elser/HuggingFaceElserModel.java | 11 +- .../elser/HuggingFaceElserService.java | 13 +- .../HuggingFaceEmbeddingsModel.java | 14 +- .../ibmwatsonx/IbmWatsonxService.java | 27 ++- .../embeddings/IbmWatsonxEmbeddingsModel.java | 16 +- .../services/mistral/MistralService.java | 27 ++- .../embeddings/MistralEmbeddingsModel.java | 19 +- .../services/openai/OpenAiService.java | 35 +++- .../completion/OpenAiChatCompletionModel.java | 11 +- .../embeddings/OpenAiEmbeddingsModel.java | 11 +- .../inference/ModelConfigurationsTests.java | 12 +- .../elasticsearch/xpack/inference/Utils.java | 6 +- .../TransportInferenceUsageActionTests.java | 48 ++++- .../ShardBulkInferenceActionFilterTests.java | 14 +- .../AzureOpenAiActionCreatorTests.java | 34 +++- .../AzureOpenAiCompletionActionTests.java | 12 +- ...ureAiStudioChatCompletionRequestTests.java | 4 +- .../AzureOpenAiCompletionRequestTests.java | 4 +- .../xpack/inference/model/TestModel.java | 8 +- .../TextSimilarityTestPlugin.java | 3 +- .../registry/ModelRegistryTests.java | 41 +++- .../services/SenderServiceTests.java | 6 +- .../AlibabaCloudSearchServiceTests.java | 4 +- ...libabaCloudSearchCompletionModelTests.java | 9 +- ...libabaCloudSearchEmbeddingsModelTests.java | 8 +- .../AlibabaCloudSearchSparseModelTests.java | 9 +- .../AmazonBedrockServiceTests.java | 101 +++++++-- ...AmazonBedrockChatCompletionModelTests.java | 4 +- .../AmazonBedrockEmbeddingsModelTests.java | 4 +- .../anthropic/AnthropicServiceTests.java | 54 +++-- .../AnthropicChatCompletionModelTests.java | 9 +- .../AzureAiStudioServiceTests.java | 192 +++++++++++++++--- ...AzureAiStudioChatCompletionModelTests.java | 48 +++-- .../AzureAiStudioEmbeddingsModelTests.java | 4 +- .../azureopenai/AzureOpenAiServiceTests.java | 91 +++++++-- .../AzureOpenAiCompletionModelTests.java | 94 ++++++++- .../AzureOpenAiEmbeddingsModelTests.java | 7 +- .../services/cohere/CohereServiceTests.java | 78 +++++-- .../CohereCompletionModelTests.java | 9 +- .../CohereEmbeddingsModelTests.java | 8 +- ...enceServiceSparseEmbeddingsModelTests.java | 4 +- .../elastic/ElasticInferenceServiceTests.java | 50 ++++- .../ElasticsearchInternalServiceTests.java | 140 ++++++++++--- .../GoogleAiStudioServiceTests.java | 90 ++++++-- .../GoogleAiStudioCompletionModelTests.java | 11 +- .../GoogleAiStudioEmbeddingsModelTests.java | 15 +- .../GoogleVertexAiServiceTests.java | 34 +++- .../GoogleVertexAiEmbeddingsModelTests.java | 9 +- .../GoogleVertexAiRerankModelTests.java | 9 +- .../huggingface/HuggingFaceServiceTests.java | 115 +++++++++-- .../elser/HuggingFaceElserModelTests.java | 7 +- .../HuggingFaceEmbeddingsModelTests.java | 16 +- .../ibmwatsonx/IbmWatsonxServiceTests.java | 19 +- .../IbmWatsonxEmbeddingsModelTests.java | 10 +- .../services/mistral/MistralServiceTests.java | 130 ++++++++++-- .../MistralEmbeddingModelTests.java | 7 +- .../services/openai/OpenAiServiceTests.java | 138 ++++++++++--- .../OpenAiChatCompletionModelTests.java | 4 +- .../OpenAiEmbeddingsModelTests.java | 19 +- 113 files changed, 2429 insertions(+), 695 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index c55436f85a6e3..66654a07bfd8c 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -234,6 +234,7 @@ static TransportVersion def(int id) { public static final TransportVersion RRF_QUERY_REWRITE = def(8_758_00_0); public static final TransportVersion SEARCH_FAILURE_STATS = def(8_759_00_0); public static final TransportVersion INGEST_GEO_DATABASE_PROVIDERS = def(8_760_00_0); + public static final TransportVersion INFERENCE_API_PARAMATERS_INTRODUCED = def(8_761_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..6fa721d939861 100644 --- a/server/src/main/java/org/elasticsearch/inference/InferenceService.java +++ b/server/src/main/java/org/elasticsearch/inference/InferenceService.java @@ -36,40 +36,55 @@ 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 endpointVersion + * @param parsedModelListener A listener which will handle the resulting model or failure */ - void parseRequestConfig(String modelId, TaskType taskType, Map config, ActionListener parsedModelListener); + void parseRequestConfig( + String modelId, + TaskType taskType, + Map config, + String endpointVersion, + ActionListener parsedModelListener + ); /** * 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) + * @param endpointVersion * @return The parsed {@link Model} */ - Model parsePersistedConfigWithSecrets(String modelId, TaskType taskType, Map config, Map secrets); + Model parsePersistedConfigWithSecrets( + String modelId, + TaskType taskType, + Map config, + Map secrets, + String endpointVersion + ); /** * 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 + * @param endpointVersion * @return The parsed {@link Model} */ - Model parsePersistedConfig(String modelId, TaskType taskType, Map config); + Model parsePersistedConfig(String modelId, TaskType taskType, Map config, String endpointVersion); /** * Perform inference on the model. diff --git a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java index a95d67e3369ad..b21e965fd1707 100644 --- a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java +++ b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java @@ -32,6 +32,9 @@ public class ModelConfigurations implements ToFilteredXContentObject, VersionedN public static final String PARAMETERS = "parameters"; public static final String CHUNKING_SETTINGS = "chunking_settings"; public static final String INCLUDE_PARAMETERS = "include_parameters"; + public static final String ENDPOINT_VERSION_FIELD_NAME = "endpoint_version"; + public static final String FIRST_ENDPOINT_VERSION = "2023-09-29"; + public static final String PARAMETERS_INTRODUCED_ENDPOINT_VERSION = "2024-10-17"; private static final String NAME = "inference_model"; public static ModelConfigurations of(Model model, TaskSettings taskSettings) { @@ -44,7 +47,8 @@ public static ModelConfigurations of(Model model, TaskSettings taskSettings) { model.getConfigurations().getService(), model.getServiceSettings(), taskSettings, - model.getConfigurations().getChunkingSettings() + model.getConfigurations().getChunkingSettings(), + model.getConfigurations().getEndpointVersion() ); } @@ -58,7 +62,8 @@ public static ModelConfigurations of(Model model, ServiceSettings serviceSetting model.getConfigurations().getService(), serviceSettings, model.getTaskSettings(), - model.getConfigurations().getChunkingSettings() + model.getConfigurations().getChunkingSettings(), + model.getConfigurations().getEndpointVersion() ); } @@ -68,12 +73,19 @@ public static ModelConfigurations of(Model model, ServiceSettings serviceSetting private final ServiceSettings serviceSettings; private final TaskSettings taskSettings; private final ChunkingSettings chunkingSettings; + private final String endpointVersion; /** * Allows no task settings to be defined. This will default to the {@link EmptyTaskSettings} object. */ - public ModelConfigurations(String inferenceEntityId, TaskType taskType, String service, ServiceSettings serviceSettings) { - this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE); + public ModelConfigurations( + String inferenceEntityId, + TaskType taskType, + String service, + ServiceSettings serviceSettings, + String endpointVersion + ) { + this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE, endpointVersion); } public ModelConfigurations( @@ -81,9 +93,10 @@ public ModelConfigurations( TaskType taskType, String service, ServiceSettings serviceSettings, - ChunkingSettings chunkingSettings + ChunkingSettings chunkingSettings, + String endpointVersion ) { - this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE, chunkingSettings); + this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE, chunkingSettings, endpointVersion); } public ModelConfigurations( @@ -91,13 +104,15 @@ public ModelConfigurations( TaskType taskType, String service, ServiceSettings serviceSettings, - TaskSettings taskSettings + TaskSettings taskSettings, + String endpointVersion ) { this.inferenceEntityId = Objects.requireNonNull(inferenceEntityId); this.taskType = Objects.requireNonNull(taskType); this.service = Objects.requireNonNull(service); this.serviceSettings = Objects.requireNonNull(serviceSettings); this.taskSettings = Objects.requireNonNull(taskSettings); + this.endpointVersion = endpointVersion; this.chunkingSettings = null; } @@ -107,7 +122,8 @@ public ModelConfigurations( String service, ServiceSettings serviceSettings, TaskSettings taskSettings, - ChunkingSettings chunkingSettings + ChunkingSettings chunkingSettings, + String endpointVersion ) { this.inferenceEntityId = Objects.requireNonNull(inferenceEntityId); this.taskType = Objects.requireNonNull(taskType); @@ -115,6 +131,7 @@ public ModelConfigurations( this.serviceSettings = Objects.requireNonNull(serviceSettings); this.taskSettings = Objects.requireNonNull(taskSettings); this.chunkingSettings = chunkingSettings; + this.endpointVersion = endpointVersion; } public ModelConfigurations(StreamInput in) throws IOException { @@ -126,6 +143,9 @@ public ModelConfigurations(StreamInput in) throws IOException { this.chunkingSettings = in.getTransportVersion().onOrAfter(TransportVersions.ML_INFERENCE_CHUNKING_SETTINGS) ? in.readOptionalNamedWriteable(ChunkingSettings.class) : null; + this.endpointVersion = in.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_API_PARAMATERS_INTRODUCED) + ? Objects.requireNonNullElse(in.readOptionalString(), FIRST_ENDPOINT_VERSION) + : FIRST_ENDPOINT_VERSION; } @Override @@ -138,6 +158,9 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersions.ML_INFERENCE_CHUNKING_SETTINGS)) { out.writeOptionalNamedWriteable(chunkingSettings); } + if (out.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_API_PARAMATERS_INTRODUCED)) { + out.writeOptionalString(endpointVersion); // not nullable after 9.0 + } } public String getInferenceEntityId() { @@ -164,6 +187,10 @@ public ChunkingSettings getChunkingSettings() { return chunkingSettings; } + public String getEndpointVersion() { + return endpointVersion; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); @@ -182,6 +209,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters builder.field(PARAMETERS, taskSettings); } + builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); builder.endObject(); return builder; } @@ -204,6 +232,7 @@ public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters builder.field(PARAMETERS, taskSettings); } + builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); builder.endObject(); return builder; } @@ -227,11 +256,12 @@ public boolean equals(Object o) { && taskType == model.taskType && Objects.equals(service, model.service) && Objects.equals(serviceSettings, model.serviceSettings) - && Objects.equals(taskSettings, model.taskSettings); + && Objects.equals(taskSettings, model.taskSettings) + && Objects.equals(endpointVersion, model.endpointVersion); } @Override public int hashCode() { - return Objects.hash(inferenceEntityId, taskType, service, serviceSettings, taskSettings); + return Objects.hash(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); } } diff --git a/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java b/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java index 30a7c6aa2bf9c..409b6d1aa8b39 100644 --- a/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java +++ b/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java @@ -20,5 +20,6 @@ public record UnparsedModel( TaskType taskType, String service, Map settings, - Map secrets + Map secrets, + String endpointVersion ) {} 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..82b19a6ea5157 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; @@ -17,15 +18,24 @@ 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.ENDPOINT_VERSION_FIELD_NAME; +import static org.elasticsearch.inference.ModelConfigurations.FIRST_ENDPOINT_VERSION; +import static org.elasticsearch.inference.ModelConfigurations.OLD_TASK_SETTINGS; +import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; +import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS_INTRODUCED_ENDPOINT_VERSION; + public class PutInferenceModelAction extends ActionType { public static final PutInferenceModelAction INSTANCE = new PutInferenceModelAction(); @@ -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,33 @@ 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(OLD_TASK_SETTINGS)) { + throw new ElasticsearchStatusException( + "Request cannot contain both [task_settings] and [parameters], use only [parameters]", + RestStatus.BAD_REQUEST + ); + } else if (newContent.containsKey(PARAMETERS)) { + newContent.put(OLD_TASK_SETTINGS, newContent.get(PARAMETERS)); + newContent.put(ENDPOINT_VERSION_FIELD_NAME, PARAMETERS_INTRODUCED_ENDPOINT_VERSION); + newContent.remove(PARAMETERS); + } else if (newContent.containsKey(OLD_TASK_SETTINGS)) { + newContent.put(ENDPOINT_VERSION_FIELD_NAME, FIRST_ENDPOINT_VERSION); + } else { + newContent.put(ENDPOINT_VERSION_FIELD_NAME, FIRST_ENDPOINT_VERSION); + } + 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..93d5c00aaa705 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,27 @@ 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.ENDPOINT_VERSION_FIELD_NAME; +import static org.elasticsearch.inference.ModelConfigurations.FIRST_ENDPOINT_VERSION; +import static org.elasticsearch.inference.ModelConfigurations.OLD_TASK_SETTINGS; +import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; public class PutInferenceModelActionTests extends ESTestCase { public static TaskType TASK_TYPE; @@ -57,4 +68,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.getContent(), false, request.getContentType()).v2(); + assertEquals(parametersValues, map.get(OLD_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, + OLD_TASK_SETTINGS, + taskSettingsValues, + "service", + "elasticsearch", + "service_settings", + serviceSettingsValues + ) + ); + assertThrows( + ElasticsearchStatusException.class, + () -> new PutInferenceModelAction.Request(TASK_TYPE, MODEL_ID, BytesReference.bytes(builder), XContentType.JSON).getContent() + ); + + } + + 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(OLD_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(OLD_TASK_SETTINGS)); + assertNull(map.get(PARAMETERS)); + assertEquals("elasticsearch", map.get("service")); + assertEquals(serviceSettingsValues, map.get("service_settings")); + assertEquals(ENDPOINT_VERSION_FIELD_NAME, FIRST_ENDPOINT_VERSION); + } } diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java index aa75b58e3ff40..9c41b00df7009 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java @@ -59,7 +59,8 @@ public TestServiceModel parsePersistedConfigWithSecrets( String modelId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); var secretSettingsMap = (Map) secrets.remove(ModelSecrets.SECRET_SETTINGS); @@ -70,12 +71,12 @@ public TestServiceModel parsePersistedConfigWithSecrets( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - return new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings); + return new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion); } @Override @SuppressWarnings("unchecked") - public Model parsePersistedConfig(String modelId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, String endpointVersion) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); var serviceSettings = getServiceSettingsFromMap(serviceSettingsMap); @@ -83,7 +84,7 @@ public Model parsePersistedConfig(String modelId, TaskType taskType, Map serviceSettingsMap); @@ -104,9 +105,13 @@ public TestServiceModel( String service, ServiceSettings serviceSettings, TestTaskSettings taskSettings, - TestSecretSettings secretSettings + TestSecretSettings secretSettings, + String endpointVersion ) { - super(new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings)); + super( + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelSecrets(secretSettings) + ); } @Override 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..8c42fb7226ac2 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,13 +46,14 @@ public List getInferenceServiceFactories() { } public static class TestDenseModel extends Model { - public TestDenseModel(String inferenceEntityId, TestDenseInferenceServiceExtension.TestServiceSettings serviceSettings) { + public TestDenseModel(String inferenceEntityId, TestServiceSettings serviceSettings, String endpointVersion) { super( new ModelConfigurations( inferenceEntityId, TaskType.TEXT_EMBEDDING, TestDenseInferenceServiceExtension.TestInferenceService.NAME, - serviceSettings + serviceSettings, + endpointVersion ), new ModelSecrets(new AbstractTestInferenceService.TestSecretSettings("api_key")) ); @@ -75,6 +76,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); @@ -84,7 +86,9 @@ public void parseRequestConfig( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - parsedModelListener.onResponse(new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings)); + parsedModelListener.onResponse( + new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion) + ); } @Override diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java index d8ee70986a57d..f51fd4c71ad10 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java @@ -42,9 +42,9 @@ public List getInferenceServiceFactories() { } public static class TestRerankingModel extends Model { - public TestRerankingModel(String inferenceEntityId, TestServiceSettings serviceSettings) { + public TestRerankingModel(String inferenceEntityId, TestServiceSettings serviceSettings, String endpointVersion) { super( - new ModelConfigurations(inferenceEntityId, TaskType.RERANK, TestInferenceService.NAME, serviceSettings), + new ModelConfigurations(inferenceEntityId, TaskType.RERANK, TestInferenceService.NAME, serviceSettings, endpointVersion), new ModelSecrets(new AbstractTestInferenceService.TestSecretSettings("api_key")) ); } @@ -66,6 +66,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); @@ -75,7 +76,9 @@ public void parseRequestConfig( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - parsedModelListener.onResponse(new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings)); + parsedModelListener.onResponse( + new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion) + ); } @Override diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java index 6eb0caad36261..2b7360f97e455 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java @@ -45,9 +45,15 @@ public List getInferenceServiceFactories() { } public static class TestSparseModel extends Model { - public TestSparseModel(String inferenceEntityId, TestServiceSettings serviceSettings) { + public TestSparseModel(String inferenceEntityId, TestServiceSettings serviceSettings, String endpointVersion) { super( - new ModelConfigurations(inferenceEntityId, TaskType.SPARSE_EMBEDDING, TestInferenceService.NAME, serviceSettings), + new ModelConfigurations( + inferenceEntityId, + TaskType.SPARSE_EMBEDDING, + TestInferenceService.NAME, + serviceSettings, + endpointVersion + ), new ModelSecrets(new AbstractTestInferenceService.TestSecretSettings("api_key")) ); } @@ -69,6 +75,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); @@ -78,7 +85,9 @@ public void parseRequestConfig( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - parsedModelListener.onResponse(new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings)); + parsedModelListener.onResponse( + new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion) + ); } @Override diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java index 206aa1f3e5d28..4ef6f397b5571 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java @@ -67,6 +67,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); @@ -76,7 +77,9 @@ public void parseRequestConfig( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - parsedModelListener.onResponse(new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings)); + parsedModelListener.onResponse( + new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion) + ); } @Override 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 d001e07d0d3db..3c1939e78881f 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 @@ -126,7 +126,8 @@ public void testGetModel() throws Exception { modelHolder.get().inferenceEntityId(), modelHolder.get().taskType(), modelHolder.get().settings(), - modelHolder.get().secrets() + modelHolder.get().secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertEquals(model, roundTripModel); } @@ -181,11 +182,21 @@ public void testDeleteModel() throws Exception { public void testGetModelsByTaskType() throws InterruptedException { var service = "foo"; var sparseAndTextEmbeddingModels = new ArrayList(); - sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service)); - sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service)); - sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service)); - sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service)); - sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service)); + sparseAndTextEmbeddingModels.add( + createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + ); + sparseAndTextEmbeddingModels.add( + createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + ); + sparseAndTextEmbeddingModels.add( + createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + ); + sparseAndTextEmbeddingModels.add( + createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + ); + sparseAndTextEmbeddingModels.add( + createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + ); for (var model : sparseAndTextEmbeddingModels) { AtomicReference putModelHolder = new AtomicReference<>(); @@ -229,7 +240,12 @@ public void testGetAllModels() throws InterruptedException { AtomicReference exceptionHolder = new AtomicReference<>(); for (int i = 0; i < modelCount; i++) { - var model = createModel(randomAlphaOfLength(5), randomFrom(TaskType.values()), service); + var model = createModel( + randomAlphaOfLength(5), + randomFrom(TaskType.values()), + service, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); createdModels.add(model); blockingCall(listener -> modelRegistry.storeModel(model, listener), putModelHolder, exceptionHolder); @@ -262,7 +278,13 @@ public void testGetModelWithSecrets() throws InterruptedException { AtomicReference putModelHolder = new AtomicReference<>(); AtomicReference exceptionHolder = new AtomicReference<>(); - var modelWithSecrets = createModelWithSecrets(inferenceEntityId, randomFrom(TaskType.values()), service, secret); + var modelWithSecrets = createModelWithSecrets( + inferenceEntityId, + randomFrom(TaskType.values()), + service, + secret, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); blockingCall(listener -> modelRegistry.storeModel(modelWithSecrets, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); assertNull(exceptionHolder.get()); @@ -290,7 +312,10 @@ public void testGetAllModels_WithDefaults() throws Exception { var defaultConfigs = new HashMap(); for (int i = 0; i < defaultModelCount; i++) { var id = "default-" + i; - defaultConfigs.put(id, createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret)); + defaultConfigs.put( + id, + createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret, ModelConfigurations.FIRST_ENDPOINT_VERSION) + ); } defaultConfigs.values().forEach(modelRegistry::addDefaultConfiguration); @@ -300,7 +325,7 @@ public void testGetAllModels_WithDefaults() throws Exception { var createdModels = new HashMap(); for (int i = 0; i < configuredModelCount; i++) { var id = randomAlphaOfLength(5) + i; - var model = createModel(id, randomFrom(TaskType.values()), service); + var model = createModel(id, randomFrom(TaskType.values()), service, ModelConfigurations.FIRST_ENDPOINT_VERSION); createdModels.put(id, model); blockingCall(listener -> modelRegistry.storeModel(model, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); @@ -339,7 +364,10 @@ public void testGetAllModels_OnlyDefaults() throws Exception { var defaultConfigs = new HashMap(); for (int i = 0; i < defaultModelCount; i++) { var id = "default-" + i; - defaultConfigs.put(id, createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret)); + defaultConfigs.put( + id, + createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret, ModelConfigurations.FIRST_ENDPOINT_VERSION) + ); } defaultConfigs.values().forEach(modelRegistry::addDefaultConfiguration); @@ -366,8 +394,20 @@ public void testGet_WithDefaults() throws InterruptedException { var service = "foo"; var secret = "abc"; - var defaultSparse = createUnparsedConfig("default-sparse", TaskType.SPARSE_EMBEDDING, service, secret); - var defaultText = createUnparsedConfig("default-text", TaskType.TEXT_EMBEDDING, service, secret); + var defaultSparse = createUnparsedConfig( + "default-sparse", + TaskType.SPARSE_EMBEDDING, + service, + secret, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); + var defaultText = createUnparsedConfig( + "default-text", + TaskType.TEXT_EMBEDDING, + service, + secret, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); modelRegistry.addDefaultConfiguration(defaultSparse); modelRegistry.addDefaultConfiguration(defaultText); @@ -375,8 +415,18 @@ public void testGet_WithDefaults() throws InterruptedException { AtomicReference putModelHolder = new AtomicReference<>(); AtomicReference exceptionHolder = new AtomicReference<>(); - var configured1 = createModel(randomAlphaOfLength(5) + 1, randomFrom(TaskType.values()), service); - var configured2 = createModel(randomAlphaOfLength(5) + 1, randomFrom(TaskType.values()), service); + var configured1 = createModel( + randomAlphaOfLength(5) + 1, + randomFrom(TaskType.values()), + service, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); + var configured2 = createModel( + randomAlphaOfLength(5) + 1, + randomFrom(TaskType.values()), + service, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); blockingCall(listener -> modelRegistry.storeModel(configured1, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); blockingCall(listener -> modelRegistry.storeModel(configured2, listener), putModelHolder, exceptionHolder); @@ -402,9 +452,27 @@ public void testGetByTaskType_WithDefaults() throws Exception { var service = "foo"; var secret = "abc"; - var defaultSparse = createUnparsedConfig("default-sparse", TaskType.SPARSE_EMBEDDING, service, secret); - var defaultText = createUnparsedConfig("default-text", TaskType.TEXT_EMBEDDING, service, secret); - var defaultChat = createUnparsedConfig("default-chat", TaskType.COMPLETION, service, secret); + var defaultSparse = createUnparsedConfig( + "default-sparse", + TaskType.SPARSE_EMBEDDING, + service, + secret, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); + var defaultText = createUnparsedConfig( + "default-text", + TaskType.TEXT_EMBEDDING, + service, + secret, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); + var defaultChat = createUnparsedConfig( + "default-chat", + TaskType.COMPLETION, + service, + secret, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); modelRegistry.addDefaultConfiguration(defaultSparse); modelRegistry.addDefaultConfiguration(defaultText); @@ -413,9 +481,14 @@ public void testGetByTaskType_WithDefaults() throws Exception { AtomicReference putModelHolder = new AtomicReference<>(); AtomicReference exceptionHolder = new AtomicReference<>(); - var configuredSparse = createModel("configured-sparse", TaskType.SPARSE_EMBEDDING, service); - var configuredText = createModel("configured-text", TaskType.TEXT_EMBEDDING, service); - var configuredRerank = createModel("configured-rerank", TaskType.RERANK, service); + var configuredSparse = createModel( + "configured-sparse", + TaskType.SPARSE_EMBEDDING, + service, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); + var configuredText = createModel("configured-text", TaskType.TEXT_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION); + var configuredRerank = createModel("configured-rerank", TaskType.RERANK, service, ModelConfigurations.FIRST_ENDPOINT_VERSION); blockingCall(listener -> modelRegistry.storeModel(configuredSparse, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); blockingCall(listener -> modelRegistry.storeModel(configuredText, listener), putModelHolder, exceptionHolder); @@ -483,7 +556,8 @@ private Model buildElserModelConfig(String inferenceEntityId, TaskType taskType) taskType, ElasticsearchInternalService.NAME, ElserInternalServiceSettingsTests.createRandom(), - ElserMlNodeTaskSettingsTests.createRandom() + ElserMlNodeTaskSettingsTests.createRandom(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); default -> throw new IllegalArgumentException("task type " + taskType + " is not supported"); }; @@ -512,24 +586,58 @@ private static Model buildModelWithUnknownField(String inferenceEntityId) { TaskType.SPARSE_EMBEDDING, ElasticsearchInternalService.NAME, ElserInternalServiceSettingsTests.createRandom(), - ElserMlNodeTaskSettingsTests.createRandom() + ElserMlNodeTaskSettingsTests.createRandom(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ); } - 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 service, String endpointVersion) { + return new Model( + new ModelConfigurations( + inferenceEntityId, + taskType, + service, + new TestModelOfAnyKind.TestModelServiceSettings(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) + ); } - public static Model createModelWithSecrets(String inferenceEntityId, TaskType taskType, String service, String secret) { + public static Model createModelWithSecrets( + String inferenceEntityId, + TaskType taskType, + String service, + String secret, + String endpointVersion + ) { return new Model( - new ModelConfigurations(inferenceEntityId, taskType, service, new TestModelOfAnyKind.TestModelServiceSettings()), + new ModelConfigurations( + inferenceEntityId, + taskType, + service, + new TestModelOfAnyKind.TestModelServiceSettings(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ), new ModelSecrets(new TestModelOfAnyKind.TestSecretSettings(secret)) ); } - public static UnparsedModel createUnparsedConfig(String inferenceEntityId, TaskType taskType, String service, String secret) { - return new UnparsedModel(inferenceEntityId, taskType, service, Map.of("a", "b"), Map.of("secret", secret)); + public static UnparsedModel createUnparsedConfig( + String inferenceEntityId, + TaskType taskType, + String service, + String secret, + String endpointVersion + ) { + return new UnparsedModel( + inferenceEntityId, + taskType, + service, + Map.of("a", "b"), + Map.of("secret", secret), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } private static class TestModelOfAnyKind extends ModelConfigurations { @@ -619,8 +727,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws } } - TestModelOfAnyKind(String inferenceEntityId, TaskType taskType, String service) { - super(inferenceEntityId, taskType, service, new TestModelServiceSettings(), new TestTaskSettings()); + TestModelOfAnyKind(String inferenceEntityId, TaskType taskType, String service, String endpointVersion) { + super(inferenceEntityId, taskType, service, new TestModelServiceSettings(), new TestTaskSettings(), endpointVersion); } @Override @@ -644,9 +752,10 @@ private static class ModelWithUnknownField extends ModelConfigurations { TaskType taskType, String service, ServiceSettings serviceSettings, - TaskSettings taskSettings + TaskSettings taskSettings, + String endpointVersion ) { - super(inferenceEntityId, taskType, service, serviceSettings, taskSettings); + super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java index 5ee1e40869dbc..1a3447ba86305 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java @@ -95,7 +95,12 @@ private void getSingleModel( } var model = service.get() - .parsePersistedConfig(unparsedModel.inferenceEntityId(), unparsedModel.taskType(), unparsedModel.settings()); + .parsePersistedConfig( + unparsedModel.inferenceEntityId(), + unparsedModel.taskType(), + unparsedModel.settings(), + unparsedModel.endpointVersion() + ); delegate.onResponse(new GetInferenceModelAction.Response(List.of(model.getConfigurations()))); })); } @@ -123,7 +128,12 @@ private GetInferenceModelAction.Response parseModels(List unparse } parsedModels.add( service.get() - .parsePersistedConfig(unparsedModel.inferenceEntityId(), unparsedModel.taskType(), unparsedModel.settings()) + .parsePersistedConfig( + unparsedModel.inferenceEntityId(), + unparsedModel.taskType(), + unparsedModel.settings(), + unparsedModel.endpointVersion() + ) .getConfigurations() ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceAction.java index e046e2aad463b..b50e3fbbaf638 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceAction.java @@ -81,7 +81,8 @@ protected void doExecute(Task task, InferenceAction.Request request, ActionListe unparsedModel.inferenceEntityId(), unparsedModel.taskType(), unparsedModel.settings(), - unparsedModel.secrets() + unparsedModel.secrets(), + unparsedModel.endpointVersion() ); inferOnService(model, request, service.get(), delegate); }); 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..7ca2ca486d4c9 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 @@ -195,7 +195,9 @@ private void parseAndStoreModel( } }); - service.parseRequestConfig(inferenceEntityId, taskType, config, parsedModelListener); + String endpointVersion = (String) config.remove(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME); + + service.parseRequestConfig(inferenceEntityId, taskType, config, endpointVersion, parsedModelListener); } private void startInferenceEndpoint(InferenceService service, Model model, ActionListener listener) { @@ -210,7 +212,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/action/filter/ShardBulkInferenceActionFilter.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java index a4eb94c2674d1..bb42bf59252d3 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java @@ -224,7 +224,8 @@ public void onResponse(UnparsedModel unparsedModel) { inferenceId, unparsedModel.taskType(), unparsedModel.settings(), - unparsedModel.secrets() + unparsedModel.secrets(), + unparsedModel.endpointVersion() ) ); executeShardBulkInferenceAsync(inferenceId, provider, requests, onFinish); 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 c6a5019783507..e685a031f40dc 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 @@ -53,6 +53,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; @@ -72,8 +73,13 @@ public static UnparsedModel unparsedModelFromMap(ModelConfigMap modelConfigMap) String service = ServiceUtils.removeStringOrThrowIfNull(modelConfigMap.config(), ModelConfigurations.SERVICE); String taskTypeStr = ServiceUtils.removeStringOrThrowIfNull(modelConfigMap.config(), TaskType.NAME); TaskType taskType = TaskType.fromString(taskTypeStr); + String endpointVersion = (String) Objects.requireNonNullElse( + modelConfigMap.config().remove(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME), + ModelConfigurations.FIRST_ENDPOINT_VERSION // TODO in 9.0 change this to require the field, once we have updated all of the + // stored models + ); - return new UnparsedModel(inferenceEntityId, taskType, service, modelConfigMap.config(), modelConfigMap.secrets()); + return new UnparsedModel(inferenceEntityId, taskType, service, modelConfigMap.config(), modelConfigMap.secrets(), endpointVersion); } private static final String TASK_TYPE_FIELD = "task_type"; @@ -446,7 +452,8 @@ static UnparsedModel deepCopyDefaultConfig(UnparsedModel other) { other.taskType(), other.service(), copySettingsMap(other.settings()), - copySecretsMap(other.secrets()) + copySecretsMap(other.secrets()), + other.endpointVersion() ); } @@ -460,10 +467,10 @@ static Map copySettingsMap(Map other) { result.put(ModelConfigurations.SERVICE_SETTINGS, copiedServiceSettings); } - var taskSettings = (Map) other.get(ModelConfigurations.TASK_SETTINGS); + var taskSettings = (Map) other.get(ModelConfigurations.OLD_TASK_SETTINGS); if (taskSettings != null) { var copiedTaskSettings = copyMap1LevelDeep(taskSettings); - result.put(ModelConfigurations.TASK_SETTINGS, copiedTaskSettings); + result.put(ModelConfigurations.OLD_TASK_SETTINGS, copiedTaskSettings); } var chunkSettings = (Map) other.get(ModelConfigurations.CHUNKING_SETTINGS); @@ -472,6 +479,11 @@ static Map copySettingsMap(Map other) { result.put(ModelConfigurations.CHUNKING_SETTINGS, copiedChunkSettings); } + var endpointVersion = (String) other.get(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME); + if (endpointVersion != null) { + result.put(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME, endpointVersion); + } + return result; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java index 709973115cefa..92261b0e4747b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java @@ -68,6 +68,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -81,7 +82,8 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -100,7 +102,8 @@ private static AlibabaCloudSearchModel createModelWithoutLoggingDeprecations( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -109,7 +112,8 @@ private static AlibabaCloudSearchModel createModelWithoutLoggingDeprecations( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @@ -120,7 +124,8 @@ private static AlibabaCloudSearchModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new AlibabaCloudSearchEmbeddingsModel( @@ -130,7 +135,8 @@ private static AlibabaCloudSearchModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); case SPARSE_EMBEDDING -> new AlibabaCloudSearchSparseModel( inferenceEntityId, @@ -139,7 +145,8 @@ private static AlibabaCloudSearchModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); case RERANK -> new AlibabaCloudSearchRerankModel( inferenceEntityId, @@ -148,7 +155,8 @@ private static AlibabaCloudSearchModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); case COMPLETION -> new AlibabaCloudSearchCompletionModel( inferenceEntityId, @@ -157,7 +165,8 @@ private static AlibabaCloudSearchModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -168,7 +177,8 @@ public AlibabaCloudSearchModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -180,12 +190,18 @@ public AlibabaCloudSearchModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @Override - public AlibabaCloudSearchModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public AlibabaCloudSearchModel parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + String endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -195,7 +211,8 @@ public AlibabaCloudSearchModel parsePersistedConfig(String inferenceEntityId, Ta serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java index f5140981bfbe0..73a847444e78b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java @@ -36,7 +36,8 @@ public AlibabaCloudSearchCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( modelId, @@ -44,7 +45,8 @@ public AlibabaCloudSearchCompletionModel( service, AlibabaCloudSearchCompletionServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchCompletionTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -55,10 +57,11 @@ public AlibabaCloudSearchCompletionModel( String service, AlibabaCloudSearchCompletionServiceSettings serviceSettings, AlibabaCloudSearchCompletionTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings + @Nullable DefaultSecretSettings secretSettings, + String endpointVersion ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java index 87e5e59ae3434..582596133ce67 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java @@ -40,7 +40,8 @@ public AlibabaCloudSearchEmbeddingsModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( modelId, @@ -48,7 +49,8 @@ public AlibabaCloudSearchEmbeddingsModel( service, AlibabaCloudSearchEmbeddingsServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchEmbeddingsTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -59,10 +61,11 @@ public AlibabaCloudSearchEmbeddingsModel( String service, AlibabaCloudSearchEmbeddingsServiceSettings serviceSettings, AlibabaCloudSearchEmbeddingsTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings + @Nullable DefaultSecretSettings secretSettings, + String endpointVersion ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java index a9152b6edd4c5..af89a2532267d 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java @@ -36,7 +36,8 @@ public AlibabaCloudSearchRerankModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( modelId, @@ -44,7 +45,8 @@ public AlibabaCloudSearchRerankModel( service, AlibabaCloudSearchRerankServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchRerankTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -55,10 +57,11 @@ public AlibabaCloudSearchRerankModel( String service, AlibabaCloudSearchRerankServiceSettings serviceSettings, AlibabaCloudSearchRerankTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings + @Nullable DefaultSecretSettings secretSettings, + String endpointVersion ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java index b551ba389136b..e829efd249224 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java @@ -40,7 +40,8 @@ public AlibabaCloudSearchSparseModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( modelId, @@ -48,7 +49,8 @@ public AlibabaCloudSearchSparseModel( service, AlibabaCloudSearchSparseServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchSparseTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -59,10 +61,11 @@ public AlibabaCloudSearchSparseModel( String service, AlibabaCloudSearchSparseServiceSettings serviceSettings, AlibabaCloudSearchSparseTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings + @Nullable DefaultSecretSettings secretSettings, + String endpointVersion ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java index 5264133f76402..2f9839c838d36 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java @@ -120,6 +120,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -133,7 +134,8 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -151,7 +153,8 @@ public Model parsePersistedConfigWithSecrets( String modelId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -164,12 +167,13 @@ public Model parsePersistedConfigWithSecrets( taskSettingsMap, secretSettingsMap, parsePersistedConfigErrorMsg(modelId, NAME), - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @Override - public Model parsePersistedConfig(String modelId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, String endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -180,7 +184,8 @@ public Model parsePersistedConfig(String modelId, TaskType taskType, Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { switch (taskType) { case TEXT_EMBEDDING -> { @@ -202,7 +208,8 @@ private static AmazonBedrockModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); checkProviderForTask(TaskType.TEXT_EMBEDDING, model.provider()); return model; @@ -215,7 +222,8 @@ private static AmazonBedrockModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); checkProviderForTask(TaskType.COMPLETION, model.provider()); checkChatCompletionProviderForTopKParameter(model); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java index 27dc607d671aa..7667a99c35a4e 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java @@ -39,7 +39,8 @@ public AmazonBedrockChatCompletionModel( Map serviceSettings, Map taskSettings, Map secretSettings, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -47,7 +48,8 @@ public AmazonBedrockChatCompletionModel( name, AmazonBedrockChatCompletionServiceSettings.fromMap(serviceSettings, context), AmazonBedrockChatCompletionTaskSettings.fromMap(taskSettings), - AmazonBedrockSecretSettings.fromMap(secretSettings) + AmazonBedrockSecretSettings.fromMap(secretSettings), + endpointVersion ); } @@ -57,9 +59,13 @@ public AmazonBedrockChatCompletionModel( String service, AmazonBedrockChatCompletionServiceSettings serviceSettings, AmazonBedrockChatCompletionTaskSettings taskSettings, - AmazonBedrockSecretSettings secrets + AmazonBedrockSecretSettings secrets, + String endpointVersion ) { - super(new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets)); + super( + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelSecrets(secrets) + ); } public AmazonBedrockChatCompletionModel(Model model, TaskSettings taskSettings) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java index 0e3a954a03279..164d73126d947 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java @@ -43,7 +43,8 @@ public AmazonBedrockEmbeddingsModel( Map serviceSettings, Map taskSettings, Map secretSettings, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -51,7 +52,8 @@ public AmazonBedrockEmbeddingsModel( service, AmazonBedrockEmbeddingsServiceSettings.fromMap(serviceSettings, context), new EmptyTaskSettings(), - AmazonBedrockSecretSettings.fromMap(secretSettings) + AmazonBedrockSecretSettings.fromMap(secretSettings), + endpointVersion ); } @@ -61,10 +63,11 @@ public AmazonBedrockEmbeddingsModel( String service, AmazonBedrockEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, - AmazonBedrockSecretSettings secrets + AmazonBedrockSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, new EmptyTaskSettings()), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, new EmptyTaskSettings(), endpointVersion), new ModelSecrets(secrets) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java index df8cea770bf94..9da999428abeb 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java @@ -57,6 +57,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -70,7 +71,8 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -89,7 +91,8 @@ private static AnthropicModel createModelFromPersistent( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -98,7 +101,8 @@ private static AnthropicModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @@ -109,7 +113,8 @@ private static AnthropicModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { case COMPLETION -> new AnthropicChatCompletionModel( @@ -119,7 +124,8 @@ private static AnthropicModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -130,7 +136,8 @@ public AnthropicModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -142,12 +149,18 @@ public AnthropicModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @Override - public AnthropicModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public AnthropicModel parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + String endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -157,7 +170,8 @@ public AnthropicModel parsePersistedConfig(String inferenceEntityId, TaskType ta serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java index 942cae8960daf..8626edd173585 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java @@ -45,7 +45,8 @@ public AnthropicChatCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -53,7 +54,8 @@ public AnthropicChatCompletionModel( service, AnthropicChatCompletionServiceSettings.fromMap(serviceSettings, context), AnthropicChatCompletionTaskSettings.fromMap(taskSettings, context), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -63,10 +65,11 @@ public AnthropicChatCompletionModel( String service, AnthropicChatCompletionServiceSettings serviceSettings, AnthropicChatCompletionTaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings, AnthropicChatCompletionModel::buildDefaultUri, @@ -82,10 +85,11 @@ public AnthropicChatCompletionModel( String url, AnthropicChatCompletionServiceSettings serviceSettings, AnthropicChatCompletionTaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings, () -> ServiceUtils.createUri(url), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java index 84c357ba8bda8..fe6c93c150311 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java @@ -109,6 +109,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -122,7 +123,8 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -140,7 +142,8 @@ public AzureAiStudioModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -152,12 +155,13 @@ public AzureAiStudioModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -167,7 +171,8 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @@ -188,7 +193,8 @@ private static AzureAiStudioModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { if (taskType == TaskType.TEXT_EMBEDDING) { @@ -199,7 +205,8 @@ private static AzureAiStudioModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); checkProviderAndEndpointTypeForTask( TaskType.TEXT_EMBEDDING, @@ -217,7 +224,8 @@ private static AzureAiStudioModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); checkProviderAndEndpointTypeForTask( TaskType.COMPLETION, @@ -236,7 +244,8 @@ private AzureAiStudioModel createModelFromPersistent( Map serviceSettings, Map taskSettings, Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -245,7 +254,8 @@ private AzureAiStudioModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java index 5afb3aaed61ff..ceb0fad59ae25 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java @@ -46,9 +46,13 @@ public AzureAiStudioChatCompletionModel( String service, AzureAiStudioChatCompletionServiceSettings serviceSettings, AzureAiStudioChatCompletionTaskSettings taskSettings, - DefaultSecretSettings secrets + DefaultSecretSettings secrets, + String endpointVersion ) { - super(new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets)); + super( + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelSecrets(secrets) + ); } public AzureAiStudioChatCompletionModel( @@ -58,7 +62,8 @@ public AzureAiStudioChatCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -66,7 +71,8 @@ public AzureAiStudioChatCompletionModel( service, AzureAiStudioChatCompletionServiceSettings.fromMap(serviceSettings, context), AzureAiStudioChatCompletionTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java index a999b9f0312e6..9f186dcdd5cf9 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java @@ -44,9 +44,13 @@ public AzureAiStudioEmbeddingsModel( String service, AzureAiStudioEmbeddingsServiceSettings serviceSettings, AzureAiStudioEmbeddingsTaskSettings taskSettings, - DefaultSecretSettings secrets + DefaultSecretSettings secrets, + String endpointVersion ) { - super(new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets)); + super( + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelSecrets(secrets) + ); } public AzureAiStudioEmbeddingsModel( @@ -56,7 +60,8 @@ public AzureAiStudioEmbeddingsModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -64,7 +69,8 @@ public AzureAiStudioEmbeddingsModel( service, AzureAiStudioEmbeddingsServiceSettings.fromMap(serviceSettings, context), AzureAiStudioEmbeddingsTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java index 24d62464f08cd..db1273e309512 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java @@ -64,6 +64,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -77,7 +78,8 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -96,7 +98,8 @@ private static AzureOpenAiModel createModelFromPersistent( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -105,7 +108,8 @@ private static AzureOpenAiModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @@ -116,7 +120,8 @@ private static AzureOpenAiModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { switch (taskType) { case TEXT_EMBEDDING -> { @@ -127,7 +132,8 @@ private static AzureOpenAiModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); } case COMPLETION -> { @@ -138,7 +144,8 @@ private static AzureOpenAiModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); } default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); @@ -150,7 +157,8 @@ public AzureOpenAiModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -162,12 +170,18 @@ public AzureOpenAiModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @Override - public AzureOpenAiModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public AzureOpenAiModel parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + String endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -177,7 +191,8 @@ public AzureOpenAiModel parsePersistedConfig(String inferenceEntityId, TaskType serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java index c4146b2ba2d30..f2540b69b8273 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java @@ -39,7 +39,8 @@ public AzureOpenAiCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -47,7 +48,8 @@ public AzureOpenAiCompletionModel( service, AzureOpenAiCompletionServiceSettings.fromMap(serviceSettings, context), AzureOpenAiCompletionTaskSettings.fromMap(taskSettings), - AzureOpenAiSecretSettings.fromMap(secrets) + AzureOpenAiSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -58,10 +60,11 @@ public AzureOpenAiCompletionModel( String service, AzureOpenAiCompletionServiceSettings serviceSettings, AzureOpenAiCompletionTaskSettings taskSettings, - @Nullable AzureOpenAiSecretSettings secrets + @Nullable AzureOpenAiSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java index 377bb33f58619..f1d49d62e8d1b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java @@ -39,7 +39,8 @@ public AzureOpenAiEmbeddingsModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -47,7 +48,8 @@ public AzureOpenAiEmbeddingsModel( service, AzureOpenAiEmbeddingsServiceSettings.fromMap(serviceSettings, context), AzureOpenAiEmbeddingsTaskSettings.fromMap(taskSettings), - AzureOpenAiSecretSettings.fromMap(secrets) + AzureOpenAiSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -58,10 +60,11 @@ public AzureOpenAiEmbeddingsModel( String service, AzureOpenAiEmbeddingsServiceSettings serviceSettings, AzureOpenAiEmbeddingsTaskSettings taskSettings, - @Nullable AzureOpenAiSecretSettings secrets + @Nullable AzureOpenAiSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java index 212cf756dd206..21d2d2aa0782e 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java @@ -69,6 +69,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -82,7 +83,8 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -101,7 +103,8 @@ private static CohereModel createModelWithoutLoggingDeprecations( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -110,7 +113,8 @@ private static CohereModel createModelWithoutLoggingDeprecations( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @@ -121,7 +125,8 @@ private static CohereModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new CohereEmbeddingsModel( @@ -131,9 +136,19 @@ private static CohereModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion + ); + case RERANK -> new CohereRerankModel( + inferenceEntityId, + taskType, + NAME, + serviceSettings, + taskSettings, + secretSettings, + context, + endpointVersion ); - case RERANK -> new CohereRerankModel(inferenceEntityId, taskType, NAME, serviceSettings, taskSettings, secretSettings, context); case COMPLETION -> new CohereCompletionModel( inferenceEntityId, taskType, @@ -141,7 +156,8 @@ private static CohereModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -152,7 +168,8 @@ public CohereModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -164,12 +181,18 @@ public CohereModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @Override - public CohereModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public CohereModel parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + String endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -179,7 +202,8 @@ public CohereModel parsePersistedConfig(String inferenceEntityId, TaskType taskT serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java index bec4f5a0b5c85..3d79b215bd5ba 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java @@ -32,7 +32,8 @@ public CohereCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( modelId, @@ -40,7 +41,8 @@ public CohereCompletionModel( service, CohereCompletionServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -51,10 +53,11 @@ public CohereCompletionModel( String service, CohereCompletionServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings + @Nullable DefaultSecretSettings secretSettings, + String endpointVersion ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secretSettings), secretSettings, serviceSettings diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java index fea5226bf9c6f..653cc3377dfff 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java @@ -34,7 +34,8 @@ public CohereEmbeddingsModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceId, @@ -42,7 +43,8 @@ public CohereEmbeddingsModel( service, CohereEmbeddingsServiceSettings.fromMap(serviceSettings, context), CohereEmbeddingsTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -53,10 +55,11 @@ public CohereEmbeddingsModel( String service, CohereEmbeddingsServiceSettings serviceSettings, CohereEmbeddingsTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings + @Nullable DefaultSecretSettings secretSettings, + String endpointVersion ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secretSettings), secretSettings, serviceSettings.getCommonSettings() diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java index b84b98973bbe5..d513e8dc06216 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java @@ -34,7 +34,8 @@ public CohereRerankModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( modelId, @@ -42,7 +43,8 @@ public CohereRerankModel( service, CohereRerankServiceSettings.fromMap(serviceSettings, context), CohereRerankTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -53,10 +55,11 @@ public CohereRerankModel( String service, CohereRerankServiceSettings serviceSettings, CohereRerankTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings + @Nullable DefaultSecretSettings secretSettings, + String endpointVersion ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secretSettings), secretSettings, serviceSettings diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java index 37c2876b45a15..d5346f8b3e482 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java @@ -116,6 +116,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -130,7 +131,8 @@ public void parseRequestConfig( serviceSettingsMap, elasticInferenceServiceComponents, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -151,7 +153,8 @@ private static ElasticInferenceServiceModel createModel( @Nullable Map secretSettings, ElasticInferenceServiceComponents eisServiceComponents, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { case SPARSE_EMBEDDING -> new ElasticInferenceServiceSparseEmbeddingsModel( @@ -162,7 +165,8 @@ private static ElasticInferenceServiceModel createModel( taskSettings, secretSettings, eisServiceComponents, - context + context, + endpointVersion ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -173,7 +177,8 @@ public Model parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -185,12 +190,13 @@ public Model parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -200,7 +206,8 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @@ -215,7 +222,8 @@ private ElasticInferenceServiceModel createModelFromPersistent( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -225,7 +233,8 @@ private ElasticInferenceServiceModel createModelFromPersistent( secretSettings, elasticInferenceServiceComponents, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java index bbbae736dbeb9..646f7e72318ef 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java @@ -36,7 +36,8 @@ public ElasticInferenceServiceSparseEmbeddingsModel( Map taskSettings, Map secrets, ElasticInferenceServiceComponents elasticInferenceServiceComponents, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -45,7 +46,8 @@ public ElasticInferenceServiceSparseEmbeddingsModel( ElasticInferenceServiceSparseEmbeddingsServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, EmptySecretSettings.INSTANCE, - elasticInferenceServiceComponents + elasticInferenceServiceComponents, + endpointVersion ); } @@ -69,10 +71,11 @@ public ElasticInferenceServiceSparseEmbeddingsModel( ElasticInferenceServiceSparseEmbeddingsServiceSettings serviceSettings, @Nullable TaskSettings taskSettings, @Nullable SecretSettings secretSettings, - ElasticInferenceServiceComponents elasticInferenceServiceComponents + ElasticInferenceServiceComponents elasticInferenceServiceComponents, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secretSettings), serviceSettings, elasticInferenceServiceComponents diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java index 59203d00e589a..fbd0d55c5daa1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java @@ -15,9 +15,10 @@ public CustomElandEmbeddingModel( String inferenceEntityId, TaskType taskType, String service, - CustomElandInternalTextEmbeddingServiceSettings serviceSettings + CustomElandInternalTextEmbeddingServiceSettings serviceSettings, + String endpointVersion ) { - super(inferenceEntityId, taskType, service, serviceSettings); + super(inferenceEntityId, taskType, service, serviceSettings, endpointVersion); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java index 83f22f08b620d..4765f105cc63e 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java @@ -21,9 +21,10 @@ public CustomElandModel( String inferenceEntityId, TaskType taskType, String service, - ElasticsearchInternalServiceSettings internalServiceSettings + ElasticsearchInternalServiceSettings internalServiceSettings, + String endpointVersion ) { - super(inferenceEntityId, taskType, service, internalServiceSettings); + super(inferenceEntityId, taskType, service, internalServiceSettings, endpointVersion); } public CustomElandModel( @@ -31,9 +32,10 @@ public CustomElandModel( TaskType taskType, String service, ElasticsearchInternalServiceSettings internalServiceSettings, - TaskSettings taskSettings + TaskSettings taskSettings, + String endpointVersion ) { - super(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings); + super(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings, endpointVersion); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java index 63f4a3dbf8472..f39487a5081c2 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java @@ -16,9 +16,10 @@ public CustomElandRerankModel( TaskType taskType, String service, CustomElandInternalServiceSettings serviceSettings, - CustomElandRerankTaskSettings taskSettings + CustomElandRerankTaskSettings taskSettings, + String endpointVersion ) { - super(inferenceEntityId, taskType, service, serviceSettings, taskSettings); + super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java index 07d0cc14b2ac8..c7e75f0b7aab0 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java @@ -26,9 +26,10 @@ public ElasticsearchInternalModel( String inferenceEntityId, TaskType taskType, String service, - ElasticsearchInternalServiceSettings internalServiceSettings + ElasticsearchInternalServiceSettings internalServiceSettings, + String endpointVersion ) { - super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings)); + super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings, endpointVersion)); this.internalServiceSettings = internalServiceSettings; } @@ -37,9 +38,10 @@ public ElasticsearchInternalModel( TaskType taskType, String service, ElasticsearchInternalServiceSettings internalServiceSettings, - TaskSettings taskSettings + TaskSettings taskSettings, + String endpointVersion ) { - super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings)); + super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings, endpointVersion)); this.internalServiceSettings = internalServiceSettings; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java index 2c9d04ac16f61..422a3e0a27c79 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java @@ -101,6 +101,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener modelListener ) { if (inferenceEntityId.equals(DEFAULT_ELSER_ID)) { @@ -134,7 +135,15 @@ public void parseRequestConfig( ); platformArch.accept( modelListener.delegateFailureAndWrap( - (delegate, arch) -> elserCase(inferenceEntityId, taskType, config, arch, serviceSettingsMap, modelListener) + (delegate, arch) -> elserCase( + inferenceEntityId, + taskType, + config, + arch, + serviceSettingsMap, + modelListener, + endpointVersion + ) ) ); } else { @@ -143,17 +152,33 @@ public void parseRequestConfig( } else if (MULTILINGUAL_E5_SMALL_VALID_IDS.contains(modelId)) { platformArch.accept( modelListener.delegateFailureAndWrap( - (delegate, arch) -> e5Case(inferenceEntityId, taskType, config, arch, serviceSettingsMap, modelListener) + (delegate, arch) -> e5Case( + inferenceEntityId, + taskType, + config, + arch, + serviceSettingsMap, + modelListener, + endpointVersion + ) ) ); } else if (ElserModels.isValidModel(modelId)) { platformArch.accept( modelListener.delegateFailureAndWrap( - (delegate, arch) -> elserCase(inferenceEntityId, taskType, config, arch, serviceSettingsMap, modelListener) + (delegate, arch) -> elserCase( + inferenceEntityId, + taskType, + config, + arch, + serviceSettingsMap, + modelListener, + endpointVersion + ) ) ); } else { - customElandCase(inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, modelListener); + customElandCase(inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, modelListener, endpointVersion); } } catch (Exception e) { modelListener.onFailure(e); @@ -165,7 +190,8 @@ private void customElandCase( TaskType taskType, Map serviceSettingsMap, Map taskSettingsMap, - ActionListener modelListener + ActionListener modelListener, + String endpointVersion ) { String modelId = (String) serviceSettingsMap.get(ElasticsearchInternalServiceSettings.MODEL_ID); var request = new GetTrainedModelsAction.Request(modelId); @@ -183,7 +209,8 @@ private void customElandCase( taskType, serviceSettingsMap, taskSettingsMap, - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(serviceSettingsMap, name()); @@ -201,7 +228,8 @@ private static CustomElandModel createCustomElandModel( TaskType taskType, Map serviceSettings, Map taskSettings, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { @@ -209,20 +237,23 @@ private static CustomElandModel createCustomElandModel( inferenceEntityId, taskType, NAME, - CustomElandInternalTextEmbeddingServiceSettings.fromMap(serviceSettings, context) + CustomElandInternalTextEmbeddingServiceSettings.fromMap(serviceSettings, context), + endpointVersion ); case SPARSE_EMBEDDING -> new CustomElandModel( inferenceEntityId, taskType, NAME, - elandServiceSettings(serviceSettings, context) + elandServiceSettings(serviceSettings, context), + endpointVersion ); case RERANK -> new CustomElandRerankModel( inferenceEntityId, taskType, NAME, elandServiceSettings(serviceSettings, context), - CustomElandRerankTaskSettings.fromMap(taskSettings) + CustomElandRerankTaskSettings.fromMap(taskSettings), + endpointVersion ); default -> throw new ElasticsearchStatusException(TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), RestStatus.BAD_REQUEST); }; @@ -246,7 +277,8 @@ private void e5Case( Map config, Set platformArchitectures, Map serviceSettingsMap, - ActionListener modelListener + ActionListener modelListener, + String endpointVersion ) { var esServiceSettingsBuilder = ElasticsearchInternalServiceSettings.fromRequestMap(serviceSettingsMap); @@ -274,7 +306,8 @@ private void e5Case( inferenceEntityId, taskType, NAME, - new MultilingualE5SmallInternalServiceSettings(esServiceSettingsBuilder.build()) + new MultilingualE5SmallInternalServiceSettings(esServiceSettingsBuilder.build()), + endpointVersion ) ); } @@ -299,7 +332,8 @@ private void elserCase( Map config, Set platformArchitectures, Map serviceSettingsMap, - ActionListener modelListener + ActionListener modelListener, + String endpointVersion ) { var esServiceSettingsBuilder = ElasticsearchInternalServiceSettings.fromRequestMap(serviceSettingsMap); final String defaultModelId = selectDefaultModelVariantBasedOnClusterArchitecture( @@ -355,7 +389,8 @@ private void elserCase( taskType, NAME, new ElserInternalServiceSettings(esServiceSettingsBuilder.build()), - ElserMlNodeTaskSettings.DEFAULT + ElserMlNodeTaskSettings.DEFAULT, + endpointVersion ) ); } @@ -378,13 +413,14 @@ public Model parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { - return parsePersistedConfig(inferenceEntityId, taskType, config); + return parsePersistedConfig(inferenceEntityId, taskType, config, endpointVersion); } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMap(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -398,7 +434,8 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M inferenceEntityId, taskType, NAME, - new MultilingualE5SmallInternalServiceSettings(ElasticsearchInternalServiceSettings.fromPersistedMap(serviceSettingsMap)) + new MultilingualE5SmallInternalServiceSettings(ElasticsearchInternalServiceSettings.fromPersistedMap(serviceSettingsMap)), + endpointVersion ); } else if (ElserModels.isValidModel(modelId)) { return new ElserInternalModel( @@ -406,7 +443,8 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M taskType, NAME, new ElserInternalServiceSettings(ElasticsearchInternalServiceSettings.fromPersistedMap(serviceSettingsMap)), - ElserMlNodeTaskSettings.DEFAULT + ElserMlNodeTaskSettings.DEFAULT, + endpointVersion ); } else { return createCustomElandModel( @@ -414,7 +452,8 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M taskType, serviceSettingsMap, taskSettingsMap, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } } @@ -430,7 +469,8 @@ public void checkModelConfig(Model model, ActionListener listener) { elandModel.getServiceSettings().modelId(), elandModel.getTaskType(), elandModel.getConfigurations().getService(), - elandModel.getServiceSettings() + elandModel.getServiceSettings(), + elandModel.getConfigurations().getEndpointVersion() ); ServiceUtils.getEmbeddingSize( @@ -458,7 +498,8 @@ private static CustomElandEmbeddingModel updateModelWithEmbeddingDetails(CustomE model.getInferenceEntityId(), model.getTaskType(), model.getConfigurations().getService(), - serviceSettings + serviceSettings, + model.getConfigurations().getEndpointVersion() ); } @@ -729,7 +770,8 @@ public List defaultConfigs() { TaskType.SPARSE_EMBEDDING, NAME, elserSettings, - Map.of() // no secrets + Map.of(), // no secrets + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java index 827eb178f7633..4e8d05bcbd547 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java @@ -21,9 +21,10 @@ public ElserInternalModel( TaskType taskType, String service, ElserInternalServiceSettings serviceSettings, - ElserMlNodeTaskSettings taskSettings + ElserMlNodeTaskSettings taskSettings, + String endpointVersion ) { - super(inferenceEntityId, taskType, service, serviceSettings, taskSettings); + super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java index 59e5e9c1550c5..63c72684827c9 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java @@ -20,9 +20,10 @@ public MultilingualE5SmallModel( String inferenceEntityId, TaskType taskType, String service, - MultilingualE5SmallInternalServiceSettings serviceSettings + MultilingualE5SmallInternalServiceSettings serviceSettings, + String endpointVersion ) { - super(inferenceEntityId, taskType, service, serviceSettings); + super(inferenceEntityId, taskType, service, serviceSettings, endpointVersion); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java index 0a5997a2a3037..9927cc273a5a7 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java @@ -68,6 +68,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -89,7 +90,8 @@ public void parseRequestConfig( chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -111,7 +113,8 @@ private static GoogleAiStudioModel createModel( ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { case COMPLETION -> new GoogleAiStudioCompletionModel( @@ -121,7 +124,8 @@ private static GoogleAiStudioModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); case TEXT_EMBEDDING -> new GoogleAiStudioEmbeddingsModel( inferenceEntityId, @@ -131,7 +135,8 @@ private static GoogleAiStudioModel createModel( taskSettings, chunkingSettings, secretSettings, - context + context, + endpointVersion ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -142,7 +147,8 @@ public GoogleAiStudioModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -160,7 +166,8 @@ public GoogleAiStudioModel parsePersistedConfigWithSecrets( taskSettingsMap, chunkingSettings, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @@ -171,7 +178,8 @@ private static GoogleAiStudioModel createModelFromPersistent( Map taskSettings, ChunkingSettings chunkingSettings, Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -181,12 +189,13 @@ private static GoogleAiStudioModel createModelFromPersistent( chunkingSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -202,7 +211,8 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M taskSettingsMap, chunkingSettings, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java index 8fa2ac0148716..41042cb448aa3 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java @@ -39,7 +39,8 @@ public GoogleAiStudioCompletionModel( Map serviceSettings, Map taskSettings, Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -47,7 +48,8 @@ public GoogleAiStudioCompletionModel( service, GoogleAiStudioCompletionServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -58,10 +60,11 @@ public GoogleAiStudioCompletionModel( String service, GoogleAiStudioCompletionServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); @@ -80,10 +83,11 @@ public GoogleAiStudioCompletionModel( String url, GoogleAiStudioCompletionServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java index 5d46a8e129dff..82f53011e131e 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java @@ -41,7 +41,8 @@ public GoogleAiStudioEmbeddingsModel( Map taskSettings, ChunkingSettings chunkingSettings, Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -50,7 +51,8 @@ public GoogleAiStudioEmbeddingsModel( GoogleAiStudioEmbeddingsServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, chunkingSettings, - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -66,10 +68,11 @@ public GoogleAiStudioEmbeddingsModel(GoogleAiStudioEmbeddingsModel model, Google GoogleAiStudioEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, ChunkingSettings chunkingSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); @@ -88,10 +91,11 @@ public GoogleAiStudioEmbeddingsModel(GoogleAiStudioEmbeddingsModel model, Google String uri, GoogleAiStudioEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); @@ -111,10 +115,11 @@ public GoogleAiStudioEmbeddingsModel(GoogleAiStudioEmbeddingsModel model, Google GoogleAiStudioEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, ChunkingSettings chunkingsettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingsettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingsettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java index b8a393c093758..df5132bef4a59 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java @@ -64,6 +64,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parseModelListener ) { try { @@ -77,7 +78,8 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -95,7 +97,8 @@ public Model parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -107,12 +110,13 @@ public Model parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -122,7 +126,8 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @@ -226,7 +231,8 @@ private static GoogleVertexAiModel createModelFromPersistent( Map serviceSettings, Map taskSettings, Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -235,7 +241,8 @@ private static GoogleVertexAiModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @@ -246,7 +253,8 @@ private static GoogleVertexAiModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new GoogleVertexAiEmbeddingsModel( @@ -256,7 +264,8 @@ private static GoogleVertexAiModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); case RERANK -> new GoogleVertexAiRerankModel( inferenceEntityId, @@ -265,7 +274,8 @@ private static GoogleVertexAiModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java index 99110045fc3da..b6670ffa2df08 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java @@ -36,7 +36,8 @@ public GoogleVertexAiEmbeddingsModel( Map serviceSettings, Map taskSettings, Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -44,7 +45,8 @@ public GoogleVertexAiEmbeddingsModel( service, GoogleVertexAiEmbeddingsServiceSettings.fromMap(serviceSettings, context), GoogleVertexAiEmbeddingsTaskSettings.fromMap(taskSettings), - GoogleVertexAiSecretSettings.fromMap(secrets) + GoogleVertexAiSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -59,10 +61,11 @@ public GoogleVertexAiEmbeddingsModel(GoogleVertexAiEmbeddingsModel model, Google String service, GoogleVertexAiEmbeddingsServiceSettings serviceSettings, GoogleVertexAiEmbeddingsTaskSettings taskSettings, - @Nullable GoogleVertexAiSecretSettings secrets + @Nullable GoogleVertexAiSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); @@ -81,10 +84,11 @@ protected GoogleVertexAiEmbeddingsModel( String uri, GoogleVertexAiEmbeddingsServiceSettings serviceSettings, GoogleVertexAiEmbeddingsTaskSettings taskSettings, - @Nullable GoogleVertexAiSecretSettings secrets + @Nullable GoogleVertexAiSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java index 45fad977a2b6b..07f64e7a6a4d4 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java @@ -36,7 +36,8 @@ public GoogleVertexAiRerankModel( Map serviceSettings, Map taskSettings, Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -44,7 +45,8 @@ public GoogleVertexAiRerankModel( service, GoogleVertexAiRerankServiceSettings.fromMap(serviceSettings, context), GoogleVertexAiRerankTaskSettings.fromMap(taskSettings), - GoogleVertexAiSecretSettings.fromMap(secrets) + GoogleVertexAiSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -59,10 +61,11 @@ public GoogleVertexAiRerankModel(GoogleVertexAiRerankModel model, GoogleVertexAi String service, GoogleVertexAiRerankServiceSettings serviceSettings, GoogleVertexAiRerankTaskSettings taskSettings, - @Nullable GoogleVertexAiSecretSettings secrets + @Nullable GoogleVertexAiSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); @@ -81,10 +84,11 @@ protected GoogleVertexAiRerankModel( String uri, GoogleVertexAiRerankServiceSettings serviceSettings, GoogleVertexAiRerankTaskSettings taskSettings, - @Nullable GoogleVertexAiSecretSettings secrets + @Nullable GoogleVertexAiSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java index 9f2615ac5c515..168c3f181704b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java @@ -51,6 +51,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -70,7 +71,8 @@ public void parseRequestConfig( chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, name()), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, name()); @@ -87,7 +89,8 @@ public HuggingFaceModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); @@ -104,12 +107,18 @@ public HuggingFaceModel parsePersistedConfigWithSecrets( chunkingSettings, secretSettingsMap, parsePersistedConfigErrorMsg(inferenceEntityId, name()), - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @Override - public HuggingFaceModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public HuggingFaceModel parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + String endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -124,7 +133,8 @@ public HuggingFaceModel parsePersistedConfig(String inferenceEntityId, TaskType chunkingSettings, null, parsePersistedConfigErrorMsg(inferenceEntityId, name()), - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @@ -135,7 +145,8 @@ protected abstract HuggingFaceModel createModel( ChunkingSettings chunkingSettings, Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ); @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java index 14af29bab9078..488d55a3178fa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java @@ -53,7 +53,8 @@ protected HuggingFaceModel createModel( ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new HuggingFaceEmbeddingsModel( @@ -63,9 +64,18 @@ protected HuggingFaceModel createModel( serviceSettings, chunkingSettings, secretSettings, - context + context, + endpointVersion + ); + case SPARSE_EMBEDDING -> new HuggingFaceElserModel( + inferenceEntityId, + taskType, + NAME, + serviceSettings, + secretSettings, + context, + endpointVersion ); - case SPARSE_EMBEDDING -> new HuggingFaceElserModel(inferenceEntityId, taskType, NAME, serviceSettings, secretSettings, context); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java index 8132089d8dc99..ad2d56bc4e4d1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java @@ -26,14 +26,16 @@ public HuggingFaceElserModel( String service, Map serviceSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, taskType, service, HuggingFaceElserServiceSettings.fromMap(serviceSettings, context), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -42,10 +44,11 @@ public HuggingFaceElserModel( TaskType taskType, String service, HuggingFaceElserServiceSettings serviceSettings, - @Nullable DefaultSecretSettings secretSettings + @Nullable DefaultSecretSettings secretSettings, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, endpointVersion), new ModelSecrets(secretSettings), serviceSettings, secretSettings diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java index a8de51c23831f..aa0d626e42f14 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java @@ -60,10 +60,19 @@ protected HuggingFaceModel createModel( ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { - case SPARSE_EMBEDDING -> new HuggingFaceElserModel(inferenceEntityId, taskType, NAME, serviceSettings, secretSettings, context); + case SPARSE_EMBEDDING -> new HuggingFaceElserModel( + inferenceEntityId, + taskType, + NAME, + serviceSettings, + secretSettings, + context, + endpointVersion + ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java index 7c4d8094fc213..371ed05c46752 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java @@ -29,7 +29,8 @@ public HuggingFaceEmbeddingsModel( Map serviceSettings, ChunkingSettings chunkingSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -37,7 +38,8 @@ public HuggingFaceEmbeddingsModel( service, HuggingFaceServiceSettings.fromMap(serviceSettings, context), chunkingSettings, - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -48,10 +50,11 @@ public HuggingFaceEmbeddingsModel( String service, HuggingFaceServiceSettings serviceSettings, ChunkingSettings chunkingSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, chunkingSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, chunkingSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings, secrets @@ -65,7 +68,8 @@ public HuggingFaceEmbeddingsModel(HuggingFaceEmbeddingsModel model, HuggingFaceS model.getConfigurations().getService(), serviceSettings, model.getConfigurations().getChunkingSettings(), - model.getSecretSettings() + model.getSecretSettings(), + model.getConfigurations().getEndpointVersion() ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java index 6507afe7302dd..e229b6aead791 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java @@ -64,6 +64,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -77,7 +78,8 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -98,7 +100,8 @@ private static IbmWatsonxModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new IbmWatsonxEmbeddingsModel( @@ -108,7 +111,8 @@ private static IbmWatsonxModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -119,7 +123,8 @@ public IbmWatsonxModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -131,7 +136,8 @@ public IbmWatsonxModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @@ -141,7 +147,8 @@ private static IbmWatsonxModel createModelFromPersistent( Map serviceSettings, Map taskSettings, Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -150,12 +157,13 @@ private static IbmWatsonxModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -165,7 +173,8 @@ public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, M serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java index d60e31b5d41c0..89f01b6ed6566 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java @@ -41,7 +41,8 @@ public IbmWatsonxEmbeddingsModel( Map serviceSettings, Map taskSettings, Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -49,7 +50,8 @@ public IbmWatsonxEmbeddingsModel( service, IbmWatsonxEmbeddingsServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -64,10 +66,11 @@ public IbmWatsonxEmbeddingsModel(IbmWatsonxEmbeddingsModel model, IbmWatsonxEmbe String service, IbmWatsonxEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); @@ -86,10 +89,11 @@ public IbmWatsonxEmbeddingsModel(IbmWatsonxEmbeddingsModel model, IbmWatsonxEmbe String uri, IbmWatsonxEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java index f4f0309b64fee..5caa8d0de1e00 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java @@ -122,6 +122,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -143,7 +144,8 @@ public void parseRequestConfig( chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -161,7 +163,8 @@ public Model parsePersistedConfigWithSecrets( String modelId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -179,12 +182,13 @@ public Model parsePersistedConfigWithSecrets( taskSettingsMap, chunkingSettings, secretSettingsMap, - parsePersistedConfigErrorMsg(modelId, NAME) + parsePersistedConfigErrorMsg(modelId, NAME), + endpointVersion ); } @Override - public Model parsePersistedConfig(String modelId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, String endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -200,7 +204,8 @@ public Model parsePersistedConfig(String modelId, TaskType taskType, Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { if (taskType == TaskType.TEXT_EMBEDDING) { return new MistralEmbeddingsModel( @@ -228,7 +234,8 @@ private static MistralEmbeddingsModel createModel( taskSettings, chunkingSettings, secretSettings, - context + context, + endpointVersion ); } @@ -242,7 +249,8 @@ private MistralEmbeddingsModel createModelFromPersistent( Map taskSettings, ChunkingSettings chunkingSettings, Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -252,7 +260,8 @@ private MistralEmbeddingsModel createModelFromPersistent( chunkingSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java index 11f6c456b88cc..c37205de59b46 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java @@ -40,7 +40,8 @@ public MistralEmbeddingsModel( Map taskSettings, ChunkingSettings chunkingSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -49,7 +50,8 @@ public MistralEmbeddingsModel( MistralEmbeddingsServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, // no task settings for Mistral embeddings chunkingSettings, - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -65,10 +67,19 @@ public MistralEmbeddingsModel( MistralEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, ChunkingSettings chunkingSettings, - DefaultSecretSettings secrets + DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, new EmptyTaskSettings(), chunkingSettings), + new ModelConfigurations( + inferenceEntityId, + taskType, + service, + serviceSettings, + new EmptyTaskSettings(), + chunkingSettings, + endpointVersion + ), new ModelSecrets(secrets) ); setPropertiesFromServiceSettings(serviceSettings); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java index 077d4b52268eb..d6a8906af1ce6 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java @@ -69,6 +69,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { try { @@ -92,7 +93,8 @@ public void parseRequestConfig( chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST + ConfigurationParseContext.REQUEST, + endpointVersion ); throwIfNotEmptyMap(config, NAME); @@ -112,7 +114,8 @@ private static OpenAiModel createModelFromPersistent( Map taskSettings, ChunkingSettings chunkingSettings, @Nullable Map secretSettings, - String failureMessage + String failureMessage, + String endpointVersion ) { return createModel( inferenceEntityId, @@ -122,7 +125,8 @@ private static OpenAiModel createModelFromPersistent( chunkingSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + endpointVersion ); } @@ -134,7 +138,8 @@ private static OpenAiModel createModel( ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new OpenAiEmbeddingsModel( @@ -145,7 +150,8 @@ private static OpenAiModel createModel( taskSettings, chunkingSettings, secretSettings, - context + context, + endpointVersion ); case COMPLETION -> new OpenAiChatCompletionModel( inferenceEntityId, @@ -154,7 +160,8 @@ private static OpenAiModel createModel( serviceSettings, taskSettings, secretSettings, - context + context, + endpointVersion ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -165,7 +172,8 @@ public OpenAiModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -185,12 +193,18 @@ public OpenAiModel parsePersistedConfigWithSecrets( taskSettingsMap, chunkingSettings, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } @Override - public OpenAiModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public OpenAiModel parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + String endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -208,7 +222,8 @@ public OpenAiModel parsePersistedConfig(String inferenceEntityId, TaskType taskT taskSettingsMap, chunkingSettings, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME) + parsePersistedConfigErrorMsg(inferenceEntityId, NAME), + endpointVersion ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java index 7ca93684bc680..dbc49717bac4a 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java @@ -37,7 +37,8 @@ public OpenAiChatCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -45,7 +46,8 @@ public OpenAiChatCompletionModel( service, OpenAiChatCompletionServiceSettings.fromMap(serviceSettings, context), OpenAiChatCompletionTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -55,10 +57,11 @@ public OpenAiChatCompletionModel( String service, OpenAiChatCompletionServiceSettings serviceSettings, OpenAiChatCompletionTaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings, secrets diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java index 5659c46050ad8..a32e1521e9562 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java @@ -39,7 +39,8 @@ public OpenAiEmbeddingsModel( Map taskSettings, ChunkingSettings chunkingSettings, @Nullable Map secrets, - ConfigurationParseContext context + ConfigurationParseContext context, + String endpointVersion ) { this( inferenceEntityId, @@ -48,7 +49,8 @@ public OpenAiEmbeddingsModel( OpenAiEmbeddingsServiceSettings.fromMap(serviceSettings, context), OpenAiEmbeddingsTaskSettings.fromMap(taskSettings, context), chunkingSettings, - DefaultSecretSettings.fromMap(secrets) + DefaultSecretSettings.fromMap(secrets), + endpointVersion ); } @@ -60,10 +62,11 @@ public OpenAiEmbeddingsModel( OpenAiEmbeddingsServiceSettings serviceSettings, OpenAiEmbeddingsTaskSettings taskSettings, ChunkingSettings chunkingSettings, - @Nullable DefaultSecretSettings secrets + @Nullable DefaultSecretSettings secrets, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings, endpointVersion), new ModelSecrets(secrets), serviceSettings, secrets diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java index 03613901c7816..44b2a871d975b 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java @@ -29,7 +29,8 @@ public static ModelConfigurations createRandomInstance() { randomAlphaOfLength(6), randomServiceSettings(), randomTaskSettings(taskType), - ChunkingSettingsFeatureFlag.isEnabled() && randomBoolean() ? ChunkingSettingsTests.createRandomChunkingSettings() : null + ChunkingSettingsFeatureFlag.isEnabled() && randomBoolean() ? ChunkingSettingsTests.createRandomChunkingSettings() : null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -40,21 +41,24 @@ public static ModelConfigurations mutateTestInstance(ModelConfigurations instanc instance.getTaskType(), instance.getService(), instance.getServiceSettings(), - instance.getTaskSettings() + instance.getTaskSettings(), + instance.getEndpointVersion() ); case 1 -> new ModelConfigurations( instance.getInferenceEntityId(), TaskType.values()[(instance.getTaskType().ordinal() + 1) % TaskType.values().length], instance.getService(), instance.getServiceSettings(), - instance.getTaskSettings() + instance.getTaskSettings(), + instance.getEndpointVersion() ); case 2 -> new ModelConfigurations( instance.getInferenceEntityId(), instance.getTaskType(), instance.getService() + "bar", instance.getServiceSettings(), - instance.getTaskSettings() + instance.getTaskSettings(), + instance.getEndpointVersion() ); default -> throw new IllegalStateException(); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java index 8928fdc79e815..2394c76b3fe8e 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java @@ -93,7 +93,8 @@ public static ScalingExecutorBuilder inferenceUtilityPool() { public static void storeSparseModel(Client client) throws Exception { Model model = new TestSparseInferenceServiceExtension.TestSparseModel( TestSparseInferenceServiceExtension.TestInferenceService.NAME, - new TestSparseInferenceServiceExtension.TestServiceSettings("sparse_model", null, false) + new TestSparseInferenceServiceExtension.TestServiceSettings("sparse_model", null, false), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); storeModel(client, model); } @@ -106,7 +107,8 @@ public static void storeDenseModel( ) throws Exception { Model model = new TestDenseInferenceServiceExtension.TestDenseModel( TestDenseInferenceServiceExtension.TestInferenceService.NAME, - new TestDenseInferenceServiceExtension.TestServiceSettings("dense_model", dimensions, similarityMeasure, elementType) + new TestDenseInferenceServiceExtension.TestServiceSettings("dense_model", dimensions, similarityMeasure, elementType), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); storeModel(client, model); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java index b0c59fe160be3..380897f385b41 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java @@ -81,12 +81,48 @@ public void test() throws Exception { listener.onResponse( new GetInferenceModelAction.Response( List.of( - new ModelConfigurations("model-001", TaskType.TEXT_EMBEDDING, "openai", mock(ServiceSettings.class)), - new ModelConfigurations("model-002", TaskType.TEXT_EMBEDDING, "openai", mock(ServiceSettings.class)), - new ModelConfigurations("model-003", TaskType.SPARSE_EMBEDDING, "hugging_face_elser", mock(ServiceSettings.class)), - new ModelConfigurations("model-004", TaskType.TEXT_EMBEDDING, "openai", mock(ServiceSettings.class)), - new ModelConfigurations("model-005", TaskType.SPARSE_EMBEDDING, "openai", mock(ServiceSettings.class)), - new ModelConfigurations("model-006", TaskType.SPARSE_EMBEDDING, "hugging_face_elser", mock(ServiceSettings.class)) + new ModelConfigurations( + "model-001", + TaskType.TEXT_EMBEDDING, + "openai", + mock(ServiceSettings.class), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ), + new ModelConfigurations( + "model-002", + TaskType.TEXT_EMBEDDING, + "openai", + mock(ServiceSettings.class), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ), + new ModelConfigurations( + "model-003", + TaskType.SPARSE_EMBEDDING, + "hugging_face_elser", + mock(ServiceSettings.class), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ), + new ModelConfigurations( + "model-004", + TaskType.TEXT_EMBEDDING, + "openai", + mock(ServiceSettings.class), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ), + new ModelConfigurations( + "model-005", + TaskType.SPARSE_EMBEDDING, + "openai", + mock(ServiceSettings.class), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ), + new ModelConfigurations( + "model-006", + TaskType.SPARSE_EMBEDDING, + "hugging_face_elser", + mock(ServiceSettings.class), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) ) ) ); 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..435c69b65c3bd 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 @@ -25,6 +25,7 @@ import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.InferenceServiceRegistry; import org.elasticsearch.inference.Model; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.inference.UnparsedModel; import org.elasticsearch.rest.RestStatus; @@ -276,7 +277,8 @@ private static ShardBulkInferenceActionFilter createFilter(ThreadPool threadPool model.getTaskType(), model.getServiceSettings().model(), XContentHelper.convertToMap(JsonXContent.jsonXContent, Strings.toString(model.getTaskSettings()), false), - XContentHelper.convertToMap(JsonXContent.jsonXContent, Strings.toString(model.getSecretSettings()), false) + XContentHelper.convertToMap(JsonXContent.jsonXContent, Strings.toString(model.getSecretSettings()), false), + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ); } else { @@ -316,7 +318,7 @@ private static ShardBulkInferenceActionFilter createFilter(ThreadPool threadPool String inferenceId = (String) invocationOnMock.getArguments()[0]; return modelMap.get(inferenceId); }; - doAnswer(modelAnswer).when(inferenceService).parsePersistedConfigWithSecrets(any(), any(), any(), any()); + doAnswer(modelAnswer).when(inferenceService).parsePersistedConfigWithSecrets(any(), any(), any(), any(), any()); InferenceServiceRegistry inferenceServiceRegistry = mock(InferenceServiceRegistry.class); when(inferenceServiceRegistry.getService(any())).thenReturn(Optional.of(inferenceService)); @@ -379,9 +381,10 @@ private static class StaticModel extends TestModel { String service, TestServiceSettings serviceSettings, TestTaskSettings taskSettings, - TestSecretSettings secretSettings + TestSecretSettings secretSettings, + String endpointVersion ) { - super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, secretSettings); + super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, secretSettings, endpointVersion); this.resultMap = new HashMap<>(); } @@ -393,7 +396,8 @@ public static StaticModel createRandomInstance() { randomAlphaOfLength(10), testModel.getServiceSettings(), testModel.getTaskSettings(), - testModel.getSecretSettings() + testModel.getSecretSettings(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java index 45a2fb0954c79..f8cef0e2e73bf 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java @@ -15,6 +15,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.InferenceServiceResults; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockRequest; import org.elasticsearch.test.http.MockResponse; @@ -468,7 +469,16 @@ public void testInfer_AzureOpenAiCompletion_WithOverriddenUser() throws IOExcept var apiKey = "api_key"; var completionInput = "some input"; - var model = createCompletionModel("resource", "deployment", "apiversion", originalUser, apiKey, null, "id"); + var model = createCompletionModel( + "resource", + "deployment", + "apiversion", + originalUser, + apiKey, + null, + "id", + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); var taskSettingsWithUserOverride = createRequestTaskSettingsMap(overriddenUser); @@ -524,7 +534,16 @@ public void testInfer_AzureOpenAiCompletionModel_WithoutUser() throws IOExceptio webServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseJson)); - var model = createCompletionModel("resource", "deployment", "apiversion", null, apiKey, null, "id"); + var model = createCompletionModel( + "resource", + "deployment", + "apiversion", + null, + apiKey, + null, + "id", + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); var requestTaskSettingsWithoutUser = createRequestTaskSettingsMap(null); @@ -582,7 +601,16 @@ public void testInfer_AzureOpenAiCompletionModel_FailsFromInvalidResponseFormat( webServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseJson)); - var model = createCompletionModel("resource", "deployment", "apiversion", null, apiKey, null, "id"); + var model = createCompletionModel( + "resource", + "deployment", + "apiversion", + null, + apiKey, + null, + "id", + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); var requestTaskSettingsWithoutUser = createRequestTaskSettingsMap(userOverride); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java index 4c7683c882816..6ee5fd18246c0 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java @@ -15,6 +15,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.InferenceServiceResults; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockResponse; import org.elasticsearch.test.http.MockWebServer; @@ -194,7 +195,16 @@ private ExecutableAction createAction( String inferenceEntityId ) { try { - var model = createCompletionModel(resourceName, deploymentId, apiVersion, user, apiKey, null, inferenceEntityId); + var model = createCompletionModel( + resourceName, + deploymentId, + apiVersion, + user, + apiKey, + null, + inferenceEntityId, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); model.setUri(new URI(getUrl(webServer))); var requestCreator = new AzureOpenAiCompletionRequestManager(model, threadPool); var errorMessage = constructFailedToSendRequestMessage(model.getUri(), "Azure OpenAI completion"); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java index f3ddf7f9299d9..c475f59a8e959 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java @@ -10,6 +10,7 @@ import org.apache.http.HttpHeaders; import org.apache.http.client.methods.HttpPost; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.inference.external.request.HttpRequest; @@ -458,7 +459,8 @@ public static AzureAiStudioChatCompletionRequest createRequest( topP, doSample, maxNewTokens, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); return new AzureAiStudioChatCompletionRequest(model, List.of(input)); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java index 048d4ea16d56f..0c1b7e38f1bfb 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java @@ -9,6 +9,7 @@ import org.apache.http.HttpHeaders; import org.apache.http.client.methods.HttpPost; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.inference.external.request.azureopenai.AzureOpenAiCompletionRequest; @@ -91,7 +92,8 @@ protected AzureOpenAiCompletionRequest createRequest( user, apiKey, entraId, - "id" + "id", + ModelConfigurations.FIRST_ENDPOINT_VERSION ); return new AzureOpenAiCompletionRequest(List.of(input), completionModel); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java index 49f3f9d48f187..62a8ff8bbe7c8 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java @@ -47,7 +47,8 @@ public static TestModel createRandomInstance(TaskType taskType) { randomAlphaOfLength(10), new TestModel.TestServiceSettings(randomAlphaOfLength(4), dimensions, similarity, elementType), new TestModel.TestTaskSettings(randomInt(3)), - new TestModel.TestSecretSettings(randomAlphaOfLength(4)) + new TestModel.TestSecretSettings(randomAlphaOfLength(4)), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -57,10 +58,11 @@ public TestModel( String service, TestServiceSettings serviceSettings, TestTaskSettings taskSettings, - TestSecretSettings secretSettings + TestSecretSettings secretSettings, + String endpointVersion ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), new ModelSecrets(secretSettings) ); } 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..8fc7e96af622d 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 @@ -146,7 +146,8 @@ private void handleGetInferenceModelActionRequ request.getTaskType(), CohereService.NAME, new CohereRerankServiceSettings("uri", "model", null), - topN == null ? new EmptyTaskSettings() : new CohereRerankTaskSettings(topN, null, null) + topN == null ? new EmptyTaskSettings() : new CohereRerankTaskSettings(topN, null, null), + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java index 75c370fd4d3fb..7250c9ab10eb4 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java @@ -22,6 +22,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.engine.VersionConflictEngineException; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.inference.UnparsedModel; import org.elasticsearch.search.SearchHit; @@ -295,7 +296,14 @@ public void testStoreModel_ThrowsException_WhenFailureIsNotAVersionConflict() { @SuppressWarnings("unchecked") public void testDeepCopyDefaultConfig() { { - var toCopy = new UnparsedModel("tocopy", randomFrom(TaskType.values()), "service-a", Map.of(), Map.of()); + var toCopy = new UnparsedModel( + "tocopy", + randomFrom(TaskType.values()), + "service-a", + Map.of(), + Map.of(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); var copied = ModelRegistry.deepCopyDefaultConfig(toCopy); assertThat(copied, not(sameInstance(toCopy))); assertThat(copied.taskType(), is(toCopy.taskType())); @@ -318,7 +326,14 @@ public void testDeepCopyDefaultConfig() { Map service = Map.of("num_threads", 1, "adaptive_allocations", Map.of("enabled", true)); Map settings = Map.of("chunking_settings", chunking, "service_settings", service, "task_settings", task); - var toCopy = new UnparsedModel("tocopy", randomFrom(TaskType.values()), "service-a", settings, secretsMap); + var toCopy = new UnparsedModel( + "tocopy", + randomFrom(TaskType.values()), + "service-a", + settings, + secretsMap, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); var copied = ModelRegistry.deepCopyDefaultConfig(toCopy); assertThat(copied, not(sameInstance(toCopy))); @@ -352,10 +367,28 @@ public void testDuplicateDefaultIds() { var id = "my-inference"; - registry.addDefaultConfiguration(new UnparsedModel(id, randomFrom(TaskType.values()), "service-a", Map.of(), Map.of())); + registry.addDefaultConfiguration( + new UnparsedModel( + id, + randomFrom(TaskType.values()), + "service-a", + Map.of(), + Map.of(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) + ); var ise = expectThrows( IllegalStateException.class, - () -> registry.addDefaultConfiguration(new UnparsedModel(id, randomFrom(TaskType.values()), "service-b", Map.of(), Map.of())) + () -> registry.addDefaultConfiguration( + new UnparsedModel( + id, + randomFrom(TaskType.values()), + "service-b", + Map.of(), + Map.of(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) + ) ); assertThat( ise.getMessage(), 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..46104167a9ea4 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 @@ -137,6 +137,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, + String endpointVersion, ActionListener parsedModelListener ) { parsedModelListener.onResponse(null); @@ -147,13 +148,14 @@ public Model parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets + Map secrets, + String endpointVersion ) { return null; } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { return null; } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java index ec4120881521a..e512571eeff7f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java @@ -94,6 +94,7 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModel() throws IOException AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -189,7 +190,8 @@ public void testChunkedInfer_Batches() throws IOException { serviceSettingsMap, taskSettingsMap, secretSettingsMap, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ) { public ExecutableAction accept( AlibabaCloudSearchActionVisitor visitor, 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..1939afd932a91 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 @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.completion; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; @@ -47,7 +48,9 @@ public static AlibabaCloudSearchCompletionModel createModel( serviceSettings, taskSettings, secrets, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -64,7 +67,9 @@ public static AlibabaCloudSearchCompletionModel createModel( AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, - secretSettings + secretSettings, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } } 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..9930e8283c645 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 @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; @@ -48,7 +49,9 @@ public static AlibabaCloudSearchEmbeddingsModel createModel( serviceSettings, taskSettings, secrets, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -65,7 +68,8 @@ public static AlibabaCloudSearchEmbeddingsModel createModel( AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, - secretSettings + secretSettings, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } } 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..bf7b8e733bd53 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 @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.sparse; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; @@ -48,7 +49,9 @@ public static AlibabaCloudSearchSparseModel createModel( serviceSettings, taskSettings, secrets, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -65,7 +68,9 @@ public static AlibabaCloudSearchSparseModel createModel( AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, - secretSettings + secretSettings, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java index eee4eb33ab453..1745dca28b384 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java @@ -110,6 +110,7 @@ public void testParseRequestConfig_CreatesAnAmazonBedrockModel() throws IOExcept Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -133,6 +134,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -156,6 +158,7 @@ public void testCreateModel_ForEmbeddingsTask_InvalidProvider() throws IOExcepti Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -179,6 +182,7 @@ public void testCreateModel_TopKParameter_NotAvailable() throws IOException { getChatCompletionTaskSettingsMap(1.0, 0.5, 0.2, 128), getAmazonBedrockSecretSettingsMap("access", "secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -205,7 +209,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -226,7 +236,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ); }); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -250,7 +266,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ); }); - service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.COMPLETION, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -274,7 +296,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ); }); - service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.COMPLETION, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -300,6 +328,7 @@ public void testParseRequestConfig_MovesModel() throws IOException { Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -323,6 +352,7 @@ public void testCreateModel_ForEmbeddingsTask_DimensionsIsNotAllowed() throws IO Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -339,7 +369,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnAmazonBedrockEmbeddings "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -367,7 +398,8 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ); @@ -390,7 +422,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -417,7 +450,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -444,7 +478,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -471,7 +506,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -499,7 +535,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); @@ -526,7 +563,12 @@ public void testParsePersistedConfig_CreatesAnAmazonBedrockEmbeddingsModel() thr var persistedConfig = getPersistedConfigMap(settingsMap, new HashMap(Map.of()), secretSettingsMap); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -545,7 +587,12 @@ public void testParsePersistedConfig_CreatesAnAmazonBedrockChatCompletionModel() var secretSettingsMap = getAmazonBedrockSecretSettingsMap("access", "secret"); var persistedConfig = getPersistedConfigMap(settingsMap, taskSettingsMap, secretSettingsMap); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); @@ -571,7 +618,12 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()) + () -> service.parsePersistedConfig( + "id", + TaskType.SPARSE_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) ); assertThat( @@ -589,7 +641,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var persistedConfig = getPersistedConfigMap(settingsMap, new HashMap(Map.of()), secretSettingsMap); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -610,7 +667,12 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var persistedConfig = getPersistedConfigMap(settingsMap, new HashMap(Map.of()), secretSettingsMap); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -630,7 +692,12 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( var secretSettingsMap = getAmazonBedrockSecretSettingsMap("access", "secret"); var persistedConfig = getPersistedConfigMap(settingsMap, taskSettingsMap, secretSettingsMap); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java index 22173943ff432..f68cf1f08d87a 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.amazonbedrock.AmazonBedrockProvider; @@ -214,7 +215,8 @@ public static AmazonBedrockChatCompletionModel createModel( "amazonbedrock", new AmazonBedrockChatCompletionServiceSettings(region, model, provider, rateLimitSettings), new AmazonBedrockChatCompletionTaskSettings(temperature, topP, topK, maxNewTokens), - new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)) + new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java index 711e3cbb5a511..07063290cf4f3 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java @@ -11,6 +11,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -75,7 +76,8 @@ public static AmazonBedrockEmbeddingsModel createModel( rateLimitSettings ), new EmptyTaskSettings(), - new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)) + new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java index c502425b22ac3..956ffc956b3be 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java @@ -16,6 +16,7 @@ import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockResponse; @@ -107,6 +108,7 @@ public void testParseRequestConfig_CreatesACompletionModel() throws IOException new HashMap<>(Map.of(AnthropicServiceFields.MAX_TOKENS, 1)), getSecretSettingsMap(apiKey) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -127,6 +129,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -145,7 +148,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -164,7 +167,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -183,7 +186,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -202,7 +205,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -221,7 +224,8 @@ public void testParsePersistedConfigWithSecrets_CreatesACompletionModel() throws "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -249,7 +253,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -279,7 +284,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -309,7 +315,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -339,7 +346,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -360,7 +368,12 @@ public void testParsePersistedConfig_CreatesACompletionModel() throws IOExceptio AnthropicChatCompletionTaskSettingsTests.getChatCompletionTaskSettingsMap(1, 1.0, 2.1, 3) ); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -381,7 +394,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() ); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -404,7 +422,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe AnthropicChatCompletionTaskSettingsTests.getChatCompletionTaskSettingsMap(1, 1.0, 2.1, 3) ); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -424,7 +447,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), taskSettings); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); 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..115fa5c455ab6 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 @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.anthropic.completion; import org.elasticsearch.common.settings.SecureString; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings; @@ -52,7 +53,9 @@ public static AnthropicChatCompletionModel createChatCompletionModel(String url, url, new AnthropicChatCompletionServiceSettings(modelName, null), new AnthropicChatCompletionTaskSettings(maxTokens, null, null, null), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -63,7 +66,9 @@ public static AnthropicChatCompletionModel createChatCompletionModel(String apiK "service", new AnthropicChatCompletionServiceSettings(modelName, null), new AnthropicChatCompletionTaskSettings(maxTokens, null, null, null), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } } 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 8ba10b50c8058..f504dbd2f4172 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 @@ -119,6 +119,7 @@ public void testParseRequestConfig_CreatesAnAzureAiStudioEmbeddingsModel() throw getEmbeddingsTaskSettingsMap("user"), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -146,6 +147,7 @@ public void testParseRequestConfig_CreatesAnAzureAiStudioChatCompletionModel() t getChatCompletionTaskSettingsMap(null, null, true, null), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -169,6 +171,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getChatCompletionTaskSettingsMap(null, null, true, null), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -194,7 +197,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.COMPLETION, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -216,7 +225,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingServiceS } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -239,7 +254,13 @@ public void testParseRequestConfig_ThrowsWhenDimsSetByUserExistsInEmbeddingServi } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -265,7 +286,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingTaskSett } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -291,7 +318,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingSecretSe } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -317,7 +350,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInChatCompletionSer } ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.COMPLETION, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -343,7 +382,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInChatCompletionTas } ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.COMPLETION, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -369,7 +414,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInChatCompletionSec } ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.COMPLETION, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -387,7 +438,13 @@ public void testParseRequestConfig_ThrowsWhenProviderIsNotValidForEmbeddings() t } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -408,7 +465,13 @@ public void testParseRequestConfig_ThrowsWhenEndpointTypeIsNotValidForEmbeddings } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -433,7 +496,13 @@ public void testParseRequestConfig_ThrowsWhenEndpointTypeIsNotValidForChatComple } ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.COMPLETION, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -445,7 +514,13 @@ public void testParsePersistedConfig_CreatesAnAzureAiStudioEmbeddingsModel() thr getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -469,7 +544,13 @@ public void testParsePersistedConfig_CreatesAnAzureAiStudioChatCompletionModel() getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.COMPLETION, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.COMPLETION, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); @@ -502,6 +583,7 @@ public void testParsePersistedConfig_ThrowsUnsupportedModelType() throws IOExcep getChatCompletionTaskSettingsMap(null, null, true, null), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -517,7 +599,13 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfigWithSecrets("id", TaskType.SPARSE_EMBEDDING, config.config(), config.secrets()) + () -> service.parsePersistedConfigWithSecrets( + "id", + TaskType.SPARSE_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) ); assertThat( @@ -535,7 +623,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); config.config().put("extra_key", "value"); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); } @@ -550,7 +644,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenExtraKeyExistsInEmbeddingSe var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); } @@ -565,7 +665,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); } @@ -580,7 +686,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); } @@ -594,7 +706,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInChatCompl var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.COMPLETION, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.COMPLETION, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); } @@ -608,7 +726,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInChatCompl var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.COMPLETION, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.COMPLETION, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); } @@ -622,7 +746,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInChatCompl secretSettings.put("extra_key", "value"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.COMPLETION, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.COMPLETION, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); } @@ -636,7 +766,12 @@ public void testParsePersistedConfig_WithoutSecretsCreatesEmbeddingsModel() thro Map.of() ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -659,7 +794,12 @@ public void testParsePersistedConfig_WithoutSecretsCreatesChatCompletionModel() Map.of() ); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, config.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + config.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); @@ -779,7 +919,8 @@ public void testCheckModelConfig_WorksForChatCompletionsModel() throws IOExcepti null, null, null, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); PlainActionFuture listener = new PlainActionFuture<>(); @@ -799,7 +940,8 @@ public void testCheckModelConfig_WorksForChatCompletionsModel() throws IOExcepti null, null, AzureAiStudioChatCompletionTaskSettings.DEFAULT_MAX_NEW_TOKENS, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java index bd34a34285cf2..3378eea246245 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.azureaistudio.AzureAiStudioEndpointType; @@ -35,7 +36,8 @@ public void testOverrideWith_OverridesWithoutValues() { 2.0, false, 512, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); var requestTaskSettingsMap = getTaskSettingsMap(null, null, null, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettingsMap); @@ -54,7 +56,8 @@ public void testOverrideWith_temperature() { null, null, null, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); var requestTaskSettings = getTaskSettingsMap(0.5, null, null, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -71,7 +74,8 @@ public void testOverrideWith_temperature() { null, null, null, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ) ); @@ -88,7 +92,8 @@ public void testOverrideWith_topP() { 0.8, null, null, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); var requestTaskSettings = getTaskSettingsMap(null, 0.5, null, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -105,7 +110,8 @@ public void testOverrideWith_topP() { 0.5, null, null, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ) ); @@ -122,7 +128,8 @@ public void testOverrideWith_doSample() { null, true, null, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); var requestTaskSettings = getTaskSettingsMap(null, null, false, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -139,7 +146,8 @@ public void testOverrideWith_doSample() { null, false, null, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ) ); @@ -156,7 +164,8 @@ public void testOverrideWith_maxNewTokens() { null, null, 512, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); var requestTaskSettings = getTaskSettingsMap(null, null, null, 128); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -173,7 +182,8 @@ public void testOverrideWith_maxNewTokens() { null, null, 128, - null + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ) ); @@ -207,7 +217,19 @@ public static AzureAiStudioChatCompletionModel createModel( AzureAiStudioEndpointType endpointType, String apiKey ) { - return createModel(id, target, provider, endpointType, apiKey, null, null, null, null, null); + return createModel( + id, + target, + provider, + endpointType, + apiKey, + null, + null, + null, + null, + null, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } public static AzureAiStudioChatCompletionModel createModel( @@ -220,7 +242,8 @@ public static AzureAiStudioChatCompletionModel createModel( @Nullable Double topP, @Nullable Boolean doSample, @Nullable Integer maxNewTokens, - @Nullable RateLimitSettings rateLimitSettings + @Nullable RateLimitSettings rateLimitSettings, + String endpointVersion ) { return new AzureAiStudioChatCompletionModel( id, @@ -228,7 +251,8 @@ public static AzureAiStudioChatCompletionModel createModel( "azureaistudio", new AzureAiStudioChatCompletionServiceSettings(target, provider, endpointType, rateLimitSettings), new AzureAiStudioChatCompletionTaskSettings(temperature, topP, doSample, maxNewTokens), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + endpointVersion ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java index 5a450f03b4e01..4e8b7d172975f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -132,7 +133,8 @@ public static AzureAiStudioEmbeddingsModel createModel( rateLimitSettings ), new AzureAiStudioEmbeddingsTaskSettings(user), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java index 8d5c590518fa8..4318f88d27dc9 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java @@ -117,6 +117,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModel() throws IOExc getAzureOpenAiRequestTaskSettingsMap("user"), getAzureOpenAiSecretSettingsMap("secret", null) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -140,6 +141,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getAzureOpenAiRequestTaskSettingsMap("user"), getAzureOpenAiSecretSettingsMap("secret", null) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -165,7 +167,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -190,7 +198,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ); }); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -215,7 +229,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ); }); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -240,7 +260,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ); }); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -265,6 +291,7 @@ public void testParseRequestConfig_MovesModel() throws IOException { getAzureOpenAiRequestTaskSettingsMap("user"), getAzureOpenAiSecretSettingsMap("secret", null) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -282,7 +309,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnAzureOpenAiEmbeddingsMo "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -312,7 +340,8 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ); @@ -336,7 +365,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -367,7 +397,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -396,7 +427,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -427,7 +459,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -458,7 +491,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -481,7 +515,12 @@ public void testParsePersistedConfig_CreatesAnAzureOpenAiEmbeddingsModel() throw getAzureOpenAiRequestTaskSettingsMap("user") ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -503,7 +542,12 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()) + () -> service.parsePersistedConfig( + "id", + TaskType.SPARSE_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) ); assertThat( @@ -521,7 +565,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() ); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -547,7 +596,12 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var persistedConfig = getPersistedConfigMap(serviceSettingsMap, getAzureOpenAiRequestTaskSettingsMap("user")); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -570,7 +624,12 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( taskSettingsMap ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); 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..ed675b9ec2974 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 @@ -9,6 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.azureopenai.AzureOpenAiSecretSettings; @@ -35,18 +36,48 @@ public void testOverrideWith_UpdatedTaskSettings_OverridesUser() { var user = "user"; var userOverride = "user override"; - var model = createCompletionModel(resource, deploymentId, apiVersion, user, apiKey, entraId, inferenceEntityId); + var model = createCompletionModel( + resource, + deploymentId, + apiVersion, + user, + apiKey, + entraId, + inferenceEntityId, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); var requestTaskSettingsMap = taskSettingsMap(userOverride); var overriddenModel = AzureOpenAiCompletionModel.of(model, requestTaskSettingsMap); assertThat( overriddenModel, - equalTo(createCompletionModel(resource, deploymentId, apiVersion, userOverride, apiKey, entraId, inferenceEntityId)) + equalTo( + createCompletionModel( + resource, + deploymentId, + apiVersion, + userOverride, + apiKey, + entraId, + inferenceEntityId, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) + ) ); } 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", + ModelConfigurations.FIRST_ENDPOINT_VERSION + + ); var requestTaskSettingsMap = Map.of(); var overriddenModel = AzureOpenAiCompletionModel.of(model, requestTaskSettingsMap); @@ -54,7 +85,17 @@ 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", + ModelConfigurations.FIRST_ENDPOINT_VERSION + + ); var overriddenModel = AzureOpenAiCompletionModel.of(model, null); assertThat(overriddenModel, sameInstance(model)); @@ -73,12 +114,32 @@ public void testOverrideWith_UpdatedServiceSettings_OverridesApiVersion() { var updatedServiceSettings = new AzureOpenAiCompletionServiceSettings(resource, deploymentId, updatedApiVersion, null); - var model = createCompletionModel(resource, deploymentId, apiVersion, user, apiKey, entraId, inferenceEntityId); + var model = createCompletionModel( + resource, + deploymentId, + apiVersion, + user, + apiKey, + entraId, + inferenceEntityId, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); var overriddenModel = new AzureOpenAiCompletionModel(model, updatedServiceSettings); assertThat( overriddenModel, - is(createCompletionModel(resource, deploymentId, updatedApiVersion, user, apiKey, entraId, inferenceEntityId)) + is( + createCompletionModel( + resource, + deploymentId, + updatedApiVersion, + user, + apiKey, + entraId, + inferenceEntityId, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) + ) ); } @@ -91,7 +152,16 @@ public void testBuildUriString() throws URISyntaxException { var inferenceEntityId = "inference entity id"; var apiVersion = "2024"; - var model = createCompletionModel(resource, deploymentId, apiVersion, user, apiKey, entraId, inferenceEntityId); + var model = createCompletionModel( + resource, + deploymentId, + apiVersion, + user, + apiKey, + entraId, + inferenceEntityId, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat( model.buildUriString().toString(), @@ -107,7 +177,9 @@ public static AzureOpenAiCompletionModel createModelWithRandomValues() { randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10), - randomAlphaOfLength(10) + randomAlphaOfLength(10), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -118,7 +190,8 @@ public static AzureOpenAiCompletionModel createCompletionModel( String user, @Nullable String apiKey, @Nullable String entraId, - String inferenceEntityId + String inferenceEntityId, + String endpointVersion ) { var secureApiKey = apiKey != null ? new SecureString(apiKey.toCharArray()) : null; var secureEntraId = entraId != null ? new SecureString(entraId.toCharArray()) : null; @@ -129,7 +202,8 @@ public static AzureOpenAiCompletionModel createCompletionModel( "service", new AzureOpenAiCompletionServiceSettings(resourceName, deploymentId, apiVersion, null), new AzureOpenAiCompletionTaskSettings(user), - new AzureOpenAiSecretSettings(secureApiKey, secureEntraId) + new AzureOpenAiSecretSettings(secureApiKey, secureEntraId), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java index 1747155623a98..1fb1a7d055a86 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -112,7 +113,8 @@ public static AzureOpenAiEmbeddingsModel createModel( "service", new AzureOpenAiEmbeddingsServiceSettings(resourceName, deploymentId, apiVersion, null, false, null, null, null), new AzureOpenAiEmbeddingsTaskSettings(user), - new AzureOpenAiSecretSettings(secureApiKey, secureEntraId) + new AzureOpenAiSecretSettings(secureApiKey, secureEntraId), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -147,7 +149,8 @@ public static AzureOpenAiEmbeddingsModel createModel( null ), new AzureOpenAiEmbeddingsTaskSettings(user), - new AzureOpenAiSecretSettings(secureApiKey, secureEntraId) + new AzureOpenAiSecretSettings(secureApiKey, secureEntraId), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java index b0b1252116a9e..78c1ce22b2cef 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java @@ -122,6 +122,7 @@ public void testParseRequestConfig_CreatesACohereEmbeddingsModel() throws IOExce getTaskSettingsMap(InputType.INGEST, CohereTruncation.START), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); @@ -149,6 +150,7 @@ public void testParseRequestConfig_OptionalTaskSettings() throws IOException { CohereEmbeddingsServiceSettingsTests.getServiceSettingsMap("url", "model", CohereEmbeddingType.FLOAT), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); @@ -170,6 +172,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getTaskSettingsMapEmpty(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -195,7 +198,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -210,7 +213,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -229,7 +232,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -249,7 +252,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -272,6 +275,7 @@ public void testParseRequestConfig_CreatesACohereEmbeddingsModelWithoutUrl() thr getTaskSettingsMapEmpty(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); @@ -290,7 +294,8 @@ public void testParsePersistedConfigWithSecrets_CreatesACohereEmbeddingsModel() "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -317,7 +322,8 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ); @@ -340,7 +346,8 @@ public void testParsePersistedConfigWithSecrets_CreatesACohereEmbeddingsModelWit "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -365,7 +372,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -397,7 +405,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -422,7 +431,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -446,7 +456,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -473,7 +484,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -493,7 +505,12 @@ public void testParsePersistedConfig_CreatesACohereEmbeddingsModel() throws IOEx getTaskSettingsMap(null, CohereTruncation.NONE) ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -514,7 +531,12 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()) + () -> service.parsePersistedConfig( + "id", + TaskType.SPARSE_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) ); MatcherAssert.assertThat( @@ -531,7 +553,12 @@ public void testParsePersistedConfig_CreatesACohereEmbeddingsModelWithoutUrl() t getTaskSettingsMap(null, null) ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -552,7 +579,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() ); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -570,7 +602,12 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var persistedConfig = getPersistedConfigMap(serviceSettingsMap, getTaskSettingsMap(InputType.SEARCH, null)); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -591,7 +628,12 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( taskSettingsMap ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); 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..8af4456538d21 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 @@ -10,6 +10,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.ConfigurationParseContext; @@ -30,7 +31,9 @@ public void testCreateModel_AlwaysWithEmptyTaskSettings() { new HashMap<>(Map.of()), new HashMap<>(Map.of("model", "overridden model")), null, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model.getTaskSettings(), is(EmptyTaskSettings.INSTANCE)); @@ -43,7 +46,9 @@ public static CohereCompletionModel createModel(String url, String apiKey, @Null "service", new CohereCompletionServiceSettings(url, model, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } 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..5286e65e52bea 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 @@ -10,6 +10,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.InputType; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -222,7 +223,8 @@ public static CohereEmbeddingsModel createModel( Objects.requireNonNullElse(embeddingType, CohereEmbeddingType.FLOAT) ), taskSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -245,7 +247,9 @@ public static CohereEmbeddingsModel createModel( Objects.requireNonNullElse(embeddingType, CohereEmbeddingType.FLOAT) ), taskSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java index c9f4234331221..a3a5695f583de 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.inference.EmptySecretSettings; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.elasticsearch.ElserModels; @@ -27,7 +28,8 @@ public static ElasticInferenceServiceSparseEmbeddingsModel createModel(String ur new ElasticInferenceServiceSparseEmbeddingsServiceSettings(ElserModels.ELSER_V2_MODEL, maxInputTokens, null), EmptyTaskSettings.INSTANCE, EmptySecretSettings.INSTANCE, - new ElasticInferenceServiceComponents(url) + new ElasticInferenceServiceComponents(url), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java index d10c70c6f0f5e..de2e4923c780a 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java @@ -20,6 +20,7 @@ import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockResponse; @@ -103,6 +104,7 @@ public void testParseRequestConfig_CreatesASparseEmbeddingsModel() throws IOExce "id", TaskType.SPARSE_EMBEDDING, getRequestConfigMap(Map.of(ServiceFields.MODEL_ID, ElserModels.ELSER_V2_MODEL), Map.of(), Map.of()), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -119,6 +121,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti "id", TaskType.COMPLETION, getRequestConfigMap(Map.of(ServiceFields.MODEL_ID, ElserModels.ELSER_V2_MODEL), Map.of(), Map.of()), + ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -133,7 +136,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, failureListener); + service.parseRequestConfig( + "id", + TaskType.SPARSE_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + failureListener + ); } } @@ -148,7 +157,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, failureListener); + service.parseRequestConfig( + "id", + TaskType.SPARSE_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + failureListener + ); } } @@ -162,7 +177,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, failureListener); + service.parseRequestConfig( + "id", + TaskType.SPARSE_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + failureListener + ); } } @@ -176,7 +197,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, failureListener); + service.parseRequestConfig( + "id", + TaskType.SPARSE_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + failureListener + ); } } @@ -192,7 +219,8 @@ public void testParsePersistedConfigWithSecrets_CreatesASparseEmbeddingModel() t "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -217,7 +245,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -240,7 +269,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -266,7 +296,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -292,7 +323,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java index 513a62e057e3f..c84617d59cfbd 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java @@ -118,7 +118,7 @@ public void testParseRequestConfig() { ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - service.parseRequestConfig(randomInferenceEntityId, taskType, config, modelListener); + service.parseRequestConfig(randomInferenceEntityId, taskType, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener); } public void testParseRequestConfig_Misconfigured() { @@ -140,7 +140,13 @@ public void testParseRequestConfig_Misconfigured() { ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - service.parseRequestConfig(randomInferenceEntityId, taskType, config, modelListener); + service.parseRequestConfig( + randomInferenceEntityId, + taskType, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelListener + ); } // Invalid config map @@ -162,7 +168,13 @@ public void testParseRequestConfig_Misconfigured() { ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - service.parseRequestConfig(randomInferenceEntityId, taskType, config, modelListener); + service.parseRequestConfig( + randomInferenceEntityId, + taskType, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelListener + ); } } @@ -190,6 +202,7 @@ public void testParseRequestConfig_E5() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION, getE5ModelVerificationActionListener(e5ServiceSettings) ); } @@ -222,6 +235,7 @@ public void testParseRequestConfig_E5() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION, getE5ModelVerificationActionListener(e5ServiceSettings) ); } @@ -251,7 +265,13 @@ public void testParseRequestConfig_E5() { e -> assertThat(e, instanceOf(ElasticsearchStatusException.class)) ); - service.parseRequestConfig(randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, modelListener); + service.parseRequestConfig( + randomInferenceEntityId, + TaskType.TEXT_EMBEDDING, + settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelListener + ); } } @@ -283,6 +303,7 @@ public void testParseRequestConfig_elser() { randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, getElserModelVerificationActionListener( elserServiceSettings, null, @@ -318,6 +339,7 @@ public void testParseRequestConfig_elser() { randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, getElserModelVerificationActionListener(elserServiceSettings, criticalWarning, warnWarning) ); assertWarnings(true, new DeprecationWarning(DeprecationLogger.CRITICAL, criticalWarning)); @@ -351,7 +373,13 @@ public void testParseRequestConfig_elser() { e -> assertThat(e, instanceOf(ElasticsearchStatusException.class)) ); - service.parseRequestConfig(randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, config, modelListener); + service.parseRequestConfig( + randomInferenceEntityId, + TaskType.SPARSE_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelListener + ); } } @@ -398,7 +426,13 @@ public void testParseRequestConfig_Rerank() { assertEquals(returnDocs, ((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); }, e -> { fail("Model parsing failed " + e.getMessage()); }); - service.parseRequestConfig(randomInferenceEntityId, TaskType.RERANK, settings, modelListener); + service.parseRequestConfig( + randomInferenceEntityId, + TaskType.RERANK, + settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelListener + ); } } @@ -440,7 +474,13 @@ public void testParseRequestConfig_Rerank_DefaultTaskSettings() { assertEquals(Boolean.TRUE, ((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); }, e -> { fail("Model parsing failed " + e.getMessage()); }); - service.parseRequestConfig(randomInferenceEntityId, TaskType.RERANK, settings, modelListener); + service.parseRequestConfig( + randomInferenceEntityId, + TaskType.RERANK, + settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelListener + ); } } @@ -479,7 +519,13 @@ public void testParseRequestConfig_SparseEmbedding() { assertThat(model.getServiceSettings(), instanceOf(CustomElandInternalServiceSettings.class)); }, e -> { fail("Model parsing failed " + e.getMessage()); }); - service.parseRequestConfig(randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, settings, modelListener); + service.parseRequestConfig( + randomInferenceEntityId, + TaskType.SPARSE_EMBEDDING, + settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelListener + ); } private ActionListener getE5ModelVerificationActionListener(MultilingualE5SmallInternalServiceSettings e5ServiceSettings) { @@ -489,7 +535,8 @@ private ActionListener getE5ModelVerificationActionListener(MultilingualE randomInferenceEntityId, TaskType.TEXT_EMBEDDING, ElasticsearchInternalService.NAME, - e5ServiceSettings + e5ServiceSettings, + ModelConfigurations.FIRST_ENDPOINT_VERSION ), model ); @@ -513,7 +560,8 @@ private ActionListener getElserModelVerificationActionListener( TaskType.SPARSE_EMBEDDING, NAME, elserServiceSettings, - ElserMlNodeTaskSettings.DEFAULT + ElserMlNodeTaskSettings.DEFAULT, + ModelConfigurations.FIRST_ENDPOINT_VERSION ), model ); @@ -542,7 +590,12 @@ public void testParsePersistedConfig() { expectThrows( IllegalArgumentException.class, - () -> service.parsePersistedConfig(randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings) + () -> service.parsePersistedConfig( + randomInferenceEntityId, + TaskType.TEXT_EMBEDDING, + settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) ); } @@ -570,7 +623,8 @@ public void testParsePersistedConfig() { CustomElandEmbeddingModel parsedModel = (CustomElandEmbeddingModel) service.parsePersistedConfig( randomInferenceEntityId, TaskType.TEXT_EMBEDDING, - settings + settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); var elandServiceSettings = new CustomElandInternalTextEmbeddingServiceSettings(1, 4, "invalid", null); assertEquals( @@ -578,7 +632,8 @@ public void testParsePersistedConfig() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, ElasticsearchInternalService.NAME, - elandServiceSettings + elandServiceSettings, + ModelConfigurations.FIRST_ENDPOINT_VERSION ), parsedModel ); @@ -609,14 +664,16 @@ public void testParsePersistedConfig() { MultilingualE5SmallModel parsedModel = (MultilingualE5SmallModel) service.parsePersistedConfig( randomInferenceEntityId, TaskType.TEXT_EMBEDDING, - settings + settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertEquals( new MultilingualE5SmallModel( randomInferenceEntityId, TaskType.TEXT_EMBEDDING, ElasticsearchInternalService.NAME, - e5ServiceSettings + e5ServiceSettings, + ModelConfigurations.FIRST_ENDPOINT_VERSION ), parsedModel ); @@ -635,7 +692,10 @@ public void testParsePersistedConfig() { settings.put("not_a_valid_config_setting", randomAlphaOfLength(10)); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - expectThrows(IllegalArgumentException.class, () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings)); + expectThrows( + IllegalArgumentException.class, + () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings, ModelConfigurations.FIRST_ENDPOINT_VERSION) + ); } // Invalid service settings @@ -656,7 +716,10 @@ public void testParsePersistedConfig() { ) ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - expectThrows(IllegalArgumentException.class, () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings)); + expectThrows( + IllegalArgumentException.class, + () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings, ModelConfigurations.FIRST_ENDPOINT_VERSION) + ); } } @@ -681,7 +744,8 @@ public void testChunkInfer_e5() { "foo", TaskType.TEXT_EMBEDDING, "e5", - new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null) + new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); var service = createService(client); @@ -769,7 +833,8 @@ public void testChunkInfer_Sparse() { "foo", TaskType.SPARSE_EMBEDDING, "elasticsearch", - new ElasticsearchInternalServiceSettings(1, 1, "model-id", null) + new ElasticsearchInternalServiceSettings(1, 1, "model-id", null), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); var service = createService(client); @@ -832,7 +897,8 @@ public void testChunkInferSetsTokenization() { "foo", TaskType.TEXT_EMBEDDING, "e5", - new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null) + new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); var service = createService(client); @@ -889,7 +955,12 @@ public void testParsePersistedConfig_Rerank() { new HashMap<>(Map.of(CustomElandRerankTaskSettings.RETURN_DOCUMENTS, returnDocs)) ); - var model = service.parsePersistedConfig(randomInferenceEntityId, TaskType.RERANK, settings); + var model = service.parsePersistedConfig( + randomInferenceEntityId, + TaskType.RERANK, + settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model.getTaskSettings(), instanceOf(CustomElandRerankTaskSettings.class)); assertEquals(returnDocs, ((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); } @@ -913,7 +984,12 @@ public void testParsePersistedConfig_Rerank() { ); settings.put(ElasticsearchInternalServiceSettings.MODEL_ID, "foo"); - var model = service.parsePersistedConfig(randomInferenceEntityId, TaskType.RERANK, settings); + var model = service.parsePersistedConfig( + randomInferenceEntityId, + TaskType.RERANK, + settings, + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model.getTaskSettings(), instanceOf(CustomElandRerankTaskSettings.class)); assertTrue(((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); } @@ -952,7 +1028,7 @@ public void testParseRequestConfigEland_PreservesTaskType() { CustomElandModel expectedModel = getCustomElandModel(taskType); PlainActionFuture listener = new PlainActionFuture<>(); - service.parseRequestConfig(randomInferenceEntityId, taskType, settings, listener); + service.parseRequestConfig(randomInferenceEntityId, taskType, settings, ModelConfigurations.FIRST_ENDPOINT_VERSION, listener); var model = listener.actionGet(TimeValue.THIRTY_SECONDS); assertThat(model, is(expectedModel)); } @@ -965,7 +1041,8 @@ private CustomElandModel getCustomElandModel(TaskType taskType) { taskType, ElasticsearchInternalService.NAME, new CustomElandInternalServiceSettings(1, 4, "custom-model", null), - CustomElandRerankTaskSettings.DEFAULT_SETTINGS + CustomElandRerankTaskSettings.DEFAULT_SETTINGS, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } else if (taskType == TaskType.TEXT_EMBEDDING) { var serviceSettings = new CustomElandInternalTextEmbeddingServiceSettings(1, 4, "custom-model", null); @@ -974,14 +1051,16 @@ private CustomElandModel getCustomElandModel(TaskType taskType) { randomInferenceEntityId, taskType, ElasticsearchInternalService.NAME, - serviceSettings + serviceSettings, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } else if (taskType == TaskType.SPARSE_EMBEDDING) { expectedModel = new CustomElandModel( randomInferenceEntityId, taskType, ElasticsearchInternalService.NAME, - new CustomElandInternalServiceSettings(1, 4, "custom-model", null) + new CustomElandInternalServiceSettings(1, 4, "custom-model", null), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } return expectedModel; @@ -1031,7 +1110,8 @@ public void testPutModel() { "my-e5", TaskType.TEXT_EMBEDDING, "e5", - new MultilingualE5SmallInternalServiceSettings(1, 1, ".multilingual-e5-small", null) + new MultilingualE5SmallInternalServiceSettings(1, 1, ".multilingual-e5-small", null), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); service.putModel(model, new ActionListener<>() { @@ -1082,7 +1162,8 @@ public void testParseRequestConfigEland_SetsDimensionsToOne() { randomInferenceEntityId, taskType, ElasticsearchInternalService.NAME, - serviceSettings + serviceSettings, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); PlainActionFuture listener = new PlainActionFuture<>(); @@ -1099,7 +1180,8 @@ public void testParseRequestConfigEland_SetsDimensionsToOne() { null, SimilarityMeasure.COSINE, DenseVectorFieldMapper.ElementType.FLOAT - ) + ), + ModelConfigurations.FIRST_ENDPOINT_VERSION ), listener ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java index 00ca67ccdeab3..47a08a35296b6 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java @@ -125,6 +125,7 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioCompletionModel() throw new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -151,6 +152,7 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioEmbeddingsModel() throw new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -179,6 +181,7 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin createRandomChunkingSettingsMap(), getSecretSettingsMap(apiKey) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -209,6 +212,7 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenChun createRandomChunkingSettingsMap(), getSecretSettingsMap(apiKey) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -238,6 +242,7 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenChun new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -258,6 +263,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -276,7 +282,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -291,7 +297,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -310,7 +316,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -329,7 +335,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -348,7 +354,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioCompletion "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -375,7 +382,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioEmbeddings "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -405,7 +413,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioEmbeddings "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -436,7 +445,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioEmbeddings "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -466,7 +476,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChun "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -495,7 +506,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -525,7 +537,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -551,7 +564,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -581,7 +595,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -599,7 +614,12 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioCompletionModel() thr try (var service = createGoogleAiStudioService()) { var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), getTaskSettingsMapEmpty()); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -622,7 +642,12 @@ public void testParsePersistedConfig_CreatesAGoogleAiEmbeddingsModelWithoutChunk createRandomChunkingSettingsMap() ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -646,7 +671,12 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenCh createRandomChunkingSettingsMap() ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -666,7 +696,12 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenCh try (var service = createGoogleAiStudioService()) { var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), getTaskSettingsMapEmpty()); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -685,7 +720,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), getTaskSettingsMapEmpty()); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -705,7 +745,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe var persistedConfig = getPersistedConfigMap(serviceSettingsMap, getTaskSettingsMapEmpty()); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -725,7 +770,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), taskSettings); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.COMPLETION, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); 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..eefb0c839d834 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 @@ -9,6 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.ConfigurationParseContext; @@ -30,7 +31,8 @@ public void testCreateModel_AlwaysWithEmptyTaskSettings() { new HashMap<>(Map.of("model_id", "model")), new HashMap<>(Map.of()), null, - ConfigurationParseContext.PERSISTENT + ConfigurationParseContext.PERSISTENT, + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model.getTaskSettings(), is(EmptyTaskSettings.INSTANCE)); @@ -50,7 +52,8 @@ public static GoogleAiStudioCompletionModel createModel(String model, String api "service", new GoogleAiStudioCompletionServiceSettings(model, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -62,7 +65,9 @@ public static GoogleAiStudioCompletionModel createModel(String model, String url url, new GoogleAiStudioCompletionServiceSettings(model, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } } 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..2744c2f4e9f17 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 @@ -11,6 +11,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -26,7 +27,8 @@ public static GoogleAiStudioEmbeddingsModel createModel(String model, String api url, new GoogleAiStudioEmbeddingsServiceSettings(model, null, null, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -39,7 +41,8 @@ public static GoogleAiStudioEmbeddingsModel createModel(String model, ChunkingSe new GoogleAiStudioEmbeddingsServiceSettings(model, null, null, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, chunkingSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -57,7 +60,9 @@ public static GoogleAiStudioEmbeddingsModel createModel( url, new GoogleAiStudioEmbeddingsServiceSettings(model, null, dimensions, similarityMeasure, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -74,7 +79,9 @@ public static GoogleAiStudioEmbeddingsModel createModel( new GoogleAiStudioEmbeddingsServiceSettings(model, tokenLimit, dimensions, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java index 3ec6c08082ba0..f17c2cf5a8d8e 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java @@ -102,6 +102,7 @@ public void testParseRequestConfig_CreatesGoogleVertexAiEmbeddingsModel() throws new HashMap<>(Map.of()), getSecretSettingsMap(serviceAccountJson) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -133,6 +134,7 @@ public void testParseRequestConfig_CreatesGoogleVertexAiRerankModel() throws IOE new HashMap<>(Map.of()), getSecretSettingsMap(serviceAccountJson) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -162,6 +164,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("{}") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -189,7 +192,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -213,7 +216,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -241,7 +244,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -269,7 +272,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -306,7 +309,8 @@ public void testParsePersistedConfigWithSecrets_CreatesGoogleVertexAiEmbeddingsM "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -337,7 +341,13 @@ public void testParsePersistedConfigWithSecrets_CreatesGoogleVertexAiRerankModel getSecretSettingsMap(serviceAccountJson) ); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.RERANK, persistedConfig.config(), persistedConfig.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.RERANK, + persistedConfig.config(), + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(GoogleVertexAiRerankModel.class)); @@ -382,7 +392,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -433,7 +444,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -484,7 +496,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -535,7 +548,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); 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..59705de730531 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 @@ -10,6 +10,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -59,7 +60,9 @@ public static GoogleVertexAiEmbeddingsModel createModel( uri, new GoogleVertexAiEmbeddingsServiceSettings(location, projectId, modelId, false, null, null, null, null), new GoogleVertexAiEmbeddingsTaskSettings(Boolean.FALSE), - new GoogleVertexAiSecretSettings(new SecureString(serviceAccountJson.toCharArray())) + new GoogleVertexAiSecretSettings(new SecureString(serviceAccountJson.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -79,7 +82,9 @@ public static GoogleVertexAiEmbeddingsModel createModel(String modelId, @Nullabl null ), new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate), - new GoogleVertexAiSecretSettings(new SecureString(randomAlphaOfLength(8).toCharArray())) + new GoogleVertexAiSecretSettings(new SecureString(randomAlphaOfLength(8).toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } 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..007c882f20827 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 @@ -9,6 +9,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.googlevertexai.GoogleVertexAiSecretSettings; @@ -45,7 +46,9 @@ public static GoogleVertexAiRerankModel createModel(@Nullable String modelId, @N "service", new GoogleVertexAiRerankServiceSettings(randomAlphaOfLength(10), modelId, null), new GoogleVertexAiRerankTaskSettings(topN), - new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)) + new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -57,7 +60,9 @@ public static GoogleVertexAiRerankModel createModel(String url, @Nullable String url, new GoogleVertexAiRerankServiceSettings(randomAlphaOfLength(10), modelId, null), new GoogleVertexAiRerankTaskSettings(topN), - new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)) + new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java index 8659b811f948e..4ca754ae020ee 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java @@ -107,6 +107,7 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModel() throws IOException "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), getSecretSettingsMap("secret")), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -131,6 +132,7 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap(), getSecretSettingsMap("secret")), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -152,6 +154,7 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsP "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap(), getSecretSettingsMap("secret")), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -173,6 +176,7 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsN "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), getSecretSettingsMap("secret")), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -192,6 +196,7 @@ public void testParseRequestConfig_CreatesAnElserModel() throws IOException { "id", TaskType.SPARSE_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), getSecretSettingsMap("secret")), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -213,7 +218,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationActionListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationActionListener + ); } } @@ -235,7 +246,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationActionListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationActionListener + ); } } @@ -257,7 +274,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationActionListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationActionListener + ); } } @@ -269,7 +292,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModel() throw "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -295,7 +319,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWithoutC "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -322,7 +347,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChun "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -344,7 +370,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChun "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -364,7 +391,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnElserModel() throws IOE "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceElserModel.class)); @@ -384,7 +412,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -406,7 +435,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -426,7 +456,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -448,7 +479,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -470,7 +502,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -485,7 +518,12 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModel() throws IOExcepti try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url")); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -501,7 +539,12 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWithoutChunkingSett try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap()); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -517,7 +560,12 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSetting try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap()); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -533,7 +581,12 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSetting try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url")); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -548,7 +601,12 @@ public void testParsePersistedConfig_CreatesAnElserModel() throws IOException { try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url"), new HashMap<>()); - var model = service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.SPARSE_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(HuggingFaceElserModel.class)); @@ -563,7 +621,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url")); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -580,7 +643,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe var persistedConfig = getPersistedConfigMap(serviceSettingsMap); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -597,7 +665,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url"), taskSettingsMap, null); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java index d7a62256f8d9c..6b0f2040e0e2f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.huggingface.elser; import org.elasticsearch.common.settings.SecureString; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings; @@ -27,7 +28,8 @@ public static HuggingFaceElserModel createModel(String url, String apiKey) { TaskType.SPARSE_EMBEDDING, "service", new HuggingFaceElserServiceSettings(url), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -37,7 +39,8 @@ public static HuggingFaceElserModel createModel(String url, String apiKey, Strin TaskType.SPARSE_EMBEDDING, "service", new HuggingFaceElserServiceSettings(url), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } } 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..7bdbdaa77c038 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 @@ -9,6 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -32,7 +33,8 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey) "service", new HuggingFaceServiceSettings(url), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -43,7 +45,9 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey, "service", new HuggingFaceServiceSettings(createUri(url), null, null, tokenLimit, null), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -54,7 +58,9 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey, "service", new HuggingFaceServiceSettings(createUri(url), null, dimensions, tokenLimit, null), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } @@ -71,7 +77,9 @@ public static HuggingFaceEmbeddingsModel createModel( "service", new HuggingFaceServiceSettings(createUri(url), similarityMeasure, dimensions, tokenLimit, null), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java index 58f1d158468e0..bbdee3b5ee3ce 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java @@ -138,6 +138,7 @@ public void testParseRequestConfig_CreatesAIbmWatsonxEmbeddingsModel() throws IO new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -158,6 +159,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -189,7 +191,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [watsonxai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -216,7 +218,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAIbmWatsonxEmbeddingsMode "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -255,7 +258,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -296,7 +300,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -333,7 +338,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -377,7 +383,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java index 93fd7e402a0de..7c8e2dd1135fe 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -33,7 +34,8 @@ public static IbmWatsonxEmbeddingsModel createModel( url, new IbmWatsonxEmbeddingsServiceSettings(model, projectId, uri, apiVersion, null, null, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -54,7 +56,8 @@ public static IbmWatsonxEmbeddingsModel createModel( url, new IbmWatsonxEmbeddingsServiceSettings(model, projectId, uri, apiVersion, null, dimensions, similarityMeasure, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -82,7 +85,8 @@ public static IbmWatsonxEmbeddingsModel createModel( null ), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java index b1e55b8bf24f9..b3b6f01ad17fa 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java @@ -116,6 +116,7 @@ public void testParseRequestConfig_CreatesAMistralEmbeddingsModel() throws IOExc getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -142,6 +143,7 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -170,6 +172,7 @@ public void testParseRequestConfig_CreatesAMistralEmbeddingsModelWhenChunkingSet createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -197,6 +200,7 @@ public void testParseRequestConfig_CreatesAMistralEmbeddingsModelWhenChunkingSet getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -220,6 +224,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -245,7 +250,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -271,7 +282,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingTaskSett } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -297,7 +314,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingSecretSe } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -309,7 +332,13 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModel() throws IOE getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -331,7 +360,13 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWithoutChunki getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -355,7 +390,13 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWhenChunkingS getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -378,7 +419,13 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWhenChunkingS getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -409,6 +456,7 @@ public void testParsePersistedConfig_ThrowsUnsupportedModelType() throws IOExcep getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -424,7 +472,13 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfigWithSecrets("id", TaskType.SPARSE_EMBEDDING, config.config(), config.secrets()) + () -> service.parsePersistedConfigWithSecrets( + "id", + TaskType.SPARSE_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) ); assertThat( @@ -442,7 +496,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); config.config().put("extra_key", "value"); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); } @@ -457,7 +517,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenExtraKeyExistsInEmbeddingSe var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); } @@ -472,7 +538,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); } @@ -487,7 +559,13 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + config.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); } @@ -501,7 +579,12 @@ public void testParsePersistedConfig_WithoutSecretsCreatesEmbeddingsModel() thro Map.of() ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -523,7 +606,12 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWitho Map.of() ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -546,7 +634,12 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWhenC Map.of() ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -568,7 +661,12 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWhenC Map.of() ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + config.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java index 6f8b40fd7f19c..e881a04383ab6 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java @@ -11,6 +11,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -39,7 +40,8 @@ public static MistralEmbeddingsModel createModel( new MistralEmbeddingsServiceSettings(model, dimensions, maxTokens, similarity, rateLimitSettings), EmptyTaskSettings.INSTANCE, chunkingSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -59,7 +61,8 @@ public static MistralEmbeddingsModel createModel( new MistralEmbeddingsServiceSettings(model, dimensions, maxTokens, similarity, rateLimitSettings), EmptyTaskSettings.INSTANCE, null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java index cf1438b334478..350778f47e8d1 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java @@ -22,6 +22,7 @@ import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -125,6 +126,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModel() throws IOExc getTaskSettingsMap("user"), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -159,6 +161,7 @@ public void testParseRequestConfig_CreatesAnOpenAiChatCompletionsModel() throws getTaskSettingsMap(user), getSecretSettingsMap(secret) ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -182,6 +185,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getTaskSettingsMap("user"), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -207,7 +211,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -225,7 +235,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa assertThat(e.getMessage(), is("Model configuration contains settings [{extra_key=value}] unknown to the [openai] service")); }); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -243,7 +259,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() assertThat(e.getMessage(), is("Model configuration contains settings [{extra_key=value}] unknown to the [openai] service")); }); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -261,7 +283,13 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap assertThat(e.getMessage(), is("Model configuration contains settings [{extra_key=value}] unknown to the [openai] service")); }); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + config, + ModelConfigurations.FIRST_ENDPOINT_VERSION, + modelVerificationListener + ); } } @@ -282,6 +310,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModelWithoutUserUrlO "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("model", null, null), getTaskSettingsMap(null), getSecretSettingsMap("secret")), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -308,6 +337,7 @@ public void testParseRequestConfig_CreatesAnOpenAiChatCompletionsModelWithoutUse "id", TaskType.COMPLETION, getRequestConfigMap(getServiceSettingsMap(model, null, null), getTaskSettingsMap(null), getSecretSettingsMap(secret)), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -334,6 +364,7 @@ public void testParseRequestConfig_MovesModel() throws IOException { getTaskSettingsMap("user"), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -360,6 +391,7 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -390,6 +422,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingSet createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -415,6 +448,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingSet "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("model", null, null), getTaskSettingsMap(null), getSecretSettingsMap("secret")), + ModelConfigurations.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -432,7 +466,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModel() "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -460,7 +495,8 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ) ); @@ -483,7 +519,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWi "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -512,7 +549,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWi "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -542,7 +580,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWh "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -571,7 +610,8 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWh "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -599,7 +639,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -629,7 +670,8 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -656,7 +698,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -682,7 +725,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -711,7 +755,8 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets() + persistedConfig.secrets(), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -732,7 +777,12 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModel() throws IOE getTaskSettingsMap("user") ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -751,7 +801,12 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()) + () -> service.parsePersistedConfig( + "id", + TaskType.SPARSE_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ) ); assertThat( @@ -768,7 +823,12 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWithoutUserUr getTaskSettingsMap(null) ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -791,7 +851,12 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWithoutChunki createRandomChunkingSettingsMap() ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -815,7 +880,12 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingS createRandomChunkingSettingsMap() ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -838,7 +908,12 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingS getTaskSettingsMap(null) ); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -860,7 +935,12 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() ); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -880,7 +960,12 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var persistedConfig = getPersistedConfigMap(serviceSettingsMap, getTaskSettingsMap("user")); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -900,7 +985,12 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("model", "url", "org", null, null, true), taskSettingsMap); - var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + ModelConfigurations.FIRST_ENDPOINT_VERSION + ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java index ab1786f0a5843..33bc3fa8e6591 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings; @@ -59,7 +60,8 @@ public static OpenAiChatCompletionModel createChatCompletionModel( "service", new OpenAiChatCompletionServiceSettings(modelName, url, org, null, null), new OpenAiChatCompletionTaskSettings(user), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java index 0e9179792b92b..d5c6e8614dfa5 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -63,7 +64,8 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, 1536, null, false, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -82,7 +84,8 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, 1536, null, false, null), new OpenAiEmbeddingsTaskSettings(user), chunkingSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -100,7 +103,8 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, 1536, null, false, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -119,7 +123,8 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, 1536, tokenLimit, false, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -139,7 +144,8 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, dimensions, tokenLimit, false, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } @@ -161,7 +167,8 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, similarityMeasure, dimensions, tokenLimit, dimensionsSetByUser, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), + ModelConfigurations.FIRST_ENDPOINT_VERSION ); } } From 7f113469ae40eb9f8701fc16c13e4668519619f8 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Fri, 4 Oct 2024 17:10:05 -0400 Subject: [PATCH 03/15] Add mappings for endpoint_version --- .../xpack/inference/InferenceIndex.java | 53 ++++++++++++++++++- .../xpack/inference/InferencePlugin.java | 14 ++++- .../TransportPutInferenceModelAction.java | 10 +++- 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java index 1c93494d78636..d4a2db3affd8e 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java @@ -10,6 +10,7 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.indices.SystemIndexDescriptor; +import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.xcontent.XContentBuilder; import java.io.IOException; @@ -27,7 +28,7 @@ private InferenceIndex() {} public static final String INDEX_ALIAS = ".inference-alias"; // Increment this version number when the mappings change - private static final int INDEX_MAPPING_VERSION = 2; + private static final int INDEX_MAPPING_VERSION = 3; public static Settings settings() { return Settings.builder() @@ -58,6 +59,56 @@ public static Settings settings() { * @return The index mappings */ public static XContentBuilder mappings() { + try { + var jsonBuilder = jsonBuilder().startObject().startObject(SINGLE_MAPPING_NAME); + { + jsonBuilder.startObject("_meta").field(SystemIndexDescriptor.VERSION_META_KEY, INDEX_MAPPING_VERSION).endObject(); + + jsonBuilder.field("dynamic", "strict"); + + jsonBuilder.startObject("properties"); + { + jsonBuilder.startObject("model_id").field("type", "keyword").endObject(); + + jsonBuilder.startObject("task_type").field("type", "keyword").endObject(); + + jsonBuilder.startObject("service").field("type", "keyword").endObject(); + + jsonBuilder.startObject("service_settings").field("dynamic", "false"); + { + jsonBuilder.startObject("properties").endObject(); + } + jsonBuilder.endObject(); + + jsonBuilder.startObject("task_settings").field("dynamic", "false"); + { + jsonBuilder.startObject("properties").endObject(); + } + jsonBuilder.endObject(); + + jsonBuilder.startObject("chunking_settings"); + { + jsonBuilder.field("dynamic", "false"); + jsonBuilder.startObject("properties"); + { + jsonBuilder.startObject("strategy").field("type", "keyword").endObject(); + } + jsonBuilder.endObject(); + } + jsonBuilder.endObject(); + + jsonBuilder.startObject("endpoint_version").field("dynamic", "false").field("type", "keyword").endObject(); + } + jsonBuilder.endObject().endObject().endObject(); + } + + return jsonBuilder; + } catch (IOException e) { + throw new UncheckedIOException("Failed to build mappings for index " + INDEX_NAME, e); + } + } + + public static XContentBuilder mappingsV2() { try { return jsonBuilder().startObject() .startObject(SINGLE_MAPPING_NAME) diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java index dbb9130ab91e1..6e68d2c5a89e9 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java @@ -259,6 +259,18 @@ public List getNamedWriteables() { @Override public Collection getSystemIndexDescriptors(Settings settings) { + var inferenceIndexV2Descriptor = SystemIndexDescriptor.builder() + .setType(SystemIndexDescriptor.Type.INTERNAL_MANAGED) + .setIndexPattern(InferenceIndex.INDEX_PATTERN) + .setAliasName(InferenceIndex.INDEX_ALIAS) + .setPrimaryIndex(InferenceIndex.INDEX_NAME) + .setDescription("Contains inference service and model configuration") + .setMappings(InferenceIndex.mappingsV2()) + .setSettings(InferenceIndex.settings()) + .setVersionMetaKey("version") + .setOrigin(ClientHelper.INFERENCE_ORIGIN) + .build(); + var inferenceIndexV1Descriptor = SystemIndexDescriptor.builder() .setType(SystemIndexDescriptor.Type.INTERNAL_MANAGED) .setIndexPattern(InferenceIndex.INDEX_PATTERN) @@ -282,7 +294,7 @@ public Collection getSystemIndexDescriptors(Settings sett .setSettings(InferenceIndex.settings()) .setVersionMetaKey("version") .setOrigin(ClientHelper.INFERENCE_ORIGIN) - .setPriorSystemIndexDescriptors(List.of(inferenceIndexV1Descriptor)) + .setPriorSystemIndexDescriptors(List.of(inferenceIndexV1Descriptor, inferenceIndexV2Descriptor)) .build(), SystemIndexDescriptor.builder() .setType(SystemIndexDescriptor.Type.INTERNAL_MANAGED) 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 7ca2ca486d4c9..4a6fb5054c494 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 { From 6432240fc3d53c0ab845ca15fcd422690351c5eb Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Fri, 4 Oct 2024 17:15:18 -0400 Subject: [PATCH 04/15] start to handle mixed cluster failures for new mapping --- .../inference/qa/mixed/OpenAIServiceMixedIT.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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"); From 84c75f1cc3fd8e26fc769aa51ace6175a30d5536 Mon Sep 17 00:00:00 2001 From: Max Hniebergall <137079448+maxhniebergall@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:17:22 -0400 Subject: [PATCH 05/15] Update docs/changelog/114176.yaml --- docs/changelog/114176.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docs/changelog/114176.yaml diff --git a/docs/changelog/114176.yaml b/docs/changelog/114176.yaml new file mode 100644 index 0000000000000..1c21f69a78494 --- /dev/null +++ b/docs/changelog/114176.yaml @@ -0,0 +1,11 @@ +pr: 114176 +summary: "[Inference API ] Add `endpoint_version` to deprecate task settings" +area: Machine Learning +type: deprecation +issues: [] +deprecation: + title: "[Inference API ] Add `endpoint_version` to deprecate task settings" + area: Machine Learning + details: Please describe the details of this change for the release notes. You can + use asciidoc. + impact: Please describe the impact of this change to users From 388c475a01f7479092b604e8f167edfe43028862 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Mon, 7 Oct 2024 11:41:22 -0400 Subject: [PATCH 06/15] Only write EndpointVersion to index --- .../elasticsearch/inference/ModelConfigurations.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java index b21e965fd1707..9b9f1c1ff45e1 100644 --- a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java +++ b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java @@ -25,7 +25,7 @@ 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 OLD_TASK_SETTINGS = "task_settings"; @@ -194,7 +194,7 @@ public String getEndpointVersion() { @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); @@ -209,7 +209,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters builder.field(PARAMETERS, taskSettings); } - builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); + if (params.paramAsBoolean(FOR_INDEX, false)) { + builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); // only write endpoint version for index, not for REST + } builder.endObject(); return builder; } @@ -217,7 +219,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); @@ -232,7 +234,9 @@ public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters builder.field(PARAMETERS, taskSettings); } + if (params.paramAsBoolean(FOR_INDEX, false)) { builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); + } builder.endObject(); return builder; } From 104ab7c9f0f682b8fae0fb5445021dad5779b3c2 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Mon, 7 Oct 2024 11:53:00 -0400 Subject: [PATCH 07/15] Refactor EndpointVersion into enum instead of string --- .../inference/EndpointVersions.java | 25 ++++++ .../inference/InferenceService.java | 6 +- .../inference/ModelConfigurations.java | 22 +++--- .../inference/UnparsedModel.java | 2 +- .../action/PutInferenceModelAction.java | 9 +-- .../action/PutInferenceModelActionTests.java | 4 +- .../mock/AbstractTestInferenceService.java | 7 +- .../TestDenseInferenceServiceExtension.java | 5 +- .../mock/TestRerankingServiceExtension.java | 5 +- .../TestSparseInferenceServiceExtension.java | 5 +- ...stStreamingCompletionServiceExtension.java | 3 +- .../integration/ModelRegistryIT.java | 63 +++++++-------- .../xpack/inference/InferenceIndex.java | 11 ++- .../TransportPutInferenceModelAction.java | 3 +- .../inference/registry/ModelRegistry.java | 9 ++- .../AlibabaCloudSearchService.java | 11 +-- .../AlibabaCloudSearchCompletionModel.java | 5 +- .../AlibabaCloudSearchEmbeddingsModel.java | 5 +- .../rerank/AlibabaCloudSearchRerankModel.java | 5 +- .../sparse/AlibabaCloudSearchSparseModel.java | 5 +- .../amazonbedrock/AmazonBedrockService.java | 9 ++- .../AmazonBedrockChatCompletionModel.java | 5 +- .../AmazonBedrockEmbeddingsModel.java | 5 +- .../services/anthropic/AnthropicService.java | 11 +-- .../AnthropicChatCompletionModel.java | 7 +- .../azureaistudio/AzureAiStudioService.java | 16 ++-- .../AzureAiStudioChatCompletionModel.java | 5 +- .../AzureAiStudioEmbeddingsModel.java | 5 +- .../azureopenai/AzureOpenAiService.java | 11 +-- .../AzureOpenAiCompletionModel.java | 5 +- .../AzureOpenAiEmbeddingsModel.java | 5 +- .../services/cohere/CohereService.java | 11 +-- .../completion/CohereCompletionModel.java | 5 +- .../embeddings/CohereEmbeddingsModel.java | 5 +- .../cohere/rerank/CohereRerankModel.java | 5 +- .../elastic/ElasticInferenceService.java | 16 ++-- ...InferenceServiceSparseEmbeddingsModel.java | 5 +- .../CustomElandEmbeddingModel.java | 3 +- .../elasticsearch/CustomElandModel.java | 5 +- .../elasticsearch/CustomElandRerankModel.java | 3 +- .../ElasticsearchInternalModel.java | 5 +- .../ElasticsearchInternalService.java | 22 ++++-- .../elasticsearch/ElserInternalModel.java | 3 +- .../MultilingualE5SmallModel.java | 3 +- .../googleaistudio/GoogleAiStudioService.java | 16 ++-- .../GoogleAiStudioCompletionModel.java | 7 +- .../GoogleAiStudioEmbeddingsModel.java | 9 ++- .../googlevertexai/GoogleVertexAiService.java | 16 ++-- .../GoogleVertexAiEmbeddingsModel.java | 7 +- .../rerank/GoogleVertexAiRerankModel.java | 7 +- .../huggingface/HuggingFaceBaseService.java | 9 ++- .../huggingface/HuggingFaceService.java | 3 +- .../elser/HuggingFaceElserModel.java | 5 +- .../elser/HuggingFaceElserService.java | 3 +- .../HuggingFaceEmbeddingsModel.java | 5 +- .../ibmwatsonx/IbmWatsonxService.java | 16 ++-- .../embeddings/IbmWatsonxEmbeddingsModel.java | 7 +- .../services/mistral/MistralService.java | 11 +-- .../embeddings/MistralEmbeddingsModel.java | 5 +- .../services/openai/OpenAiService.java | 11 +-- .../completion/OpenAiChatCompletionModel.java | 5 +- .../embeddings/OpenAiEmbeddingsModel.java | 5 +- .../inference/ModelConfigurationsTests.java | 13 ++- .../elasticsearch/xpack/inference/Utils.java | 5 +- .../TransportInferenceUsageActionTests.java | 13 +-- .../ShardBulkInferenceActionFilterTests.java | 8 +- .../AzureOpenAiActionCreatorTests.java | 8 +- .../AzureOpenAiCompletionActionTests.java | 4 +- ...ureAiStudioChatCompletionRequestTests.java | 4 +- .../AzureOpenAiCompletionRequestTests.java | 4 +- .../xpack/inference/model/TestModel.java | 5 +- .../TextSimilarityTestPlugin.java | 3 +- .../registry/ModelRegistryTests.java | 17 ++-- .../services/SenderServiceTests.java | 12 ++- .../AlibabaCloudSearchServiceTests.java | 5 +- ...libabaCloudSearchCompletionModelTests.java | 6 +- ...libabaCloudSearchEmbeddingsModelTests.java | 6 +- .../AlibabaCloudSearchSparseModelTests.java | 6 +- .../AmazonBedrockServiceTests.java | 47 +++++------ ...AmazonBedrockChatCompletionModelTests.java | 4 +- .../AmazonBedrockEmbeddingsModelTests.java | 4 +- .../anthropic/AnthropicServiceTests.java | 32 ++++---- .../AnthropicChatCompletionModelTests.java | 6 +- .../AzureAiStudioServiceTests.java | 64 +++++++-------- ...AzureAiStudioChatCompletionModelTests.java | 24 +++--- .../AzureAiStudioEmbeddingsModelTests.java | 4 +- .../azureopenai/AzureOpenAiServiceTests.java | 39 ++++----- .../AzureOpenAiCompletionModelTests.java | 22 +++--- .../AzureOpenAiEmbeddingsModelTests.java | 6 +- .../services/cohere/CohereServiceTests.java | 45 +++++------ .../CohereCompletionModelTests.java | 6 +- .../CohereEmbeddingsModelTests.java | 6 +- ...enceServiceSparseEmbeddingsModelTests.java | 4 +- .../elastic/ElasticInferenceServiceTests.java | 48 +++-------- .../ElasticsearchInternalServiceTests.java | 79 ++++++++----------- .../GoogleAiStudioServiceTests.java | 53 +++++++------ .../GoogleAiStudioCompletionModelTests.java | 8 +- .../GoogleAiStudioEmbeddingsModelTests.java | 10 +-- .../GoogleVertexAiServiceTests.java | 27 ++++--- .../GoogleVertexAiEmbeddingsModelTests.java | 6 +- .../GoogleVertexAiRerankModelTests.java | 6 +- .../huggingface/HuggingFaceServiceTests.java | 53 +++++++------ .../elser/HuggingFaceElserModelTests.java | 6 +- .../HuggingFaceEmbeddingsModelTests.java | 10 +-- .../ibmwatsonx/IbmWatsonxServiceTests.java | 17 ++-- .../IbmWatsonxEmbeddingsModelTests.java | 8 +- .../services/mistral/MistralServiceTests.java | 45 +++++------ .../MistralEmbeddingModelTests.java | 6 +- .../services/openai/OpenAiServiceTests.java | 68 ++++++++-------- .../OpenAiChatCompletionModelTests.java | 4 +- .../OpenAiEmbeddingsModelTests.java | 14 ++-- 111 files changed, 765 insertions(+), 667 deletions(-) create mode 100644 server/src/main/java/org/elasticsearch/inference/EndpointVersions.java diff --git a/server/src/main/java/org/elasticsearch/inference/EndpointVersions.java b/server/src/main/java/org/elasticsearch/inference/EndpointVersions.java new file mode 100644 index 0000000000000..9e7bd8b3b230e --- /dev/null +++ b/server/src/main/java/org/elasticsearch/inference/EndpointVersions.java @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +package org.elasticsearch.inference; + +public enum EndpointVersions { + FIRST_ENDPOINT_VERSION("2023-09-29"), + PARAMETERS_INTRODUCED_ENDPOINT_VERSION("2024-10-17"); + + private final String name; + + EndpointVersions(String s) { + name = s; + } + + public String toString() { + return this.name; + } +} diff --git a/server/src/main/java/org/elasticsearch/inference/InferenceService.java b/server/src/main/java/org/elasticsearch/inference/InferenceService.java index 6fa721d939861..950edaa828f10 100644 --- a/server/src/main/java/org/elasticsearch/inference/InferenceService.java +++ b/server/src/main/java/org/elasticsearch/inference/InferenceService.java @@ -46,7 +46,7 @@ void parseRequestConfig( String modelId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ); @@ -69,7 +69,7 @@ Model parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ); /** @@ -84,7 +84,7 @@ Model parsePersistedConfigWithSecrets( * @param endpointVersion * @return The parsed {@link Model} */ - Model parsePersistedConfig(String modelId, TaskType taskType, Map config, String endpointVersion); + Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion); /** * Perform inference on the model. diff --git a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java index 9b9f1c1ff45e1..5e3d11cf983c3 100644 --- a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java +++ b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java @@ -33,8 +33,6 @@ public class ModelConfigurations implements ToFilteredXContentObject, VersionedN public static final String CHUNKING_SETTINGS = "chunking_settings"; public static final String INCLUDE_PARAMETERS = "include_parameters"; public static final String ENDPOINT_VERSION_FIELD_NAME = "endpoint_version"; - public static final String FIRST_ENDPOINT_VERSION = "2023-09-29"; - public static final String PARAMETERS_INTRODUCED_ENDPOINT_VERSION = "2024-10-17"; private static final String NAME = "inference_model"; public static ModelConfigurations of(Model model, TaskSettings taskSettings) { @@ -73,7 +71,7 @@ public static ModelConfigurations of(Model model, ServiceSettings serviceSetting private final ServiceSettings serviceSettings; private final TaskSettings taskSettings; private final ChunkingSettings chunkingSettings; - private final String endpointVersion; + private final EndpointVersions endpointVersion; /** * Allows no task settings to be defined. This will default to the {@link EmptyTaskSettings} object. @@ -83,7 +81,7 @@ public ModelConfigurations( TaskType taskType, String service, ServiceSettings serviceSettings, - String endpointVersion + EndpointVersions endpointVersion ) { this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE, endpointVersion); } @@ -94,7 +92,7 @@ public ModelConfigurations( String service, ServiceSettings serviceSettings, ChunkingSettings chunkingSettings, - String endpointVersion + EndpointVersions endpointVersion ) { this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE, chunkingSettings, endpointVersion); } @@ -105,7 +103,7 @@ public ModelConfigurations( String service, ServiceSettings serviceSettings, TaskSettings taskSettings, - String endpointVersion + EndpointVersions endpointVersion ) { this.inferenceEntityId = Objects.requireNonNull(inferenceEntityId); this.taskType = Objects.requireNonNull(taskType); @@ -123,7 +121,7 @@ public ModelConfigurations( ServiceSettings serviceSettings, TaskSettings taskSettings, ChunkingSettings chunkingSettings, - String endpointVersion + EndpointVersions endpointVersion ) { this.inferenceEntityId = Objects.requireNonNull(inferenceEntityId); this.taskType = Objects.requireNonNull(taskType); @@ -144,8 +142,8 @@ public ModelConfigurations(StreamInput in) throws IOException { ? in.readOptionalNamedWriteable(ChunkingSettings.class) : null; this.endpointVersion = in.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_API_PARAMATERS_INTRODUCED) - ? Objects.requireNonNullElse(in.readOptionalString(), FIRST_ENDPOINT_VERSION) - : FIRST_ENDPOINT_VERSION; + ? Objects.requireNonNullElse(in.readEnum(EndpointVersions.class), EndpointVersions.FIRST_ENDPOINT_VERSION) + : EndpointVersions.FIRST_ENDPOINT_VERSION; } @Override @@ -159,7 +157,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalNamedWriteable(chunkingSettings); } if (out.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_API_PARAMATERS_INTRODUCED)) { - out.writeOptionalString(endpointVersion); // not nullable after 9.0 + out.writeEnum(endpointVersion); // not nullable after 9.0 } } @@ -187,7 +185,7 @@ public ChunkingSettings getChunkingSettings() { return chunkingSettings; } - public String getEndpointVersion() { + public EndpointVersions getEndpointVersion() { return endpointVersion; } @@ -235,7 +233,7 @@ public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params builder.field(PARAMETERS, taskSettings); } if (params.paramAsBoolean(FOR_INDEX, false)) { - builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); + builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); } builder.endObject(); return builder; diff --git a/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java b/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java index 409b6d1aa8b39..a6011bcb26cd1 100644 --- a/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java +++ b/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java @@ -21,5 +21,5 @@ public record UnparsedModel( String service, Map settings, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) {} 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 82b19a6ea5157..1ae824cf498d8 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 @@ -16,6 +16,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentHelper; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.rest.RestStatus; @@ -31,10 +32,8 @@ import java.util.Objects; import static org.elasticsearch.inference.ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME; -import static org.elasticsearch.inference.ModelConfigurations.FIRST_ENDPOINT_VERSION; import static org.elasticsearch.inference.ModelConfigurations.OLD_TASK_SETTINGS; import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; -import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS_INTRODUCED_ENDPOINT_VERSION; public class PutInferenceModelAction extends ActionType { @@ -91,12 +90,12 @@ public BytesReference getRewrittenContent() { ); } else if (newContent.containsKey(PARAMETERS)) { newContent.put(OLD_TASK_SETTINGS, newContent.get(PARAMETERS)); - newContent.put(ENDPOINT_VERSION_FIELD_NAME, PARAMETERS_INTRODUCED_ENDPOINT_VERSION); + newContent.put(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.PARAMETERS_INTRODUCED_ENDPOINT_VERSION); newContent.remove(PARAMETERS); } else if (newContent.containsKey(OLD_TASK_SETTINGS)) { - newContent.put(ENDPOINT_VERSION_FIELD_NAME, FIRST_ENDPOINT_VERSION); + newContent.put(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.FIRST_ENDPOINT_VERSION); } else { - newContent.put(ENDPOINT_VERSION_FIELD_NAME, FIRST_ENDPOINT_VERSION); + newContent.put(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.FIRST_ENDPOINT_VERSION); } try (XContentBuilder builder = XContentFactory.contentBuilder(this.contentType)) { builder.map(newContent); 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 93d5c00aaa705..1d0da27acd388 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 @@ -12,6 +12,7 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.XContentHelper; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xcontent.XContentBuilder; @@ -25,7 +26,6 @@ import java.util.Map; import static org.elasticsearch.inference.ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME; -import static org.elasticsearch.inference.ModelConfigurations.FIRST_ENDPOINT_VERSION; import static org.elasticsearch.inference.ModelConfigurations.OLD_TASK_SETTINGS; import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; @@ -117,6 +117,6 @@ public void testWithTaskSettings() throws IOException { assertNull(map.get(PARAMETERS)); assertEquals("elasticsearch", map.get("service")); assertEquals(serviceSettingsValues, map.get("service_settings")); - assertEquals(ENDPOINT_VERSION_FIELD_NAME, FIRST_ENDPOINT_VERSION); + assertEquals(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.FIRST_ENDPOINT_VERSION); } } diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java index 9c41b00df7009..ef57705612d95 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java @@ -12,6 +12,7 @@ import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; @@ -60,7 +61,7 @@ public TestServiceModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); var secretSettingsMap = (Map) secrets.remove(ModelSecrets.SECRET_SETTINGS); @@ -76,7 +77,7 @@ public TestServiceModel parsePersistedConfigWithSecrets( @Override @SuppressWarnings("unchecked") - public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); var serviceSettings = getServiceSettingsFromMap(serviceSettingsMap); @@ -106,7 +107,7 @@ public TestServiceModel( ServiceSettings serviceSettings, TestTaskSettings taskSettings, TestSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), 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 8c42fb7226ac2..ca582ca06fd8b 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 @@ -18,6 +18,7 @@ import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -46,7 +47,7 @@ public List getInferenceServiceFactories() { } public static class TestDenseModel extends Model { - public TestDenseModel(String inferenceEntityId, TestServiceSettings serviceSettings, String endpointVersion) { + public TestDenseModel(String inferenceEntityId, TestServiceSettings serviceSettings, EndpointVersions endpointVersion) { super( new ModelConfigurations( inferenceEntityId, @@ -76,7 +77,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java index f51fd4c71ad10..f7482779c7fd0 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java @@ -17,6 +17,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -42,7 +43,7 @@ public List getInferenceServiceFactories() { } public static class TestRerankingModel extends Model { - public TestRerankingModel(String inferenceEntityId, TestServiceSettings serviceSettings, String endpointVersion) { + public TestRerankingModel(String inferenceEntityId, TestServiceSettings serviceSettings, EndpointVersions endpointVersion) { super( new ModelConfigurations(inferenceEntityId, TaskType.RERANK, TestInferenceService.NAME, serviceSettings, endpointVersion), new ModelSecrets(new AbstractTestInferenceService.TestSecretSettings("api_key")) @@ -66,7 +67,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java index 2b7360f97e455..9939fb409665b 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java @@ -17,6 +17,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -45,7 +46,7 @@ public List getInferenceServiceFactories() { } public static class TestSparseModel extends Model { - public TestSparseModel(String inferenceEntityId, TestServiceSettings serviceSettings, String endpointVersion) { + public TestSparseModel(String inferenceEntityId, TestServiceSettings serviceSettings, EndpointVersions endpointVersion) { super( new ModelConfigurations( inferenceEntityId, @@ -75,7 +76,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java index 4ef6f397b5571..d99932d95c352 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java @@ -19,6 +19,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -67,7 +68,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); 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 3c1939e78881f..91dee2e2b3430 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 @@ -12,6 +12,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; @@ -127,7 +128,7 @@ public void testGetModel() throws Exception { modelHolder.get().taskType(), modelHolder.get().settings(), modelHolder.get().secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertEquals(model, roundTripModel); } @@ -183,19 +184,19 @@ public void testGetModelsByTaskType() throws InterruptedException { var service = "foo"; var sparseAndTextEmbeddingModels = new ArrayList(); sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) ); sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) ); sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) ); sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) ); sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION) + createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) ); for (var model : sparseAndTextEmbeddingModels) { @@ -244,7 +245,7 @@ public void testGetAllModels() throws InterruptedException { randomAlphaOfLength(5), randomFrom(TaskType.values()), service, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); createdModels.add(model); @@ -283,7 +284,7 @@ public void testGetModelWithSecrets() throws InterruptedException { randomFrom(TaskType.values()), service, secret, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); blockingCall(listener -> modelRegistry.storeModel(modelWithSecrets, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); @@ -314,7 +315,7 @@ public void testGetAllModels_WithDefaults() throws Exception { var id = "default-" + i; defaultConfigs.put( id, - createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret, ModelConfigurations.FIRST_ENDPOINT_VERSION) + createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret, EndpointVersions.FIRST_ENDPOINT_VERSION) ); } defaultConfigs.values().forEach(modelRegistry::addDefaultConfiguration); @@ -325,7 +326,7 @@ public void testGetAllModels_WithDefaults() throws Exception { var createdModels = new HashMap(); for (int i = 0; i < configuredModelCount; i++) { var id = randomAlphaOfLength(5) + i; - var model = createModel(id, randomFrom(TaskType.values()), service, ModelConfigurations.FIRST_ENDPOINT_VERSION); + var model = createModel(id, randomFrom(TaskType.values()), service, EndpointVersions.FIRST_ENDPOINT_VERSION); createdModels.put(id, model); blockingCall(listener -> modelRegistry.storeModel(model, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); @@ -366,7 +367,7 @@ public void testGetAllModels_OnlyDefaults() throws Exception { var id = "default-" + i; defaultConfigs.put( id, - createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret, ModelConfigurations.FIRST_ENDPOINT_VERSION) + createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret, EndpointVersions.FIRST_ENDPOINT_VERSION) ); } defaultConfigs.values().forEach(modelRegistry::addDefaultConfiguration); @@ -399,14 +400,14 @@ public void testGet_WithDefaults() throws InterruptedException { TaskType.SPARSE_EMBEDDING, service, secret, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var defaultText = createUnparsedConfig( "default-text", TaskType.TEXT_EMBEDDING, service, secret, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); modelRegistry.addDefaultConfiguration(defaultSparse); @@ -419,13 +420,13 @@ public void testGet_WithDefaults() throws InterruptedException { randomAlphaOfLength(5) + 1, randomFrom(TaskType.values()), service, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var configured2 = createModel( randomAlphaOfLength(5) + 1, randomFrom(TaskType.values()), service, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); blockingCall(listener -> modelRegistry.storeModel(configured1, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); @@ -457,21 +458,21 @@ public void testGetByTaskType_WithDefaults() throws Exception { TaskType.SPARSE_EMBEDDING, service, secret, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var defaultText = createUnparsedConfig( "default-text", TaskType.TEXT_EMBEDDING, service, secret, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var defaultChat = createUnparsedConfig( "default-chat", TaskType.COMPLETION, service, secret, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); modelRegistry.addDefaultConfiguration(defaultSparse); @@ -485,10 +486,10 @@ public void testGetByTaskType_WithDefaults() throws Exception { "configured-sparse", TaskType.SPARSE_EMBEDDING, service, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); - var configuredText = createModel("configured-text", TaskType.TEXT_EMBEDDING, service, ModelConfigurations.FIRST_ENDPOINT_VERSION); - var configuredRerank = createModel("configured-rerank", TaskType.RERANK, service, ModelConfigurations.FIRST_ENDPOINT_VERSION); + var configuredText = createModel("configured-text", TaskType.TEXT_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION); + var configuredRerank = createModel("configured-rerank", TaskType.RERANK, service, EndpointVersions.FIRST_ENDPOINT_VERSION); blockingCall(listener -> modelRegistry.storeModel(configuredSparse, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); blockingCall(listener -> modelRegistry.storeModel(configuredText, listener), putModelHolder, exceptionHolder); @@ -557,7 +558,7 @@ private Model buildElserModelConfig(String inferenceEntityId, TaskType taskType) ElasticsearchInternalService.NAME, ElserInternalServiceSettingsTests.createRandom(), ElserMlNodeTaskSettingsTests.createRandom(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); default -> throw new IllegalArgumentException("task type " + taskType + " is not supported"); }; @@ -587,19 +588,19 @@ private static Model buildModelWithUnknownField(String inferenceEntityId) { ElasticsearchInternalService.NAME, ElserInternalServiceSettingsTests.createRandom(), ElserMlNodeTaskSettingsTests.createRandom(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); } - public static Model createModel(String inferenceEntityId, TaskType taskType, String service, String endpointVersion) { + public static Model createModel(String inferenceEntityId, TaskType taskType, String service, EndpointVersions endpointVersion) { return new Model( new ModelConfigurations( inferenceEntityId, taskType, service, new TestModelOfAnyKind.TestModelServiceSettings(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); } @@ -609,7 +610,7 @@ public static Model createModelWithSecrets( TaskType taskType, String service, String secret, - String endpointVersion + EndpointVersions endpointVersion ) { return new Model( new ModelConfigurations( @@ -617,7 +618,7 @@ public static Model createModelWithSecrets( taskType, service, new TestModelOfAnyKind.TestModelServiceSettings(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), new ModelSecrets(new TestModelOfAnyKind.TestSecretSettings(secret)) ); @@ -628,7 +629,7 @@ public static UnparsedModel createUnparsedConfig( TaskType taskType, String service, String secret, - String endpointVersion + EndpointVersions endpointVersion ) { return new UnparsedModel( inferenceEntityId, @@ -636,7 +637,7 @@ public static UnparsedModel createUnparsedConfig( service, Map.of("a", "b"), Map.of("secret", secret), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -727,7 +728,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws } } - TestModelOfAnyKind(String inferenceEntityId, TaskType taskType, String service, String endpointVersion) { + TestModelOfAnyKind(String inferenceEntityId, TaskType taskType, String service, EndpointVersions endpointVersion) { super(inferenceEntityId, taskType, service, new TestModelServiceSettings(), new TestTaskSettings(), endpointVersion); } @@ -753,7 +754,7 @@ private static class ModelWithUnknownField extends ModelConfigurations { String service, ServiceSettings serviceSettings, TaskSettings taskSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java index d4a2db3affd8e..44c2d8f42a8fd 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java @@ -10,7 +10,6 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.indices.SystemIndexDescriptor; -import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.xcontent.XContentBuilder; import java.io.IOException; @@ -97,7 +96,15 @@ public static XContentBuilder mappings() { } jsonBuilder.endObject(); - jsonBuilder.startObject("endpoint_version").field("dynamic", "false").field("type", "keyword").endObject(); + jsonBuilder.startObject("endpoint_version").field("dynamic", "false"); + { + jsonBuilder.startObject("properties"); + { + jsonBuilder.field("type", "keyword"); + } + jsonBuilder.endObject(); + } + jsonBuilder.endObject(); } jsonBuilder.endObject().endObject().endObject(); } 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 4a6fb5054c494..59436bbe0483c 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 @@ -23,6 +23,7 @@ import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.index.mapper.StrictDynamicMappingException; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.InferenceServiceRegistry; import org.elasticsearch.inference.Model; @@ -203,7 +204,7 @@ private void parseAndStoreModel( } }); - String endpointVersion = (String) config.remove(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME); + EndpointVersions endpointVersion = (EndpointVersions) config.remove(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME); service.parseRequestConfig(inferenceEntityId, taskType, config, endpointVersion, parsedModelListener); } 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 e685a031f40dc..44f6b2dfe255b 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 @@ -29,6 +29,7 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.reindex.DeleteByQueryAction; import org.elasticsearch.index.reindex.DeleteByQueryRequest; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; @@ -73,10 +74,10 @@ public static UnparsedModel unparsedModelFromMap(ModelConfigMap modelConfigMap) String service = ServiceUtils.removeStringOrThrowIfNull(modelConfigMap.config(), ModelConfigurations.SERVICE); String taskTypeStr = ServiceUtils.removeStringOrThrowIfNull(modelConfigMap.config(), TaskType.NAME); TaskType taskType = TaskType.fromString(taskTypeStr); - String endpointVersion = (String) Objects.requireNonNullElse( + EndpointVersions endpointVersion = (EndpointVersions) Objects.requireNonNullElse( modelConfigMap.config().remove(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME), - ModelConfigurations.FIRST_ENDPOINT_VERSION // TODO in 9.0 change this to require the field, once we have updated all of the - // stored models + EndpointVersions.FIRST_ENDPOINT_VERSION // TODO in 9.0 change this to require the field, once we have updated all of the + // stored models ); return new UnparsedModel(inferenceEntityId, taskType, service, modelConfigMap.config(), modelConfigMap.secrets(), endpointVersion); @@ -426,7 +427,7 @@ private static IndexRequest createIndexRequest(String docId, String indexName, T builder, new ToXContent.MapParams( Map.of( - ModelConfigurations.USE_ID_FOR_INDEX, + ModelConfigurations.FOR_INDEX, Boolean.TRUE.toString(), ModelConfigurations.INCLUDE_PARAMETERS, // we are going to continue to write the parameters field as `task_settings` Boolean.FALSE.toString() diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java index 92261b0e4747b..e7b1cef1201af 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java @@ -15,6 +15,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -68,7 +69,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -103,7 +104,7 @@ private static AlibabaCloudSearchModel createModelWithoutLoggingDeprecations( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, @@ -125,7 +126,7 @@ private static AlibabaCloudSearchModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new AlibabaCloudSearchEmbeddingsModel( @@ -178,7 +179,7 @@ public AlibabaCloudSearchModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -200,7 +201,7 @@ public AlibabaCloudSearchModel parsePersistedConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java index 73a847444e78b..3dd53e4a80a91 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.completion; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -37,7 +38,7 @@ public AlibabaCloudSearchCompletionModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( modelId, @@ -58,7 +59,7 @@ public AlibabaCloudSearchCompletionModel( AlibabaCloudSearchCompletionServiceSettings serviceSettings, AlibabaCloudSearchCompletionTaskSettings taskSettings, @Nullable DefaultSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java index 582596133ce67..d3f80fbe479fe 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -41,7 +42,7 @@ public AlibabaCloudSearchEmbeddingsModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( modelId, @@ -62,7 +63,7 @@ public AlibabaCloudSearchEmbeddingsModel( AlibabaCloudSearchEmbeddingsServiceSettings serviceSettings, AlibabaCloudSearchEmbeddingsTaskSettings taskSettings, @Nullable DefaultSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java index af89a2532267d..6a7ef1afece6d 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.rerank; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -37,7 +38,7 @@ public AlibabaCloudSearchRerankModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( modelId, @@ -58,7 +59,7 @@ public AlibabaCloudSearchRerankModel( AlibabaCloudSearchRerankServiceSettings serviceSettings, AlibabaCloudSearchRerankTaskSettings taskSettings, @Nullable DefaultSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java index e829efd249224..aa8f322461f6f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.sparse; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -41,7 +42,7 @@ public AlibabaCloudSearchSparseModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( modelId, @@ -62,7 +63,7 @@ public AlibabaCloudSearchSparseModel( AlibabaCloudSearchSparseServiceSettings serviceSettings, AlibabaCloudSearchSparseTaskSettings taskSettings, @Nullable DefaultSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java index 2f9839c838d36..5ddfc52de67fe 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java @@ -16,6 +16,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -120,7 +121,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -154,7 +155,7 @@ public Model parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -173,7 +174,7 @@ public Model parsePersistedConfigWithSecrets( } @Override - public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -197,7 +198,7 @@ private static AmazonBedrockModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { switch (taskType) { case TEXT_EMBEDDING -> { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java index 7667a99c35a4e..1172f7a498695 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.inference.services.amazonbedrock.completion; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -40,7 +41,7 @@ public AmazonBedrockChatCompletionModel( Map taskSettings, Map secretSettings, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -60,7 +61,7 @@ public AmazonBedrockChatCompletionModel( AmazonBedrockChatCompletionServiceSettings serviceSettings, AmazonBedrockChatCompletionTaskSettings taskSettings, AmazonBedrockSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java index 164d73126d947..7f6c61130d298 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java @@ -9,6 +9,7 @@ import org.elasticsearch.common.ValidationException; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -44,7 +45,7 @@ public AmazonBedrockEmbeddingsModel( Map taskSettings, Map secretSettings, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -64,7 +65,7 @@ public AmazonBedrockEmbeddingsModel( AmazonBedrockEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, AmazonBedrockSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, new EmptyTaskSettings(), endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java index 9da999428abeb..2eec1572731fd 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java @@ -15,6 +15,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -57,7 +58,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -92,7 +93,7 @@ private static AnthropicModel createModelFromPersistent( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, @@ -114,7 +115,7 @@ private static AnthropicModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case COMPLETION -> new AnthropicChatCompletionModel( @@ -137,7 +138,7 @@ public AnthropicModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -159,7 +160,7 @@ public AnthropicModel parsePersistedConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java index 8626edd173585..35636ed325984 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java @@ -9,6 +9,7 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -46,7 +47,7 @@ public AnthropicChatCompletionModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -66,7 +67,7 @@ public AnthropicChatCompletionModel( AnthropicChatCompletionServiceSettings serviceSettings, AnthropicChatCompletionTaskSettings taskSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), @@ -86,7 +87,7 @@ public AnthropicChatCompletionModel( AnthropicChatCompletionServiceSettings serviceSettings, AnthropicChatCompletionTaskSettings taskSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java index fe6c93c150311..7f05c4b9187f8 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java @@ -16,6 +16,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -109,7 +110,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -143,7 +144,7 @@ public AzureAiStudioModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -161,7 +162,12 @@ public AzureAiStudioModel parsePersistedConfigWithSecrets( } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + EndpointVersions endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -194,7 +200,7 @@ private static AzureAiStudioModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { if (taskType == TaskType.TEXT_EMBEDDING) { @@ -245,7 +251,7 @@ private AzureAiStudioModel createModelFromPersistent( Map taskSettings, Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java index ceb0fad59ae25..5a547a3cf70e9 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.azureaistudio.completion; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -47,7 +48,7 @@ public AzureAiStudioChatCompletionModel( AzureAiStudioChatCompletionServiceSettings serviceSettings, AzureAiStudioChatCompletionTaskSettings taskSettings, DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), @@ -63,7 +64,7 @@ public AzureAiStudioChatCompletionModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java index 9f186dcdd5cf9..1a91174d4d576 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.azureaistudio.embeddings; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -45,7 +46,7 @@ public AzureAiStudioEmbeddingsModel( AzureAiStudioEmbeddingsServiceSettings serviceSettings, AzureAiStudioEmbeddingsTaskSettings taskSettings, DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), @@ -61,7 +62,7 @@ public AzureAiStudioEmbeddingsModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java index db1273e309512..273064d54da2b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java @@ -16,6 +16,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -64,7 +65,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -99,7 +100,7 @@ private static AzureOpenAiModel createModelFromPersistent( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, @@ -121,7 +122,7 @@ private static AzureOpenAiModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { switch (taskType) { case TEXT_EMBEDDING -> { @@ -158,7 +159,7 @@ public AzureOpenAiModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -180,7 +181,7 @@ public AzureOpenAiModel parsePersistedConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java index f2540b69b8273..65b39f7827949 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.azureopenai.completion; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -40,7 +41,7 @@ public AzureOpenAiCompletionModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -61,7 +62,7 @@ public AzureOpenAiCompletionModel( AzureOpenAiCompletionServiceSettings serviceSettings, AzureOpenAiCompletionTaskSettings taskSettings, @Nullable AzureOpenAiSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java index f1d49d62e8d1b..2a88fd4be6615 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.azureopenai.embeddings; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -40,7 +41,7 @@ public AzureOpenAiEmbeddingsModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -61,7 +62,7 @@ public AzureOpenAiEmbeddingsModel( AzureOpenAiEmbeddingsServiceSettings serviceSettings, AzureOpenAiEmbeddingsTaskSettings taskSettings, @Nullable AzureOpenAiSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java index 21d2d2aa0782e..7a8257650bad7 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java @@ -15,6 +15,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -69,7 +70,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -104,7 +105,7 @@ private static CohereModel createModelWithoutLoggingDeprecations( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, @@ -126,7 +127,7 @@ private static CohereModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new CohereEmbeddingsModel( @@ -169,7 +170,7 @@ public CohereModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -191,7 +192,7 @@ public CohereModel parsePersistedConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java index 3d79b215bd5ba..3932d8578a1d2 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java @@ -9,6 +9,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -33,7 +34,7 @@ public CohereCompletionModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( modelId, @@ -54,7 +55,7 @@ public CohereCompletionModel( CohereCompletionServiceSettings serviceSettings, TaskSettings taskSettings, @Nullable DefaultSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java index 653cc3377dfff..acadb8808ca06 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.cohere.embeddings; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -35,7 +36,7 @@ public CohereEmbeddingsModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceId, @@ -56,7 +57,7 @@ public CohereEmbeddingsModel( CohereEmbeddingsServiceSettings serviceSettings, CohereEmbeddingsTaskSettings taskSettings, @Nullable DefaultSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java index d513e8dc06216..4fd937b51c744 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.cohere.rerank; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -35,7 +36,7 @@ public CohereRerankModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( modelId, @@ -56,7 +57,7 @@ public CohereRerankModel( CohereRerankServiceSettings serviceSettings, CohereRerankTaskSettings taskSettings, @Nullable DefaultSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java index d5346f8b3e482..4ff4543c94d68 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java @@ -16,6 +16,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -116,7 +117,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -154,7 +155,7 @@ private static ElasticInferenceServiceModel createModel( ElasticInferenceServiceComponents eisServiceComponents, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case SPARSE_EMBEDDING -> new ElasticInferenceServiceSparseEmbeddingsModel( @@ -178,7 +179,7 @@ public Model parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -196,7 +197,12 @@ public Model parsePersistedConfigWithSecrets( } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + EndpointVersions endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -223,7 +229,7 @@ private ElasticInferenceServiceModel createModelFromPersistent( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java index 646f7e72318ef..e7643ed8b312f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java @@ -10,6 +10,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptySecretSettings; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.SecretSettings; @@ -37,7 +38,7 @@ public ElasticInferenceServiceSparseEmbeddingsModel( Map secrets, ElasticInferenceServiceComponents elasticInferenceServiceComponents, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -72,7 +73,7 @@ public ElasticInferenceServiceSparseEmbeddingsModel( @Nullable TaskSettings taskSettings, @Nullable SecretSettings secretSettings, ElasticInferenceServiceComponents elasticInferenceServiceComponents, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java index fbd0d55c5daa1..cfc748ac06f9f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.inference.services.elasticsearch; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; public class CustomElandEmbeddingModel extends CustomElandModel { @@ -16,7 +17,7 @@ public CustomElandEmbeddingModel( TaskType taskType, String service, CustomElandInternalTextEmbeddingServiceSettings serviceSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(inferenceEntityId, taskType, service, serviceSettings, endpointVersion); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java index 4765f105cc63e..15456ec2adcf1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java @@ -9,6 +9,7 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.TaskSettings; import org.elasticsearch.inference.TaskType; @@ -22,7 +23,7 @@ public CustomElandModel( TaskType taskType, String service, ElasticsearchInternalServiceSettings internalServiceSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(inferenceEntityId, taskType, service, internalServiceSettings, endpointVersion); } @@ -33,7 +34,7 @@ public CustomElandModel( String service, ElasticsearchInternalServiceSettings internalServiceSettings, TaskSettings taskSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings, endpointVersion); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java index f39487a5081c2..88d49c6597b97 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.inference.services.elasticsearch; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; public class CustomElandRerankModel extends CustomElandModel { @@ -17,7 +18,7 @@ public CustomElandRerankModel( String service, CustomElandInternalServiceSettings serviceSettings, CustomElandRerankTaskSettings taskSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java index c7e75f0b7aab0..f55934119b6cd 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java @@ -9,6 +9,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Strings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskSettings; @@ -27,7 +28,7 @@ public ElasticsearchInternalModel( TaskType taskType, String service, ElasticsearchInternalServiceSettings internalServiceSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings, endpointVersion)); this.internalServiceSettings = internalServiceSettings; @@ -39,7 +40,7 @@ public ElasticsearchInternalModel( String service, ElasticsearchInternalServiceSettings internalServiceSettings, TaskSettings taskSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings, endpointVersion)); this.internalServiceSettings = internalServiceSettings; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java index 422a3e0a27c79..e8ce7c634c4c6 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java @@ -19,6 +19,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceResults; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; @@ -101,7 +102,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener modelListener ) { if (inferenceEntityId.equals(DEFAULT_ELSER_ID)) { @@ -191,7 +192,7 @@ private void customElandCase( Map serviceSettingsMap, Map taskSettingsMap, ActionListener modelListener, - String endpointVersion + EndpointVersions endpointVersion ) { String modelId = (String) serviceSettingsMap.get(ElasticsearchInternalServiceSettings.MODEL_ID); var request = new GetTrainedModelsAction.Request(modelId); @@ -229,7 +230,7 @@ private static CustomElandModel createCustomElandModel( Map serviceSettings, Map taskSettings, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { @@ -278,7 +279,7 @@ private void e5Case( Set platformArchitectures, Map serviceSettingsMap, ActionListener modelListener, - String endpointVersion + EndpointVersions endpointVersion ) { var esServiceSettingsBuilder = ElasticsearchInternalServiceSettings.fromRequestMap(serviceSettingsMap); @@ -333,7 +334,7 @@ private void elserCase( Set platformArchitectures, Map serviceSettingsMap, ActionListener modelListener, - String endpointVersion + EndpointVersions endpointVersion ) { var esServiceSettingsBuilder = ElasticsearchInternalServiceSettings.fromRequestMap(serviceSettingsMap); final String defaultModelId = selectDefaultModelVariantBasedOnClusterArchitecture( @@ -414,13 +415,18 @@ public Model parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { return parsePersistedConfig(inferenceEntityId, taskType, config, endpointVersion); } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + EndpointVersions endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMap(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -771,7 +777,7 @@ public List defaultConfigs() { NAME, elserSettings, Map.of(), // no secrets - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java index 4e8d05bcbd547..1da1db89bfe04 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java @@ -9,6 +9,7 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.TaskType; import org.elasticsearch.xpack.core.ml.action.CreateTrainedModelAssignmentAction; @@ -22,7 +23,7 @@ public ElserInternalModel( String service, ElserInternalServiceSettings serviceSettings, ElserMlNodeTaskSettings taskSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java index 63c72684827c9..7328e7d269859 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java @@ -9,6 +9,7 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.TaskType; import org.elasticsearch.xpack.core.ml.action.CreateTrainedModelAssignmentAction; @@ -21,7 +22,7 @@ public MultilingualE5SmallModel( TaskType taskType, String service, MultilingualE5SmallInternalServiceSettings serviceSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(inferenceEntityId, taskType, service, serviceSettings, endpointVersion); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java index 9927cc273a5a7..b43a6f0293479 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java @@ -16,6 +16,7 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -68,7 +69,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -114,7 +115,7 @@ private static GoogleAiStudioModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case COMPLETION -> new GoogleAiStudioCompletionModel( @@ -148,7 +149,7 @@ public GoogleAiStudioModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -179,7 +180,7 @@ private static GoogleAiStudioModel createModelFromPersistent( ChunkingSettings chunkingSettings, Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, @@ -195,7 +196,12 @@ private static GoogleAiStudioModel createModelFromPersistent( } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + EndpointVersions endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java index 41042cb448aa3..0ed6fa76c3486 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java @@ -10,6 +10,7 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -40,7 +41,7 @@ public GoogleAiStudioCompletionModel( Map taskSettings, Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -61,7 +62,7 @@ public GoogleAiStudioCompletionModel( GoogleAiStudioCompletionServiceSettings serviceSettings, TaskSettings taskSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), @@ -84,7 +85,7 @@ public GoogleAiStudioCompletionModel( GoogleAiStudioCompletionServiceSettings serviceSettings, TaskSettings taskSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java index 82f53011e131e..4e699a61e4645 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java @@ -11,6 +11,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -42,7 +43,7 @@ public GoogleAiStudioEmbeddingsModel( ChunkingSettings chunkingSettings, Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -69,7 +70,7 @@ public GoogleAiStudioEmbeddingsModel(GoogleAiStudioEmbeddingsModel model, Google TaskSettings taskSettings, ChunkingSettings chunkingSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings, endpointVersion), @@ -92,7 +93,7 @@ public GoogleAiStudioEmbeddingsModel(GoogleAiStudioEmbeddingsModel model, Google GoogleAiStudioEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), @@ -116,7 +117,7 @@ public GoogleAiStudioEmbeddingsModel(GoogleAiStudioEmbeddingsModel model, Google TaskSettings taskSettings, ChunkingSettings chunkingsettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingsettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java index df5132bef4a59..6823ece06ebd1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java @@ -16,6 +16,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -64,7 +65,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parseModelListener ) { try { @@ -98,7 +99,7 @@ public Model parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -116,7 +117,12 @@ public Model parsePersistedConfigWithSecrets( } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + EndpointVersions endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -232,7 +238,7 @@ private static GoogleVertexAiModel createModelFromPersistent( Map taskSettings, Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, @@ -254,7 +260,7 @@ private static GoogleVertexAiModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new GoogleVertexAiEmbeddingsModel( diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java index b6670ffa2df08..6a645845ed7e2 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java @@ -9,6 +9,7 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -37,7 +38,7 @@ public GoogleVertexAiEmbeddingsModel( Map taskSettings, Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -62,7 +63,7 @@ public GoogleVertexAiEmbeddingsModel(GoogleVertexAiEmbeddingsModel model, Google GoogleVertexAiEmbeddingsServiceSettings serviceSettings, GoogleVertexAiEmbeddingsTaskSettings taskSettings, @Nullable GoogleVertexAiSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), @@ -85,7 +86,7 @@ protected GoogleVertexAiEmbeddingsModel( GoogleVertexAiEmbeddingsServiceSettings serviceSettings, GoogleVertexAiEmbeddingsTaskSettings taskSettings, @Nullable GoogleVertexAiSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java index 07f64e7a6a4d4..96df873dab6d9 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java @@ -9,6 +9,7 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -37,7 +38,7 @@ public GoogleVertexAiRerankModel( Map taskSettings, Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -62,7 +63,7 @@ public GoogleVertexAiRerankModel(GoogleVertexAiRerankModel model, GoogleVertexAi GoogleVertexAiRerankServiceSettings serviceSettings, GoogleVertexAiRerankTaskSettings taskSettings, @Nullable GoogleVertexAiSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), @@ -85,7 +86,7 @@ protected GoogleVertexAiRerankModel( GoogleVertexAiRerankServiceSettings serviceSettings, GoogleVertexAiRerankTaskSettings taskSettings, @Nullable GoogleVertexAiSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java index 168c3f181704b..b965cff96e1be 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -51,7 +52,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -90,7 +91,7 @@ public HuggingFaceModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); @@ -117,7 +118,7 @@ public HuggingFaceModel parsePersistedConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); @@ -146,7 +147,7 @@ protected abstract HuggingFaceModel createModel( Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ); @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java index 488d55a3178fa..c88e65e88f53b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java @@ -16,6 +16,7 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.SimilarityMeasure; @@ -54,7 +55,7 @@ protected HuggingFaceModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new HuggingFaceEmbeddingsModel( diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java index ad2d56bc4e4d1..429dd47ac3f2d 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.huggingface.elser; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -27,7 +28,7 @@ public HuggingFaceElserModel( Map serviceSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -45,7 +46,7 @@ public HuggingFaceElserModel( String service, HuggingFaceElserServiceSettings serviceSettings, @Nullable DefaultSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java index aa0d626e42f14..28cf779d57daa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java @@ -17,6 +17,7 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -61,7 +62,7 @@ protected HuggingFaceModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case SPARSE_EMBEDDING -> new HuggingFaceElserModel( diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java index 371ed05c46752..ea0a585a09f11 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java @@ -9,6 +9,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -30,7 +31,7 @@ public HuggingFaceEmbeddingsModel( ChunkingSettings chunkingSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -51,7 +52,7 @@ public HuggingFaceEmbeddingsModel( HuggingFaceServiceSettings serviceSettings, ChunkingSettings chunkingSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, chunkingSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java index e229b6aead791..61429752afd9d 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java @@ -15,6 +15,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -64,7 +65,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -101,7 +102,7 @@ private static IbmWatsonxModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new IbmWatsonxEmbeddingsModel( @@ -124,7 +125,7 @@ public IbmWatsonxModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -148,7 +149,7 @@ private static IbmWatsonxModel createModelFromPersistent( Map taskSettings, Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, @@ -163,7 +164,12 @@ private static IbmWatsonxModel createModelFromPersistent( } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + EndpointVersions endpointVersion + ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java index 89f01b6ed6566..75ff0db028fa5 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java @@ -10,6 +10,7 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -42,7 +43,7 @@ public IbmWatsonxEmbeddingsModel( Map taskSettings, Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -67,7 +68,7 @@ public IbmWatsonxEmbeddingsModel(IbmWatsonxEmbeddingsModel model, IbmWatsonxEmbe IbmWatsonxEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), @@ -90,7 +91,7 @@ public IbmWatsonxEmbeddingsModel(IbmWatsonxEmbeddingsModel model, IbmWatsonxEmbe IbmWatsonxEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java index 5caa8d0de1e00..37c3e7a2c22dc 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java @@ -15,6 +15,7 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -122,7 +123,7 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -164,7 +165,7 @@ public Model parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -188,7 +189,7 @@ public Model parsePersistedConfigWithSecrets( } @Override - public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -223,7 +224,7 @@ private static MistralEmbeddingsModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { if (taskType == TaskType.TEXT_EMBEDDING) { return new MistralEmbeddingsModel( @@ -250,7 +251,7 @@ private MistralEmbeddingsModel createModelFromPersistent( ChunkingSettings chunkingSettings, Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java index c37205de59b46..459d013b21c99 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java @@ -10,6 +10,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -41,7 +42,7 @@ public MistralEmbeddingsModel( ChunkingSettings chunkingSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -68,7 +69,7 @@ public MistralEmbeddingsModel( TaskSettings taskSettings, ChunkingSettings chunkingSettings, DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations( diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java index d6a8906af1ce6..ae797c9df1f67 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java @@ -16,6 +16,7 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -69,7 +70,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -115,7 +116,7 @@ private static OpenAiModel createModelFromPersistent( ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, - String endpointVersion + EndpointVersions endpointVersion ) { return createModel( inferenceEntityId, @@ -139,7 +140,7 @@ private static OpenAiModel createModel( @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { return switch (taskType) { case TEXT_EMBEDDING -> new OpenAiEmbeddingsModel( @@ -173,7 +174,7 @@ public OpenAiModel parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); @@ -203,7 +204,7 @@ public OpenAiModel parsePersistedConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion + EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java index dbc49717bac4a..903a091256075 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.openai.completion; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -38,7 +39,7 @@ public OpenAiChatCompletionModel( Map taskSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -58,7 +59,7 @@ public OpenAiChatCompletionModel( OpenAiChatCompletionServiceSettings serviceSettings, OpenAiChatCompletionTaskSettings taskSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java index a32e1521e9562..68f9a00d16b22 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java @@ -9,6 +9,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -40,7 +41,7 @@ public OpenAiEmbeddingsModel( ChunkingSettings chunkingSettings, @Nullable Map secrets, ConfigurationParseContext context, - String endpointVersion + EndpointVersions endpointVersion ) { this( inferenceEntityId, @@ -63,7 +64,7 @@ public OpenAiEmbeddingsModel( OpenAiEmbeddingsTaskSettings taskSettings, ChunkingSettings chunkingSettings, @Nullable DefaultSecretSettings secrets, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings, endpointVersion), diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java index 44b2a871d975b..d4c171d8836db 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java @@ -9,11 +9,13 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ServiceSettings; import org.elasticsearch.inference.TaskSettings; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.AbstractWireSerializingTestCase; +import org.elasticsearch.test.EnumSerializationTestUtils; import org.elasticsearch.xpack.core.inference.ChunkingSettingsFeatureFlag; import org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests; import org.elasticsearch.xpack.inference.services.elasticsearch.ElserInternalServiceSettingsTests; @@ -30,7 +32,7 @@ public static ModelConfigurations createRandomInstance() { randomServiceSettings(), randomTaskSettings(taskType), ChunkingSettingsFeatureFlag.isEnabled() && randomBoolean() ? ChunkingSettingsTests.createRandomChunkingSettings() : null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -92,4 +94,13 @@ protected ModelConfigurations createTestInstance() { protected ModelConfigurations mutateInstance(ModelConfigurations instance) { return mutateTestInstance(instance); } + + // future-proof of accidental enum ordering change or extension for serialization + public void testEnsureEndpointVersionsOrdinalsOrder() { + EnumSerializationTestUtils.assertEnumSerialization( + EndpointVersions.class, + EndpointVersions.FIRST_ENDPOINT_VERSION, + EndpointVersions.PARAMETERS_INTRODUCED_ENDPOINT_VERSION + ); + } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java index 2394c76b3fe8e..9088705b4c3d5 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; @@ -94,7 +95,7 @@ public static void storeSparseModel(Client client) throws Exception { Model model = new TestSparseInferenceServiceExtension.TestSparseModel( TestSparseInferenceServiceExtension.TestInferenceService.NAME, new TestSparseInferenceServiceExtension.TestServiceSettings("sparse_model", null, false), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); storeModel(client, model); } @@ -108,7 +109,7 @@ public static void storeDenseModel( Model model = new TestDenseInferenceServiceExtension.TestDenseModel( TestDenseInferenceServiceExtension.TestInferenceService.NAME, new TestDenseInferenceServiceExtension.TestServiceSettings("dense_model", dimensions, similarityMeasure, elementType), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); storeModel(client, model); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java index 380897f385b41..5e6bc848b38d0 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java @@ -15,6 +15,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.io.stream.BytesStreamOutput; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ServiceSettings; import org.elasticsearch.inference.TaskType; @@ -86,42 +87,42 @@ public void test() throws Exception { TaskType.TEXT_EMBEDDING, "openai", mock(ServiceSettings.class), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), new ModelConfigurations( "model-002", TaskType.TEXT_EMBEDDING, "openai", mock(ServiceSettings.class), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), new ModelConfigurations( "model-003", TaskType.SPARSE_EMBEDDING, "hugging_face_elser", mock(ServiceSettings.class), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), new ModelConfigurations( "model-004", TaskType.TEXT_EMBEDDING, "openai", mock(ServiceSettings.class), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), new ModelConfigurations( "model-005", TaskType.SPARSE_EMBEDDING, "openai", mock(ServiceSettings.class), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), new ModelConfigurations( "model-006", TaskType.SPARSE_EMBEDDING, "hugging_face_elser", mock(ServiceSettings.class), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ) 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 435c69b65c3bd..1552999c9dee1 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 @@ -22,10 +22,10 @@ import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.inference.ChunkedInferenceServiceResults; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.InferenceServiceRegistry; import org.elasticsearch.inference.Model; -import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.inference.UnparsedModel; import org.elasticsearch.rest.RestStatus; @@ -278,7 +278,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), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); } else { @@ -382,7 +382,7 @@ private static class StaticModel extends TestModel { TestServiceSettings serviceSettings, TestTaskSettings taskSettings, TestSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, secretSettings, endpointVersion); this.resultMap = new HashMap<>(); @@ -397,7 +397,7 @@ public static StaticModel createRandomInstance() { testModel.getServiceSettings(), testModel.getTaskSettings(), testModel.getSecretSettings(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java index f8cef0e2e73bf..bb9a3bbf10cb1 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java @@ -14,8 +14,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; -import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockRequest; import org.elasticsearch.test.http.MockResponse; @@ -477,7 +477,7 @@ public void testInfer_AzureOpenAiCompletion_WithOverriddenUser() throws IOExcept apiKey, null, "id", - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); @@ -542,7 +542,7 @@ public void testInfer_AzureOpenAiCompletionModel_WithoutUser() throws IOExceptio apiKey, null, "id", - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); @@ -609,7 +609,7 @@ public void testInfer_AzureOpenAiCompletionModel_FailsFromInvalidResponseFormat( apiKey, null, "id", - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java index 6ee5fd18246c0..4c64f14cad4f0 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java @@ -14,8 +14,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; -import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockResponse; import org.elasticsearch.test.http.MockWebServer; @@ -203,7 +203,7 @@ private ExecutableAction createAction( apiKey, null, inferenceEntityId, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); model.setUri(new URI(getUrl(webServer))); var requestCreator = new AzureOpenAiCompletionRequestManager(model, threadPool); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java index c475f59a8e959..855efe4632d83 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java @@ -10,7 +10,7 @@ import org.apache.http.HttpHeaders; import org.apache.http.client.methods.HttpPost; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.inference.external.request.HttpRequest; @@ -460,7 +460,7 @@ public static AzureAiStudioChatCompletionRequest createRequest( doSample, maxNewTokens, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); return new AzureAiStudioChatCompletionRequest(model, List.of(input)); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java index 0c1b7e38f1bfb..b2abb4f267328 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java @@ -9,7 +9,7 @@ import org.apache.http.HttpHeaders; import org.apache.http.client.methods.HttpPost; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.inference.external.request.azureopenai.AzureOpenAiCompletionRequest; @@ -93,7 +93,7 @@ protected AzureOpenAiCompletionRequest createRequest( apiKey, entraId, "id", - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); return new AzureOpenAiCompletionRequest(List.of(input), completionModel); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java index 62a8ff8bbe7c8..6131389263b49 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java @@ -12,6 +12,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -48,7 +49,7 @@ public static TestModel createRandomInstance(TaskType taskType) { new TestModel.TestServiceSettings(randomAlphaOfLength(4), dimensions, similarity, elementType), new TestModel.TestTaskSettings(randomInt(3)), new TestModel.TestSecretSettings(randomAlphaOfLength(4)), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -59,7 +60,7 @@ public TestModel( TestServiceSettings serviceSettings, TestTaskSettings taskSettings, TestSecretSettings secretSettings, - String endpointVersion + EndpointVersions endpointVersion ) { super( new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), 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 8fc7e96af622d..2bc092b1684d9 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 @@ -22,6 +22,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; @@ -147,7 +148,7 @@ private void handleGetInferenceModelActionRequ CohereService.NAME, new CohereRerankServiceSettings("uri", "model", null), topN == null ? new EmptyTaskSettings() : new CohereRerankTaskSettings(topN, null, null), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java index 7250c9ab10eb4..c43f2dcefa042 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.engine.VersionConflictEngineException; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.inference.UnparsedModel; import org.elasticsearch.search.SearchHit; @@ -302,7 +302,7 @@ public void testDeepCopyDefaultConfig() { "service-a", Map.of(), Map.of(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var copied = ModelRegistry.deepCopyDefaultConfig(toCopy); assertThat(copied, not(sameInstance(toCopy))); @@ -332,7 +332,7 @@ public void testDeepCopyDefaultConfig() { "service-a", settings, secretsMap, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var copied = ModelRegistry.deepCopyDefaultConfig(toCopy); assertThat(copied, not(sameInstance(toCopy))); @@ -368,14 +368,7 @@ public void testDuplicateDefaultIds() { var id = "my-inference"; registry.addDefaultConfiguration( - new UnparsedModel( - id, - randomFrom(TaskType.values()), - "service-a", - Map.of(), - Map.of(), - ModelConfigurations.FIRST_ENDPOINT_VERSION - ) + new UnparsedModel(id, randomFrom(TaskType.values()), "service-a", Map.of(), Map.of(), EndpointVersions.FIRST_ENDPOINT_VERSION) ); var ise = expectThrows( IllegalStateException.class, @@ -386,7 +379,7 @@ public void testDuplicateDefaultIds() { "service-b", Map.of(), Map.of(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ); 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 46104167a9ea4..4954186fae774 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 @@ -13,6 +13,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -137,7 +138,7 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - String endpointVersion, + EndpointVersions endpointVersion, ActionListener parsedModelListener ) { parsedModelListener.onResponse(null); @@ -149,13 +150,18 @@ public Model parsePersistedConfigWithSecrets( TaskType taskType, Map config, Map secrets, - String endpointVersion + EndpointVersions endpointVersion ) { return null; } @Override - public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config, String endpointVersion) { + public Model parsePersistedConfig( + String inferenceEntityId, + TaskType taskType, + Map config, + EndpointVersions endpointVersion + ) { return null; } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java index e512571eeff7f..2074a3ff5edb9 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java @@ -13,6 +13,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -94,7 +95,7 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModel() throws IOException AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -191,7 +192,7 @@ public void testChunkedInfer_Batches() throws IOException { taskSettingsMap, secretSettingsMap, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) { public ExecutableAction accept( AlibabaCloudSearchActionVisitor visitor, 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 1939afd932a91..3556b54992931 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 @@ -8,7 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.completion; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; @@ -49,7 +49,7 @@ public static AlibabaCloudSearchCompletionModel createModel( taskSettings, secrets, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -68,7 +68,7 @@ public static AlibabaCloudSearchCompletionModel createModel( serviceSettings, taskSettings, secretSettings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } 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 9930e8283c645..da0614f3cbc32 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 @@ -8,7 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; @@ -50,7 +50,7 @@ public static AlibabaCloudSearchEmbeddingsModel createModel( taskSettings, secrets, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -69,7 +69,7 @@ public static AlibabaCloudSearchEmbeddingsModel createModel( serviceSettings, taskSettings, secretSettings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } } 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 bf7b8e733bd53..59a5b481b4fef 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 @@ -8,7 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.sparse; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; @@ -50,7 +50,7 @@ public static AlibabaCloudSearchSparseModel createModel( taskSettings, secrets, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -69,7 +69,7 @@ public static AlibabaCloudSearchSparseModel createModel( serviceSettings, taskSettings, secretSettings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java index 1745dca28b384..9301bddad8d5a 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java @@ -16,6 +16,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -110,7 +111,7 @@ public void testParseRequestConfig_CreatesAnAmazonBedrockModel() throws IOExcept Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -134,7 +135,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -158,7 +159,7 @@ public void testCreateModel_ForEmbeddingsTask_InvalidProvider() throws IOExcepti Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -182,7 +183,7 @@ public void testCreateModel_TopKParameter_NotAvailable() throws IOException { getChatCompletionTaskSettingsMap(1.0, 0.5, 0.2, 128), getAmazonBedrockSecretSettingsMap("access", "secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -213,7 +214,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -240,7 +241,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -270,7 +271,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() "id", TaskType.COMPLETION, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -300,7 +301,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap "id", TaskType.COMPLETION, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -328,7 +329,7 @@ public void testParseRequestConfig_MovesModel() throws IOException { Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -352,7 +353,7 @@ public void testCreateModel_ForEmbeddingsTask_DimensionsIsNotAllowed() throws IO Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -370,7 +371,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnAmazonBedrockEmbeddings TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -399,7 +400,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -423,7 +424,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -451,7 +452,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -479,7 +480,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -507,7 +508,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -536,7 +537,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); @@ -567,7 +568,7 @@ public void testParsePersistedConfig_CreatesAnAmazonBedrockEmbeddingsModel() thr "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -591,7 +592,7 @@ public void testParsePersistedConfig_CreatesAnAmazonBedrockChatCompletionModel() "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); @@ -622,7 +623,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -645,7 +646,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -671,7 +672,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -696,7 +697,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java index f68cf1f08d87a..7b700144f66ad 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.amazonbedrock.AmazonBedrockProvider; @@ -216,7 +216,7 @@ public static AmazonBedrockChatCompletionModel createModel( new AmazonBedrockChatCompletionServiceSettings(region, model, provider, rateLimitSettings), new AmazonBedrockChatCompletionTaskSettings(temperature, topP, topK, maxNewTokens), new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java index 07063290cf4f3..78b8c775fc6ab 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java @@ -11,7 +11,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -77,7 +77,7 @@ public static AmazonBedrockEmbeddingsModel createModel( ), new EmptyTaskSettings(), new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java index 956ffc956b3be..ad66725a7269c 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java @@ -13,10 +13,10 @@ import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; -import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockResponse; @@ -108,7 +108,7 @@ public void testParseRequestConfig_CreatesACompletionModel() throws IOException new HashMap<>(Map.of(AnthropicServiceFields.MAX_TOKENS, 1)), getSecretSettingsMap(apiKey) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -129,7 +129,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -148,7 +148,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -167,7 +167,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -186,7 +186,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -205,7 +205,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -225,7 +225,7 @@ public void testParsePersistedConfigWithSecrets_CreatesACompletionModel() throws TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -254,7 +254,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -285,7 +285,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -316,7 +316,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -347,7 +347,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -372,7 +372,7 @@ public void testParsePersistedConfig_CreatesACompletionModel() throws IOExceptio "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -398,7 +398,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -426,7 +426,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -451,7 +451,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); 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 115fa5c455ab6..3810743b9f4f7 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 @@ -8,7 +8,7 @@ package org.elasticsearch.xpack.inference.services.anthropic.completion; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings; @@ -54,7 +54,7 @@ public static AnthropicChatCompletionModel createChatCompletionModel(String url, new AnthropicChatCompletionServiceSettings(modelName, null), new AnthropicChatCompletionTaskSettings(maxTokens, null, null, null), new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -67,7 +67,7 @@ public static AnthropicChatCompletionModel createChatCompletionModel(String apiK new AnthropicChatCompletionServiceSettings(modelName, null), new AnthropicChatCompletionTaskSettings(maxTokens, null, null, null), new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } 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 f504dbd2f4172..ad1c38988e3af 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 @@ -18,6 +18,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -119,7 +120,7 @@ public void testParseRequestConfig_CreatesAnAzureAiStudioEmbeddingsModel() throw getEmbeddingsTaskSettingsMap("user"), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -147,7 +148,7 @@ public void testParseRequestConfig_CreatesAnAzureAiStudioChatCompletionModel() t getChatCompletionTaskSettingsMap(null, null, true, null), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -171,7 +172,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getChatCompletionTaskSettingsMap(null, null, true, null), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -201,7 +202,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.COMPLETION, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -229,7 +230,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingServiceS "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -258,7 +259,7 @@ public void testParseRequestConfig_ThrowsWhenDimsSetByUserExistsInEmbeddingServi "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -290,7 +291,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingTaskSett "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -322,7 +323,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingSecretSe "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -354,7 +355,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInChatCompletionSer "id", TaskType.COMPLETION, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -386,7 +387,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInChatCompletionTas "id", TaskType.COMPLETION, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -418,7 +419,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInChatCompletionSec "id", TaskType.COMPLETION, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -442,7 +443,7 @@ public void testParseRequestConfig_ThrowsWhenProviderIsNotValidForEmbeddings() t "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -469,7 +470,7 @@ public void testParseRequestConfig_ThrowsWhenEndpointTypeIsNotValidForEmbeddings "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -500,7 +501,7 @@ public void testParseRequestConfig_ThrowsWhenEndpointTypeIsNotValidForChatComple "id", TaskType.COMPLETION, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -519,7 +520,7 @@ public void testParsePersistedConfig_CreatesAnAzureAiStudioEmbeddingsModel() thr TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -549,7 +550,7 @@ public void testParsePersistedConfig_CreatesAnAzureAiStudioChatCompletionModel() TaskType.COMPLETION, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); @@ -583,7 +584,7 @@ public void testParsePersistedConfig_ThrowsUnsupportedModelType() throws IOExcep getChatCompletionTaskSettingsMap(null, null, true, null), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -604,7 +605,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM TaskType.SPARSE_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -628,7 +629,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -649,7 +650,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenExtraKeyExistsInEmbeddingSe TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -670,7 +671,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -691,7 +692,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -711,7 +712,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInChatCompl TaskType.COMPLETION, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); @@ -731,7 +732,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInChatCompl TaskType.COMPLETION, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); @@ -751,7 +752,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInChatCompl TaskType.COMPLETION, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); @@ -770,7 +771,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesEmbeddingsModel() thro "id", TaskType.TEXT_EMBEDDING, config.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -794,12 +795,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesChatCompletionModel() Map.of() ); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - config.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, config.config(), EndpointVersions.FIRST_ENDPOINT_VERSION); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); @@ -920,7 +916,7 @@ public void testCheckModelConfig_WorksForChatCompletionsModel() throws IOExcepti null, null, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); PlainActionFuture listener = new PlainActionFuture<>(); @@ -941,7 +937,7 @@ public void testCheckModelConfig_WorksForChatCompletionsModel() throws IOExcepti null, AzureAiStudioChatCompletionTaskSettings.DEFAULT_MAX_NEW_TOKENS, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java index 3378eea246245..bd3e5cea349a2 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.azureaistudio.AzureAiStudioEndpointType; @@ -37,7 +37,7 @@ public void testOverrideWith_OverridesWithoutValues() { false, 512, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var requestTaskSettingsMap = getTaskSettingsMap(null, null, null, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettingsMap); @@ -57,7 +57,7 @@ public void testOverrideWith_temperature() { null, null, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var requestTaskSettings = getTaskSettingsMap(0.5, null, null, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -75,7 +75,7 @@ public void testOverrideWith_temperature() { null, null, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ); @@ -93,7 +93,7 @@ public void testOverrideWith_topP() { null, null, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var requestTaskSettings = getTaskSettingsMap(null, 0.5, null, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -111,7 +111,7 @@ public void testOverrideWith_topP() { null, null, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ); @@ -129,7 +129,7 @@ public void testOverrideWith_doSample() { true, null, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var requestTaskSettings = getTaskSettingsMap(null, null, false, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -147,7 +147,7 @@ public void testOverrideWith_doSample() { false, null, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ); @@ -165,7 +165,7 @@ public void testOverrideWith_maxNewTokens() { null, 512, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var requestTaskSettings = getTaskSettingsMap(null, null, null, 128); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -183,7 +183,7 @@ public void testOverrideWith_maxNewTokens() { null, 128, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ); @@ -228,7 +228,7 @@ public static AzureAiStudioChatCompletionModel createModel( null, null, null, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -243,7 +243,7 @@ public static AzureAiStudioChatCompletionModel createModel( @Nullable Boolean doSample, @Nullable Integer maxNewTokens, @Nullable RateLimitSettings rateLimitSettings, - String endpointVersion + EndpointVersions endpointVersion ) { return new AzureAiStudioChatCompletionModel( id, diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java index 4e8b7d172975f..4412c00fdfda7 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -134,7 +134,7 @@ public static AzureAiStudioEmbeddingsModel createModel( ), new AzureAiStudioEmbeddingsTaskSettings(user), new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java index 4318f88d27dc9..01c999b35556f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -117,7 +118,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModel() throws IOExc getAzureOpenAiRequestTaskSettingsMap("user"), getAzureOpenAiSecretSettingsMap("secret", null) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -141,7 +142,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getAzureOpenAiRequestTaskSettingsMap("user"), getAzureOpenAiSecretSettingsMap("secret", null) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -171,7 +172,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -202,7 +203,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -233,7 +234,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -264,7 +265,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -291,7 +292,7 @@ public void testParseRequestConfig_MovesModel() throws IOException { getAzureOpenAiRequestTaskSettingsMap("user"), getAzureOpenAiSecretSettingsMap("secret", null) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -310,7 +311,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnAzureOpenAiEmbeddingsMo TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -341,7 +342,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -366,7 +367,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -398,7 +399,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -428,7 +429,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -460,7 +461,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -492,7 +493,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -519,7 +520,7 @@ public void testParsePersistedConfig_CreatesAnAzureOpenAiEmbeddingsModel() throw "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -546,7 +547,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -569,7 +570,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -600,7 +601,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -628,7 +629,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); 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 ed675b9ec2974..6373d470da50c 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 @@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.azureopenai.AzureOpenAiSecretSettings; @@ -44,7 +44,7 @@ public void testOverrideWith_UpdatedTaskSettings_OverridesUser() { apiKey, entraId, inferenceEntityId, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var requestTaskSettingsMap = taskSettingsMap(userOverride); var overriddenModel = AzureOpenAiCompletionModel.of(model, requestTaskSettingsMap); @@ -60,7 +60,7 @@ public void testOverrideWith_UpdatedTaskSettings_OverridesUser() { apiKey, entraId, inferenceEntityId, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ); @@ -75,7 +75,7 @@ public void testOverrideWith_EmptyMap_OverridesNothing() { "api key", "entra id", "inference entity id", - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var requestTaskSettingsMap = Map.of(); @@ -93,7 +93,7 @@ public void testOverrideWith_NullMap_OverridesNothing() { "api key", "entra id", "inference entity id", - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var overriddenModel = AzureOpenAiCompletionModel.of(model, null); @@ -122,7 +122,7 @@ public void testOverrideWith_UpdatedServiceSettings_OverridesApiVersion() { apiKey, entraId, inferenceEntityId, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var overriddenModel = new AzureOpenAiCompletionModel(model, updatedServiceSettings); @@ -137,7 +137,7 @@ public void testOverrideWith_UpdatedServiceSettings_OverridesApiVersion() { apiKey, entraId, inferenceEntityId, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ) ); @@ -160,7 +160,7 @@ public void testBuildUriString() throws URISyntaxException { apiKey, entraId, inferenceEntityId, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat( @@ -178,7 +178,7 @@ public static AzureOpenAiCompletionModel createModelWithRandomValues() { randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -191,7 +191,7 @@ public static AzureOpenAiCompletionModel createCompletionModel( @Nullable String apiKey, @Nullable String entraId, String inferenceEntityId, - String endpointVersion + EndpointVersions endpointVersion ) { var secureApiKey = apiKey != null ? new SecureString(apiKey.toCharArray()) : null; var secureEntraId = entraId != null ? new SecureString(entraId.toCharArray()) : null; @@ -203,7 +203,7 @@ public static AzureOpenAiCompletionModel createCompletionModel( new AzureOpenAiCompletionServiceSettings(resourceName, deploymentId, apiVersion, null), new AzureOpenAiCompletionTaskSettings(user), new AzureOpenAiSecretSettings(secureApiKey, secureEntraId), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java index 1fb1a7d055a86..295d28db47146 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -114,7 +114,7 @@ public static AzureOpenAiEmbeddingsModel createModel( new AzureOpenAiEmbeddingsServiceSettings(resourceName, deploymentId, apiVersion, null, false, null, null, null), new AzureOpenAiEmbeddingsTaskSettings(user), new AzureOpenAiSecretSettings(secureApiKey, secureEntraId), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -150,7 +150,7 @@ public static AzureOpenAiEmbeddingsModel createModel( ), new AzureOpenAiEmbeddingsTaskSettings(user), new AzureOpenAiSecretSettings(secureApiKey, secureEntraId), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java index 78c1ce22b2cef..7d2986e302ae4 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java @@ -19,6 +19,7 @@ import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -122,7 +123,7 @@ public void testParseRequestConfig_CreatesACohereEmbeddingsModel() throws IOExce getTaskSettingsMap(InputType.INGEST, CohereTruncation.START), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); @@ -150,7 +151,7 @@ public void testParseRequestConfig_OptionalTaskSettings() throws IOException { CohereEmbeddingsServiceSettingsTests.getServiceSettingsMap("url", "model", CohereEmbeddingType.FLOAT), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); @@ -172,7 +173,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getTaskSettingsMapEmpty(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -198,7 +199,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -213,7 +214,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -232,7 +233,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -252,7 +253,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -275,7 +276,7 @@ public void testParseRequestConfig_CreatesACohereEmbeddingsModelWithoutUrl() thr getTaskSettingsMapEmpty(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); @@ -295,7 +296,7 @@ public void testParsePersistedConfigWithSecrets_CreatesACohereEmbeddingsModel() TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -323,7 +324,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -347,7 +348,7 @@ public void testParsePersistedConfigWithSecrets_CreatesACohereEmbeddingsModelWit TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -373,7 +374,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -406,7 +407,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -432,7 +433,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -457,7 +458,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -485,7 +486,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -509,7 +510,7 @@ public void testParsePersistedConfig_CreatesACohereEmbeddingsModel() throws IOEx "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -535,7 +536,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -557,7 +558,7 @@ public void testParsePersistedConfig_CreatesACohereEmbeddingsModelWithoutUrl() t "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -583,7 +584,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -606,7 +607,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -632,7 +633,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); 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 8af4456538d21..ae92024a14367 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 @@ -10,7 +10,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.ConfigurationParseContext; @@ -32,7 +32,7 @@ public void testCreateModel_AlwaysWithEmptyTaskSettings() { new HashMap<>(Map.of("model", "overridden model")), null, ConfigurationParseContext.PERSISTENT, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); @@ -47,7 +47,7 @@ public static CohereCompletionModel createModel(String url, String apiKey, @Null new CohereCompletionServiceSettings(url, model, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } 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 5286e65e52bea..8a722651f55e0 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 @@ -9,8 +9,8 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; -import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -224,7 +224,7 @@ public static CohereEmbeddingsModel createModel( ), taskSettings, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -248,7 +248,7 @@ public static CohereEmbeddingsModel createModel( ), taskSettings, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java index a3a5695f583de..fdf8e033f98b8 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.inference.EmptySecretSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.elasticsearch.ElserModels; @@ -29,7 +29,7 @@ public static ElasticInferenceServiceSparseEmbeddingsModel createModel(String ur EmptyTaskSettings.INSTANCE, EmptySecretSettings.INSTANCE, new ElasticInferenceServiceComponents(url), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java index de2e4923c780a..80279eee3eadc 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java @@ -17,10 +17,10 @@ import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.EmptySecretSettings; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; -import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockResponse; @@ -104,7 +104,7 @@ public void testParseRequestConfig_CreatesASparseEmbeddingsModel() throws IOExce "id", TaskType.SPARSE_EMBEDDING, getRequestConfigMap(Map.of(ServiceFields.MODEL_ID, ElserModels.ELSER_V2_MODEL), Map.of(), Map.of()), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -121,7 +121,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti "id", TaskType.COMPLETION, getRequestConfigMap(Map.of(ServiceFields.MODEL_ID, ElserModels.ELSER_V2_MODEL), Map.of(), Map.of()), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -136,13 +136,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig( - "id", - TaskType.SPARSE_EMBEDDING, - config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, - failureListener - ); + service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -157,13 +151,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig( - "id", - TaskType.SPARSE_EMBEDDING, - config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, - failureListener - ); + service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -177,13 +165,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig( - "id", - TaskType.SPARSE_EMBEDDING, - config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, - failureListener - ); + service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -197,13 +179,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig( - "id", - TaskType.SPARSE_EMBEDDING, - config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, - failureListener - ); + service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -220,7 +196,7 @@ public void testParsePersistedConfigWithSecrets_CreatesASparseEmbeddingModel() t TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -246,7 +222,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -270,7 +246,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -297,7 +273,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -324,7 +300,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java index c84617d59cfbd..47f809515f2f2 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java @@ -21,6 +21,7 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceResults; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InputType; @@ -118,7 +119,7 @@ public void testParseRequestConfig() { ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - service.parseRequestConfig(randomInferenceEntityId, taskType, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, modelListener); + service.parseRequestConfig(randomInferenceEntityId, taskType, config, EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener); } public void testParseRequestConfig_Misconfigured() { @@ -140,13 +141,7 @@ public void testParseRequestConfig_Misconfigured() { ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - service.parseRequestConfig( - randomInferenceEntityId, - taskType, - config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, - modelListener - ); + service.parseRequestConfig(randomInferenceEntityId, taskType, config, EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener); } // Invalid config map @@ -168,13 +163,7 @@ public void testParseRequestConfig_Misconfigured() { ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - service.parseRequestConfig( - randomInferenceEntityId, - taskType, - config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, - modelListener - ); + service.parseRequestConfig(randomInferenceEntityId, taskType, config, EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener); } } @@ -202,7 +191,7 @@ public void testParseRequestConfig_E5() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, getE5ModelVerificationActionListener(e5ServiceSettings) ); } @@ -235,7 +224,7 @@ public void testParseRequestConfig_E5() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, getE5ModelVerificationActionListener(e5ServiceSettings) ); } @@ -269,7 +258,7 @@ public void testParseRequestConfig_E5() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -303,7 +292,7 @@ public void testParseRequestConfig_elser() { randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, getElserModelVerificationActionListener( elserServiceSettings, null, @@ -339,7 +328,7 @@ public void testParseRequestConfig_elser() { randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, getElserModelVerificationActionListener(elserServiceSettings, criticalWarning, warnWarning) ); assertWarnings(true, new DeprecationWarning(DeprecationLogger.CRITICAL, criticalWarning)); @@ -377,7 +366,7 @@ public void testParseRequestConfig_elser() { randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -430,7 +419,7 @@ public void testParseRequestConfig_Rerank() { randomInferenceEntityId, TaskType.RERANK, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -478,7 +467,7 @@ public void testParseRequestConfig_Rerank_DefaultTaskSettings() { randomInferenceEntityId, TaskType.RERANK, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -523,7 +512,7 @@ public void testParseRequestConfig_SparseEmbedding() { randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -536,7 +525,7 @@ private ActionListener getE5ModelVerificationActionListener(MultilingualE TaskType.TEXT_EMBEDDING, ElasticsearchInternalService.NAME, e5ServiceSettings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), model ); @@ -561,7 +550,7 @@ private ActionListener getElserModelVerificationActionListener( NAME, elserServiceSettings, ElserMlNodeTaskSettings.DEFAULT, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), model ); @@ -594,7 +583,7 @@ public void testParsePersistedConfig() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -624,7 +613,7 @@ public void testParsePersistedConfig() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var elandServiceSettings = new CustomElandInternalTextEmbeddingServiceSettings(1, 4, "invalid", null); assertEquals( @@ -633,7 +622,7 @@ public void testParsePersistedConfig() { TaskType.TEXT_EMBEDDING, ElasticsearchInternalService.NAME, elandServiceSettings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), parsedModel ); @@ -665,7 +654,7 @@ public void testParsePersistedConfig() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertEquals( new MultilingualE5SmallModel( @@ -673,7 +662,7 @@ public void testParsePersistedConfig() { TaskType.TEXT_EMBEDDING, ElasticsearchInternalService.NAME, e5ServiceSettings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), parsedModel ); @@ -694,7 +683,7 @@ public void testParsePersistedConfig() { var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); expectThrows( IllegalArgumentException.class, - () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings, ModelConfigurations.FIRST_ENDPOINT_VERSION) + () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings, EndpointVersions.FIRST_ENDPOINT_VERSION) ); } @@ -718,7 +707,7 @@ public void testParsePersistedConfig() { var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); expectThrows( IllegalArgumentException.class, - () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings, ModelConfigurations.FIRST_ENDPOINT_VERSION) + () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings, EndpointVersions.FIRST_ENDPOINT_VERSION) ); } } @@ -745,7 +734,7 @@ public void testChunkInfer_e5() { TaskType.TEXT_EMBEDDING, "e5", new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var service = createService(client); @@ -834,7 +823,7 @@ public void testChunkInfer_Sparse() { TaskType.SPARSE_EMBEDDING, "elasticsearch", new ElasticsearchInternalServiceSettings(1, 1, "model-id", null), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var service = createService(client); @@ -898,7 +887,7 @@ public void testChunkInferSetsTokenization() { TaskType.TEXT_EMBEDDING, "e5", new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); var service = createService(client); @@ -959,7 +948,7 @@ public void testParsePersistedConfig_Rerank() { randomInferenceEntityId, TaskType.RERANK, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model.getTaskSettings(), instanceOf(CustomElandRerankTaskSettings.class)); assertEquals(returnDocs, ((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); @@ -988,7 +977,7 @@ public void testParsePersistedConfig_Rerank() { randomInferenceEntityId, TaskType.RERANK, settings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model.getTaskSettings(), instanceOf(CustomElandRerankTaskSettings.class)); assertTrue(((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); @@ -1028,7 +1017,7 @@ public void testParseRequestConfigEland_PreservesTaskType() { CustomElandModel expectedModel = getCustomElandModel(taskType); PlainActionFuture listener = new PlainActionFuture<>(); - service.parseRequestConfig(randomInferenceEntityId, taskType, settings, ModelConfigurations.FIRST_ENDPOINT_VERSION, listener); + service.parseRequestConfig(randomInferenceEntityId, taskType, settings, EndpointVersions.FIRST_ENDPOINT_VERSION, listener); var model = listener.actionGet(TimeValue.THIRTY_SECONDS); assertThat(model, is(expectedModel)); } @@ -1042,7 +1031,7 @@ private CustomElandModel getCustomElandModel(TaskType taskType) { ElasticsearchInternalService.NAME, new CustomElandInternalServiceSettings(1, 4, "custom-model", null), CustomElandRerankTaskSettings.DEFAULT_SETTINGS, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } else if (taskType == TaskType.TEXT_EMBEDDING) { var serviceSettings = new CustomElandInternalTextEmbeddingServiceSettings(1, 4, "custom-model", null); @@ -1052,7 +1041,7 @@ private CustomElandModel getCustomElandModel(TaskType taskType) { taskType, ElasticsearchInternalService.NAME, serviceSettings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } else if (taskType == TaskType.SPARSE_EMBEDDING) { expectedModel = new CustomElandModel( @@ -1060,7 +1049,7 @@ private CustomElandModel getCustomElandModel(TaskType taskType) { taskType, ElasticsearchInternalService.NAME, new CustomElandInternalServiceSettings(1, 4, "custom-model", null), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } return expectedModel; @@ -1111,7 +1100,7 @@ public void testPutModel() { TaskType.TEXT_EMBEDDING, "e5", new MultilingualE5SmallInternalServiceSettings(1, 1, ".multilingual-e5-small", null), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); service.putModel(model, new ActionListener<>() { @@ -1163,7 +1152,7 @@ public void testParseRequestConfigEland_SetsDimensionsToOne() { taskType, ElasticsearchInternalService.NAME, serviceSettings, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); PlainActionFuture listener = new PlainActionFuture<>(); @@ -1181,7 +1170,7 @@ public void testParseRequestConfigEland_SetsDimensionsToOne() { SimilarityMeasure.COSINE, DenseVectorFieldMapper.ElementType.FLOAT ), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ), listener ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java index 47a08a35296b6..bd3730ff76f91 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java @@ -19,6 +19,7 @@ import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -125,7 +126,7 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioCompletionModel() throw new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -152,7 +153,7 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioEmbeddingsModel() throw new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -181,7 +182,7 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin createRandomChunkingSettingsMap(), getSecretSettingsMap(apiKey) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -212,7 +213,7 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenChun createRandomChunkingSettingsMap(), getSecretSettingsMap(apiKey) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -242,7 +243,7 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenChun new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -263,7 +264,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -282,7 +283,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -297,7 +298,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -316,7 +317,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -335,7 +336,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -355,7 +356,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioCompletion TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -383,7 +384,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioEmbeddings TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -414,7 +415,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioEmbeddings TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -446,7 +447,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioEmbeddings TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -477,7 +478,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChun TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -507,7 +508,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -538,7 +539,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -565,7 +566,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -596,7 +597,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.COMPLETION, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -618,7 +619,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioCompletionModel() thr "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -646,7 +647,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiEmbeddingsModelWithoutChunk "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -675,7 +676,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenCh "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -700,7 +701,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenCh "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -724,7 +725,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -749,7 +750,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -774,7 +775,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti "id", TaskType.COMPLETION, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); 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 eefb0c839d834..55bbf767faf81 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 @@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.ConfigurationParseContext; @@ -32,7 +32,7 @@ public void testCreateModel_AlwaysWithEmptyTaskSettings() { new HashMap<>(Map.of()), null, ConfigurationParseContext.PERSISTENT, - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model.getTaskSettings(), is(EmptyTaskSettings.INSTANCE)); @@ -53,7 +53,7 @@ public static GoogleAiStudioCompletionModel createModel(String model, String api new GoogleAiStudioCompletionServiceSettings(model, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -66,7 +66,7 @@ public static GoogleAiStudioCompletionModel createModel(String model, String url new GoogleAiStudioCompletionServiceSettings(model, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } 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 2744c2f4e9f17..9f4255bb4c9e0 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 @@ -11,7 +11,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -28,7 +28,7 @@ public static GoogleAiStudioEmbeddingsModel createModel(String model, String api new GoogleAiStudioEmbeddingsServiceSettings(model, null, null, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -42,7 +42,7 @@ public static GoogleAiStudioEmbeddingsModel createModel(String model, ChunkingSe EmptyTaskSettings.INSTANCE, chunkingSettings, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -61,7 +61,7 @@ public static GoogleAiStudioEmbeddingsModel createModel( new GoogleAiStudioEmbeddingsServiceSettings(model, null, dimensions, similarityMeasure, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -80,7 +80,7 @@ public static GoogleAiStudioEmbeddingsModel createModel( EmptyTaskSettings.INSTANCE, null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java index f17c2cf5a8d8e..1b32d40e1fa1e 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; @@ -102,7 +103,7 @@ public void testParseRequestConfig_CreatesGoogleVertexAiEmbeddingsModel() throws new HashMap<>(Map.of()), getSecretSettingsMap(serviceAccountJson) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -134,7 +135,7 @@ public void testParseRequestConfig_CreatesGoogleVertexAiRerankModel() throws IOE new HashMap<>(Map.of()), getSecretSettingsMap(serviceAccountJson) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -164,7 +165,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("{}") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -192,7 +193,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -216,7 +217,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -244,7 +245,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -272,7 +273,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -310,7 +311,7 @@ public void testParsePersistedConfigWithSecrets_CreatesGoogleVertexAiEmbeddingsM TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -346,7 +347,7 @@ public void testParsePersistedConfigWithSecrets_CreatesGoogleVertexAiRerankModel TaskType.RERANK, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiRerankModel.class)); @@ -393,7 +394,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -445,7 +446,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -497,7 +498,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -549,7 +550,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); 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 59705de730531..f4f849ba6ff2a 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 @@ -10,7 +10,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -61,7 +61,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())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -83,7 +83,7 @@ public static GoogleVertexAiEmbeddingsModel createModel(String modelId, @Nullabl ), new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate), new GoogleVertexAiSecretSettings(new SecureString(randomAlphaOfLength(8).toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } 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 007c882f20827..1193b9e671dcb 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 @@ -9,7 +9,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.googlevertexai.GoogleVertexAiSecretSettings; @@ -47,7 +47,7 @@ public static GoogleVertexAiRerankModel createModel(@Nullable String modelId, @N new GoogleVertexAiRerankServiceSettings(randomAlphaOfLength(10), modelId, null), new GoogleVertexAiRerankTaskSettings(topN), new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -61,7 +61,7 @@ public static GoogleVertexAiRerankModel createModel(String url, @Nullable String new GoogleVertexAiRerankServiceSettings(randomAlphaOfLength(10), modelId, null), new GoogleVertexAiRerankTaskSettings(topN), new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java index 4ca754ae020ee..9c1d556427aa6 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -107,7 +108,7 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModel() throws IOException "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), getSecretSettingsMap("secret")), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -132,7 +133,7 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap(), getSecretSettingsMap("secret")), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -154,7 +155,7 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsP "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap(), getSecretSettingsMap("secret")), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -176,7 +177,7 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsN "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), getSecretSettingsMap("secret")), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -196,7 +197,7 @@ public void testParseRequestConfig_CreatesAnElserModel() throws IOException { "id", TaskType.SPARSE_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), getSecretSettingsMap("secret")), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -222,7 +223,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -250,7 +251,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -278,7 +279,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -293,7 +294,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModel() throw TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -320,7 +321,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWithoutC TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -348,7 +349,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChun TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -371,7 +372,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChun TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -392,7 +393,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnElserModel() throws IOE TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceElserModel.class)); @@ -413,7 +414,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -436,7 +437,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -457,7 +458,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -480,7 +481,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -503,7 +504,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -522,7 +523,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModel() throws IOExcepti "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -543,7 +544,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWithoutChunkingSett "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -564,7 +565,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSetting "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -585,7 +586,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSetting "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -605,7 +606,7 @@ public void testParsePersistedConfig_CreatesAnElserModel() throws IOException { "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceElserModel.class)); @@ -625,7 +626,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -647,7 +648,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -669,7 +670,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java index 6b0f2040e0e2f..27e1ddb43ee1b 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java @@ -8,7 +8,7 @@ package org.elasticsearch.xpack.inference.services.huggingface.elser; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings; @@ -29,7 +29,7 @@ public static HuggingFaceElserModel createModel(String url, String apiKey) { "service", new HuggingFaceElserServiceSettings(url), new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -40,7 +40,7 @@ public static HuggingFaceElserModel createModel(String url, String apiKey, Strin "service", new HuggingFaceElserServiceSettings(url), new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } } 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 7bdbdaa77c038..e4b7f643b9e42 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 @@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -34,7 +34,7 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey) new HuggingFaceServiceSettings(url), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -46,7 +46,7 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey, new HuggingFaceServiceSettings(createUri(url), null, null, tokenLimit, null), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -59,7 +59,7 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey, new HuggingFaceServiceSettings(createUri(url), null, dimensions, tokenLimit, null), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -78,7 +78,7 @@ public static HuggingFaceEmbeddingsModel createModel( new HuggingFaceServiceSettings(createUri(url), similarityMeasure, dimensions, tokenLimit, null), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java index bbdee3b5ee3ce..b06cb6a51ad8c 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.EmptyTaskSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -138,7 +139,7 @@ public void testParseRequestConfig_CreatesAIbmWatsonxEmbeddingsModel() throws IO new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -159,7 +160,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -191,7 +192,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [watsonxai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, ModelConfigurations.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); } } @@ -219,7 +220,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAIbmWatsonxEmbeddingsMode TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -259,7 +260,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -301,7 +302,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -339,7 +340,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -384,7 +385,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java index 7c8e2dd1135fe..5be17eba88327 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -35,7 +35,7 @@ public static IbmWatsonxEmbeddingsModel createModel( new IbmWatsonxEmbeddingsServiceSettings(model, projectId, uri, apiVersion, null, null, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -57,7 +57,7 @@ public static IbmWatsonxEmbeddingsModel createModel( new IbmWatsonxEmbeddingsServiceSettings(model, projectId, uri, apiVersion, null, dimensions, similarityMeasure, null), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -86,7 +86,7 @@ public static IbmWatsonxEmbeddingsModel createModel( ), EmptyTaskSettings.INSTANCE, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java index b3b6f01ad17fa..c0ffbebff8aec 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -116,7 +117,7 @@ public void testParseRequestConfig_CreatesAMistralEmbeddingsModel() throws IOExc getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -143,7 +144,7 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -172,7 +173,7 @@ public void testParseRequestConfig_CreatesAMistralEmbeddingsModelWhenChunkingSet createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -200,7 +201,7 @@ public void testParseRequestConfig_CreatesAMistralEmbeddingsModelWhenChunkingSet getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -224,7 +225,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -254,7 +255,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -286,7 +287,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingTaskSett "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -318,7 +319,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingSecretSe "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -337,7 +338,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModel() throws IOE TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -365,7 +366,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWithoutChunki TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -395,7 +396,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWhenChunkingS TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -424,7 +425,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWhenChunkingS TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -456,7 +457,7 @@ public void testParsePersistedConfig_ThrowsUnsupportedModelType() throws IOExcep getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -477,7 +478,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM TaskType.SPARSE_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -501,7 +502,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -522,7 +523,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenExtraKeyExistsInEmbeddingSe TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -543,7 +544,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -564,7 +565,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding TaskType.TEXT_EMBEDDING, config.config(), config.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -583,7 +584,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesEmbeddingsModel() thro "id", TaskType.TEXT_EMBEDDING, config.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -610,7 +611,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWitho "id", TaskType.TEXT_EMBEDDING, config.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -638,7 +639,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWhenC "id", TaskType.TEXT_EMBEDDING, config.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -665,7 +666,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWhenC "id", TaskType.TEXT_EMBEDDING, config.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java index e881a04383ab6..1197ec830bc6b 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java @@ -11,7 +11,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -41,7 +41,7 @@ public static MistralEmbeddingsModel createModel( EmptyTaskSettings.INSTANCE, chunkingSettings, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -62,7 +62,7 @@ public static MistralEmbeddingsModel createModel( EmptyTaskSettings.INSTANCE, null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java index 350778f47e8d1..922989abed57c 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java @@ -19,10 +19,10 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; -import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -126,7 +126,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModel() throws IOExc getTaskSettingsMap("user"), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -161,7 +161,7 @@ public void testParseRequestConfig_CreatesAnOpenAiChatCompletionsModel() throws getTaskSettingsMap(user), getSecretSettingsMap(secret) ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -185,7 +185,7 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getTaskSettingsMap("user"), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -215,7 +215,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -239,7 +239,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -263,7 +263,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -287,7 +287,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap "id", TaskType.TEXT_EMBEDDING, config, - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -310,7 +310,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModelWithoutUserUrlO "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("model", null, null), getTaskSettingsMap(null), getSecretSettingsMap("secret")), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -337,7 +337,7 @@ public void testParseRequestConfig_CreatesAnOpenAiChatCompletionsModelWithoutUse "id", TaskType.COMPLETION, getRequestConfigMap(getServiceSettingsMap(model, null, null), getTaskSettingsMap(null), getSecretSettingsMap(secret)), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -364,7 +364,7 @@ public void testParseRequestConfig_MovesModel() throws IOException { getTaskSettingsMap("user"), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -391,7 +391,7 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -422,7 +422,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingSet createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -448,7 +448,7 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingSet "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("model", null, null), getTaskSettingsMap(null), getSecretSettingsMap("secret")), - ModelConfigurations.FIRST_ENDPOINT_VERSION, + EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -467,7 +467,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModel() TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -496,7 +496,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM TaskType.SPARSE_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -520,7 +520,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWi TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -550,7 +550,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWi TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -581,7 +581,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWh TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -611,7 +611,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWh TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -640,7 +640,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -671,7 +671,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -699,7 +699,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -726,7 +726,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -756,7 +756,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa TaskType.TEXT_EMBEDDING, persistedConfig.config(), persistedConfig.secrets(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -781,7 +781,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModel() throws IOE "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -805,7 +805,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ) ); @@ -827,7 +827,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWithoutUserUr "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -855,7 +855,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWithoutChunki "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -884,7 +884,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingS "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -912,7 +912,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingS "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -939,7 +939,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -964,7 +964,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -989,7 +989,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java index 33bc3fa8e6591..fca68f3d27d30 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings; @@ -61,7 +61,7 @@ public static OpenAiChatCompletionModel createChatCompletionModel( new OpenAiChatCompletionServiceSettings(modelName, url, org, null, null), new OpenAiChatCompletionTaskSettings(user), new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java index d5c6e8614dfa5..c8731385ca50e 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.ModelConfigurations; +import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -65,7 +65,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsTaskSettings(user), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -85,7 +85,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsTaskSettings(user), chunkingSettings, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -104,7 +104,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsTaskSettings(user), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -124,7 +124,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsTaskSettings(user), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -145,7 +145,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsTaskSettings(user), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } @@ -168,7 +168,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsTaskSettings(user), null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - ModelConfigurations.FIRST_ENDPOINT_VERSION + EndpointVersions.FIRST_ENDPOINT_VERSION ); } } From 8c9c4f4a3be222daf3d8d68ad46bb6441f07985a Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Mon, 7 Oct 2024 12:11:59 -0400 Subject: [PATCH 08/15] undo renaming task_settings field name --- .../elasticsearch/inference/ModelConfigurations.java | 6 +++--- .../core/inference/action/PutInferenceModelAction.java | 8 ++++---- .../inference/action/PutInferenceModelActionTests.java | 10 +++++----- .../inference/mock/AbstractTestInferenceService.java | 4 ++-- .../xpack/inference/integration/ModelRegistryIT.java | 4 ++-- .../xpack/inference/registry/ModelRegistry.java | 4 ++-- .../alibabacloudsearch/AlibabaCloudSearchService.java | 6 +++--- .../AlibabaCloudSearchEmbeddingsTaskSettings.java | 2 +- .../sparse/AlibabaCloudSearchSparseTaskSettings.java | 2 +- .../services/amazonbedrock/AmazonBedrockService.java | 6 +++--- ...AmazonBedrockChatCompletionRequestTaskSettings.java | 8 ++++---- .../AmazonBedrockChatCompletionTaskSettings.java | 8 ++++---- .../inference/services/anthropic/AnthropicService.java | 6 +++--- .../AnthropicChatCompletionTaskSettings.java | 2 +- .../services/azureaistudio/AzureAiStudioService.java | 6 +++--- ...AzureAiStudioChatCompletionRequestTaskSettings.java | 6 +++--- .../AzureAiStudioChatCompletionTaskSettings.java | 6 +++--- .../AzureAiStudioEmbeddingsRequestTaskSettings.java | 2 +- .../AzureAiStudioEmbeddingsTaskSettings.java | 2 +- .../services/azureopenai/AzureOpenAiService.java | 6 +++--- .../AzureOpenAiCompletionRequestTaskSettings.java | 2 +- .../completion/AzureOpenAiCompletionTaskSettings.java | 2 +- .../AzureOpenAiEmbeddingsRequestTaskSettings.java | 2 +- .../embeddings/AzureOpenAiEmbeddingsTaskSettings.java | 2 +- .../xpack/inference/services/cohere/CohereService.java | 6 +++--- .../embeddings/CohereEmbeddingsTaskSettings.java | 4 ++-- .../cohere/rerank/CohereRerankTaskSettings.java | 4 ++-- .../services/elastic/ElasticInferenceService.java | 6 +++--- .../elasticsearch/ElasticsearchInternalService.java | 4 ++-- .../services/googleaistudio/GoogleAiStudioService.java | 6 +++--- .../services/googlevertexai/GoogleVertexAiService.java | 6 +++--- .../GoogleVertexAiRerankRequestTaskSettings.java | 2 +- .../rerank/GoogleVertexAiRerankTaskSettings.java | 2 +- .../services/ibmwatsonx/IbmWatsonxService.java | 6 +++--- .../inference/services/mistral/MistralService.java | 6 +++--- .../xpack/inference/services/openai/OpenAiService.java | 6 +++--- .../OpenAiChatCompletionRequestTaskSettings.java | 2 +- .../completion/OpenAiChatCompletionTaskSettings.java | 2 +- .../OpenAiEmbeddingsRequestTaskSettings.java | 2 +- .../embeddings/OpenAiEmbeddingsTaskSettings.java | 2 +- .../java/org/elasticsearch/xpack/inference/Utils.java | 10 +++------- .../AlibabaCloudSearchServiceTests.java | 2 +- .../amazonbedrock/AmazonBedrockServiceTests.java | 6 ++---- .../azureaistudio/AzureAiStudioServiceTests.java | 2 +- .../services/azureopenai/AzureOpenAiServiceTests.java | 2 +- .../inference/services/cohere/CohereServiceTests.java | 2 +- .../ElasticsearchInternalServiceTests.java | 4 ++-- .../googleaistudio/GoogleAiStudioServiceTests.java | 2 +- .../googlevertexai/GoogleVertexAiServiceTests.java | 2 +- .../services/ibmwatsonx/IbmWatsonxServiceTests.java | 2 +- .../services/mistral/MistralServiceTests.java | 2 +- 51 files changed, 104 insertions(+), 110 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java index 5e3d11cf983c3..467c38bd92667 100644 --- a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java +++ b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java @@ -28,7 +28,7 @@ public class ModelConfigurations implements ToFilteredXContentObject, VersionedN 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 OLD_TASK_SETTINGS = "task_settings"; + public static final String TASK_SETTINGS = "task_settings"; public static final String PARAMETERS = "parameters"; public static final String CHUNKING_SETTINGS = "chunking_settings"; public static final String INCLUDE_PARAMETERS = "include_parameters"; @@ -200,7 +200,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TaskType.NAME, taskType.toString()); builder.field(SERVICE, service); builder.field(SERVICE_SETTINGS, serviceSettings); - builder.field(OLD_TASK_SETTINGS, taskSettings); + builder.field(TASK_SETTINGS, taskSettings); if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } @@ -225,7 +225,7 @@ public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params builder.field(TaskType.NAME, taskType.toString()); builder.field(SERVICE, service); builder.field(SERVICE_SETTINGS, serviceSettings.getFilteredXContentObject()); - builder.field(OLD_TASK_SETTINGS, taskSettings); + builder.field(TASK_SETTINGS, taskSettings); if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } 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 1ae824cf498d8..65bbae57094c1 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 @@ -32,7 +32,7 @@ import java.util.Objects; import static org.elasticsearch.inference.ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME; -import static org.elasticsearch.inference.ModelConfigurations.OLD_TASK_SETTINGS; +import static org.elasticsearch.inference.ModelConfigurations.TASK_SETTINGS; import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; public class PutInferenceModelAction extends ActionType { @@ -83,16 +83,16 @@ public BytesReference getContent() { 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(OLD_TASK_SETTINGS)) { + 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(PARAMETERS)) { - newContent.put(OLD_TASK_SETTINGS, newContent.get(PARAMETERS)); + newContent.put(TASK_SETTINGS, newContent.get(PARAMETERS)); newContent.put(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.PARAMETERS_INTRODUCED_ENDPOINT_VERSION); newContent.remove(PARAMETERS); - } else if (newContent.containsKey(OLD_TASK_SETTINGS)) { + } else if (newContent.containsKey(TASK_SETTINGS)) { newContent.put(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.FIRST_ENDPOINT_VERSION); } else { newContent.put(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.FIRST_ENDPOINT_VERSION); 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 1d0da27acd388..85df139c15051 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 @@ -26,7 +26,7 @@ import java.util.Map; import static org.elasticsearch.inference.ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME; -import static org.elasticsearch.inference.ModelConfigurations.OLD_TASK_SETTINGS; +import static org.elasticsearch.inference.ModelConfigurations.TASK_SETTINGS; import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; public class PutInferenceModelActionTests extends ESTestCase { @@ -76,7 +76,7 @@ public void testWithParameters() throws IOException { 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.getContent(), false, request.getContentType()).v2(); - assertEquals(parametersValues, map.get(OLD_TASK_SETTINGS)); + assertEquals(parametersValues, map.get(TASK_SETTINGS)); assertNull(map.get(PARAMETERS)); assertEquals("elasticsearch", map.get("service")); assertEquals(serviceSettingsValues, map.get("service_settings")); @@ -91,7 +91,7 @@ public void testWithParametersAndTaskSettings() throws IOException { Map.of( PARAMETERS, parametersValues, - OLD_TASK_SETTINGS, + TASK_SETTINGS, taskSettingsValues, "service", "elasticsearch", @@ -110,10 +110,10 @@ 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(OLD_TASK_SETTINGS, taskSettingsValues, "service", "elasticsearch", "service_settings", serviceSettingsValues)); + 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(OLD_TASK_SETTINGS)); + 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/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java index ef57705612d95..a902fc94a8320 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java @@ -45,8 +45,8 @@ public TransportVersion getMinimalSupportedVersion() { protected static Map getTaskSettingsMap(Map settings) { Map taskSettingsMap; // task settings are optional - if (settings.containsKey(ModelConfigurations.OLD_TASK_SETTINGS)) { - taskSettingsMap = (Map) settings.remove(ModelConfigurations.OLD_TASK_SETTINGS); + if (settings.containsKey(ModelConfigurations.TASK_SETTINGS)) { + taskSettingsMap = (Map) settings.remove(ModelConfigurations.TASK_SETTINGS); } else { taskSettingsMap = Map.of(); } 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 91dee2e2b3430..f984bc35daefd 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 @@ -740,7 +740,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TaskType.NAME, getTaskType().toString()); builder.field(SERVICE, getService()); builder.field(SERVICE_SETTINGS, getServiceSettings()); - builder.field(OLD_TASK_SETTINGS, getTaskSettings()); + builder.field(TASK_SETTINGS, getTaskSettings()); builder.endObject(); return builder; } @@ -767,7 +767,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TaskType.NAME, getTaskType().toString()); builder.field(SERVICE, getService()); builder.field(SERVICE_SETTINGS, getServiceSettings()); - builder.field(OLD_TASK_SETTINGS, getTaskSettings()); + builder.field(TASK_SETTINGS, getTaskSettings()); builder.endObject(); return builder; } 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 44f6b2dfe255b..03084c53f108a 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 @@ -468,10 +468,10 @@ static Map copySettingsMap(Map other) { result.put(ModelConfigurations.SERVICE_SETTINGS, copiedServiceSettings); } - var taskSettings = (Map) other.get(ModelConfigurations.OLD_TASK_SETTINGS); + var taskSettings = (Map) other.get(ModelConfigurations.TASK_SETTINGS); if (taskSettings != null) { var copiedTaskSettings = copyMap1LevelDeep(taskSettings); - result.put(ModelConfigurations.OLD_TASK_SETTINGS, copiedTaskSettings); + result.put(ModelConfigurations.TASK_SETTINGS, copiedTaskSettings); } var chunkSettings = (Map) other.get(ModelConfigurations.CHUNKING_SETTINGS); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java index e7b1cef1201af..775af606c8e3d 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java @@ -74,7 +74,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); AlibabaCloudSearchModel model = createModel( inferenceEntityId, @@ -182,7 +182,7 @@ public AlibabaCloudSearchModel parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); return createModelWithoutLoggingDeprecations( @@ -204,7 +204,7 @@ public AlibabaCloudSearchModel parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); return createModelWithoutLoggingDeprecations( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java index ece60cc1df2a0..abfd49940b67b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java @@ -53,7 +53,7 @@ public static AlibabaCloudSearchEmbeddingsTaskSettings fromMap(Map m InputType inputType = extractOptionalEnum( map, INPUT_TYPE, - ModelConfigurations.OLD_TASK_SETTINGS, + ModelConfigurations.TASK_SETTINGS, InputType::fromString, VALID_REQUEST_VALUES, validationException diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java index 5ddfc52de67fe..8d8ba4449af9d 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java @@ -126,7 +126,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); AmazonBedrockModel model = createModel( modelId, @@ -158,7 +158,7 @@ public Model parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModel( @@ -176,7 +176,7 @@ public Model parsePersistedConfigWithSecrets( @Override public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); return createModel( modelId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionRequestTaskSettings.java index 2b90320ab746b..5985dcd56c5d2 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionRequestTaskSettings.java @@ -55,7 +55,7 @@ public static AmazonBedrockChatCompletionRequestTaskSettings fromMap(Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); AnthropicModel model = createModel( inferenceEntityId, @@ -141,7 +141,7 @@ public AnthropicModel parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -163,7 +163,7 @@ public AnthropicModel parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java index f49e3b60f32f9..a1457dda64e40 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java @@ -62,7 +62,7 @@ private static AnthropicChatCompletionTaskSettings fromPersistedMap(Map map, ValidationException validationException) { - Integer maxTokens = extractRequiredPositiveInteger(map, MAX_TOKENS, ModelConfigurations.OLD_TASK_SETTINGS, validationException); + Integer maxTokens = extractRequiredPositiveInteger(map, MAX_TOKENS, ModelConfigurations.TASK_SETTINGS, validationException); // At the time of writing the allowed values for the temperature field are -1, and range 0-1. // I'm intentionally not validating the values here, we'll let Anthropic return an error when we send it instead. diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java index 7f05c4b9187f8..5a39ab0ce4ae4 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java @@ -115,7 +115,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); AzureAiStudioModel model = createModel( inferenceEntityId, @@ -147,7 +147,7 @@ public AzureAiStudioModel parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -169,7 +169,7 @@ public Model parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionRequestTaskSettings.java index 80c8a297ad201..2eef059e3fae1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionRequestTaskSettings.java @@ -55,7 +55,7 @@ public static AzureAiStudioChatCompletionRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER_FIELD, ModelConfigurations.OLD_TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER_FIELD, ModelConfigurations.TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java index 273064d54da2b..fbe31050433d5 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java @@ -70,7 +70,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); AzureOpenAiModel model = createModel( inferenceEntityId, @@ -162,7 +162,7 @@ public AzureOpenAiModel parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -184,7 +184,7 @@ public AzureOpenAiModel parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionRequestTaskSettings.java index b0bb519cdad92..5dd42bb1b911f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionRequestTaskSettings.java @@ -27,7 +27,7 @@ public static AzureOpenAiCompletionRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsRequestTaskSettings.java index 6a2a65baa054c..ffb8c844ac89f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsRequestTaskSettings.java @@ -40,7 +40,7 @@ public static AzureOpenAiEmbeddingsRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java index 7a8257650bad7..5fe313efecc11 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java @@ -75,7 +75,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); CohereModel model = createModel( inferenceEntityId, @@ -173,7 +173,7 @@ public CohereModel parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); return createModelWithoutLoggingDeprecations( @@ -195,7 +195,7 @@ public CohereModel parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); return createModelWithoutLoggingDeprecations( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java index c585f607f5a94..0a42df8c0bb41 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java @@ -57,7 +57,7 @@ public static CohereEmbeddingsTaskSettings fromMap(Map map) { InputType inputType = extractOptionalEnum( map, INPUT_TYPE, - ModelConfigurations.OLD_TASK_SETTINGS, + ModelConfigurations.TASK_SETTINGS, InputType::fromString, VALID_REQUEST_VALUES, validationException @@ -65,7 +65,7 @@ public static CohereEmbeddingsTaskSettings fromMap(Map map) { CohereTruncation truncation = extractOptionalEnum( map, TRUNCATE, - ModelConfigurations.OLD_TASK_SETTINGS, + ModelConfigurations.TASK_SETTINGS, CohereTruncation::fromString, EnumSet.allOf(CohereTruncation.class), validationException diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java index db3c16f07a2a5..a01f6a4e65b8f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java @@ -53,13 +53,13 @@ public static CohereRerankTaskSettings fromMap(Map map) { Integer topNDocumentsOnly = extractOptionalPositiveInteger( map, TOP_N_DOCS_ONLY, - ModelConfigurations.OLD_TASK_SETTINGS, + ModelConfigurations.TASK_SETTINGS, validationException ); Integer maxChunksPerDoc = extractOptionalPositiveInteger( map, MAX_CHUNKS_PER_DOC, - ModelConfigurations.OLD_TASK_SETTINGS, + ModelConfigurations.TASK_SETTINGS, validationException ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java index 4ff4543c94d68..a0ad1c7cb70b1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java @@ -122,7 +122,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ElasticInferenceServiceModel model = createModel( inferenceEntityId, @@ -182,7 +182,7 @@ public Model parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -204,7 +204,7 @@ public Model parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java index e8ce7c634c4c6..06c316bb36f5f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java @@ -118,7 +118,7 @@ public void parseRequestConfig( try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMap(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMap(config, ModelConfigurations.TASK_SETTINGS); String serviceName = (String) config.remove(ModelConfigurations.SERVICE); // required for elser service in elasticsearch service throwIfNotEmptyMap(config, name()); @@ -428,7 +428,7 @@ public Model parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMap(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMap(config, ModelConfigurations.TASK_SETTINGS); String modelId = (String) serviceSettingsMap.get(ElasticsearchInternalServiceSettings.MODEL_ID); if (modelId == null) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java index b43a6f0293479..029be839773f7 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java @@ -74,7 +74,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { @@ -152,7 +152,7 @@ public GoogleAiStudioModel parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -203,7 +203,7 @@ public Model parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java index 6823ece06ebd1..308149f1aa7fb 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java @@ -70,7 +70,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); GoogleVertexAiModel model = createModel( inferenceEntityId, @@ -102,7 +102,7 @@ public Model parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -124,7 +124,7 @@ public Model parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankRequestTaskSettings.java index 44344e6c0dd60..5cb1acd8038f7 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankRequestTaskSettings.java @@ -29,7 +29,7 @@ public static GoogleVertexAiRerankRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - Integer topN = extractOptionalPositiveInteger(map, TOP_N, ModelConfigurations.OLD_TASK_SETTINGS, validationException); + Integer topN = extractOptionalPositiveInteger(map, TOP_N, ModelConfigurations.TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java index 61429752afd9d..fc1c109291edf 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java @@ -70,7 +70,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); IbmWatsonxModel model = createModel( inferenceEntityId, @@ -128,7 +128,7 @@ public IbmWatsonxModel parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -171,7 +171,7 @@ public Model parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java index 37c3e7a2c22dc..e887a453c18ef 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java @@ -128,7 +128,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { @@ -168,7 +168,7 @@ public Model parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -191,7 +191,7 @@ public Model parsePersistedConfigWithSecrets( @Override public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java index ae797c9df1f67..8138bb57b1087 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java @@ -75,7 +75,7 @@ public void parseRequestConfig( ) { try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { @@ -177,7 +177,7 @@ public OpenAiModel parsePersistedConfigWithSecrets( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -207,7 +207,7 @@ public OpenAiModel parsePersistedConfig( EndpointVersions endpointVersion ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.OLD_TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionRequestTaskSettings.java index bf30792d96b58..8029d8579baba 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionRequestTaskSettings.java @@ -40,7 +40,7 @@ public static OpenAiChatCompletionRequestTaskSettings fromMap(Map map) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettings.java index 7cbc6f5f0b64b..b3b94f7584563 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettings.java @@ -40,7 +40,7 @@ public static OpenAiEmbeddingsRequestTaskSettings fromMap(Map ma ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java index 158c163a989f4..b4cf9b27d0ff1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java @@ -38,7 +38,7 @@ public class OpenAiEmbeddingsTaskSettings implements TaskSettings { public static OpenAiEmbeddingsTaskSettings fromMap(Map map, ConfigurationParseContext context) { ValidationException validationException = new ValidationException(); - String user = extractOptionalString(map, USER, ModelConfigurations.OLD_TASK_SETTINGS, validationException); + String user = extractOptionalString(map, USER, ModelConfigurations.TASK_SETTINGS, validationException); if (validationException.validationErrors().isEmpty() == false) { throw validationException; } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java index 9088705b4c3d5..46f754b2dd9c4 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java @@ -197,9 +197,7 @@ public static PersistedConfig getPersistedConfigMap( var secrets = secretSettings == null ? null : new HashMap(Map.of(ModelSecrets.SECRET_SETTINGS, secretSettings)); return new PersistedConfig( - new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) - ), + new HashMap<>(Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings)), secrets ); } @@ -210,9 +208,7 @@ public static PersistedConfig getPersistedConfigMap(Map serviceS public static PersistedConfig getPersistedConfigMap(Map serviceSettings, Map taskSettings) { return new PersistedConfig( - new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) - ), + new HashMap<>(Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings)), null ); } @@ -239,7 +235,7 @@ public static Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java index 2074a3ff5edb9..2fa3d76cf40c5 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java @@ -257,7 +257,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java index 9301bddad8d5a..136ec46714b98 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java @@ -1184,7 +1184,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } @@ -1195,9 +1195,7 @@ private Utils.PersistedConfig getPersistedConfigMap( ) { return new Utils.PersistedConfig( - new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) - ), + new HashMap<>(Map.of(ModelConfigurations.SERVICE_SETTINGS, serviceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings)), new HashMap<>(Map.of(ModelSecrets.SECRET_SETTINGS, secretSettings)) ); } 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 ad1c38988e3af..378d46855e6d5 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 @@ -1169,7 +1169,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java index 01c999b35556f..ed3600aca3a83 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java @@ -1215,7 +1215,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java index 7d2986e302ae4..c680a12d94a9d 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java @@ -1402,7 +1402,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java index 47f809515f2f2..eb7f0f030f42b 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java @@ -404,7 +404,7 @@ public void testParseRequestConfig_Rerank() { ); var returnDocs = randomBoolean(); settings.put( - ModelConfigurations.OLD_TASK_SETTINGS, + ModelConfigurations.TASK_SETTINGS, new HashMap<>(Map.of(CustomElandRerankTaskSettings.RETURN_DOCUMENTS, returnDocs)) ); @@ -940,7 +940,7 @@ public void testParsePersistedConfig_Rerank() { settings.put(ElasticsearchInternalServiceSettings.MODEL_ID, "foo"); var returnDocs = randomBoolean(); settings.put( - ModelConfigurations.OLD_TASK_SETTINGS, + ModelConfigurations.TASK_SETTINGS, new HashMap<>(Map.of(CustomElandRerankTaskSettings.RETURN_DOCUMENTS, returnDocs)) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java index bd3730ff76f91..4e9c298ee4de4 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java @@ -1306,7 +1306,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java index 1b32d40e1fa1e..ad425b04bc3be 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java @@ -581,7 +581,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java index b06cb6a51ad8c..33af0c1180d20 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java @@ -789,7 +789,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java index c0ffbebff8aec..1be904f1724ef 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java @@ -952,7 +952,7 @@ private Map getRequestConfigMap( builtServiceSettings.putAll(secretSettings); return new HashMap<>( - Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.OLD_TASK_SETTINGS, taskSettings) + Map.of(ModelConfigurations.SERVICE_SETTINGS, builtServiceSettings, ModelConfigurations.TASK_SETTINGS, taskSettings) ); } From 6de692b9b123d6f758be0c17fd7e506127af3eff Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Mon, 7 Oct 2024 15:13:29 -0400 Subject: [PATCH 09/15] Remove endpoint_version --- .../inference/EndpointVersions.java | 25 --- .../inference/InferenceService.java | 21 +- .../inference/ModelConfigurations.java | 61 ++---- .../inference/UnparsedModel.java | 3 +- .../action/PutInferenceModelAction.java | 8 +- .../action/PutInferenceModelActionTests.java | 3 - .../mock/AbstractTestInferenceService.java | 18 +- .../TestDenseInferenceServiceExtension.java | 11 +- .../mock/TestRerankingServiceExtension.java | 10 +- .../TestSparseInferenceServiceExtension.java | 16 +- ...stStreamingCompletionServiceExtension.java | 6 +- .../integration/ModelRegistryIT.java | 176 +++------------- .../xpack/inference/InferenceIndex.java | 60 +----- .../xpack/inference/InferencePlugin.java | 14 +- .../TransportGetInferenceModelAction.java | 14 +- .../action/TransportInferenceAction.java | 3 +- .../TransportPutInferenceModelAction.java | 5 +- .../ShardBulkInferenceActionFilter.java | 3 +- .../inference/registry/ModelRegistry.java | 26 +-- .../AlibabaCloudSearchService.java | 42 ++-- .../AlibabaCloudSearchCompletionModel.java | 12 +- .../AlibabaCloudSearchEmbeddingsModel.java | 12 +- .../rerank/AlibabaCloudSearchRerankModel.java | 12 +- .../sparse/AlibabaCloudSearchSparseModel.java | 12 +- .../amazonbedrock/AmazonBedrockService.java | 25 +-- .../AmazonBedrockChatCompletionModel.java | 15 +- .../AmazonBedrockEmbeddingsModel.java | 12 +- .../services/anthropic/AnthropicService.java | 33 +-- .../AnthropicChatCompletionModel.java | 17 +- .../azureaistudio/AzureAiStudioService.java | 36 +--- .../AzureAiStudioChatCompletionModel.java | 15 +- .../AzureAiStudioEmbeddingsModel.java | 15 +- .../azureopenai/AzureOpenAiService.java | 36 +--- .../AzureOpenAiCompletionModel.java | 12 +- .../AzureOpenAiEmbeddingsModel.java | 12 +- .../services/cohere/CohereService.java | 47 +---- .../completion/CohereCompletionModel.java | 12 +- .../embeddings/CohereEmbeddingsModel.java | 12 +- .../cohere/rerank/CohereRerankModel.java | 12 +- .../elastic/ElasticInferenceService.java | 33 +-- ...InferenceServiceSparseEmbeddingsModel.java | 12 +- .../CustomElandEmbeddingModel.java | 6 +- .../elasticsearch/CustomElandModel.java | 11 +- .../elasticsearch/CustomElandRerankModel.java | 6 +- .../ElasticsearchInternalModel.java | 11 +- .../ElasticsearchInternalService.java | 94 +++------ .../elasticsearch/ElserInternalModel.java | 6 +- .../MultilingualE5SmallModel.java | 6 +- .../googleaistudio/GoogleAiStudioService.java | 36 +--- .../GoogleAiStudioCompletionModel.java | 17 +- .../GoogleAiStudioEmbeddingsModel.java | 22 +- .../googlevertexai/GoogleVertexAiService.java | 36 +--- .../GoogleVertexAiEmbeddingsModel.java | 17 +- .../rerank/GoogleVertexAiRerankModel.java | 17 +- .../huggingface/HuggingFaceBaseService.java | 24 +-- .../huggingface/HuggingFaceService.java | 17 +- .../elser/HuggingFaceElserModel.java | 12 +- .../elser/HuggingFaceElserService.java | 14 +- .../HuggingFaceEmbeddingsModel.java | 15 +- .../ibmwatsonx/IbmWatsonxService.java | 33 +-- .../embeddings/IbmWatsonxEmbeddingsModel.java | 17 +- .../services/mistral/MistralService.java | 28 +-- .../embeddings/MistralEmbeddingsModel.java | 20 +- .../services/openai/OpenAiService.java | 36 +--- .../completion/OpenAiChatCompletionModel.java | 12 +- .../embeddings/OpenAiEmbeddingsModel.java | 12 +- .../inference/ModelConfigurationsTests.java | 22 +- .../elasticsearch/xpack/inference/Utils.java | 7 +- .../TransportInferenceUsageActionTests.java | 19 +- .../ShardBulkInferenceActionFilterTests.java | 15 +- .../AzureOpenAiActionCreatorTests.java | 10 +- .../AzureOpenAiCompletionActionTests.java | 12 +- ...ureAiStudioChatCompletionRequestTests.java | 4 +- .../AzureOpenAiCompletionRequestTests.java | 4 +- .../xpack/inference/model/TestModel.java | 9 +- .../TextSimilarityTestPlugin.java | 5 +- .../registry/ModelRegistryTests.java | 12 +- .../services/SenderServiceTests.java | 12 +- .../AlibabaCloudSearchServiceTests.java | 5 +- ...libabaCloudSearchCompletionModelTests.java | 7 +- ...libabaCloudSearchEmbeddingsModelTests.java | 7 +- .../AlibabaCloudSearchSparseModelTests.java | 7 +- .../AmazonBedrockServiceTests.java | 50 ++--- ...AmazonBedrockChatCompletionModelTests.java | 4 +- .../AmazonBedrockEmbeddingsModelTests.java | 4 +- .../anthropic/AnthropicServiceTests.java | 38 ++-- .../AnthropicChatCompletionModelTests.java | 7 +- .../AzureAiStudioServiceTests.java | 189 +++--------------- ...AzureAiStudioChatCompletionModelTests.java | 48 ++--- .../AzureAiStudioEmbeddingsModelTests.java | 4 +- .../azureopenai/AzureOpenAiServiceTests.java | 44 ++-- .../AzureOpenAiCompletionModelTests.java | 31 +-- .../AzureOpenAiEmbeddingsModelTests.java | 7 +- .../services/cohere/CohereServiceTests.java | 55 ++--- .../CohereCompletionModelTests.java | 7 +- .../CohereEmbeddingsModelTests.java | 7 +- ...enceServiceSparseEmbeddingsModelTests.java | 4 +- .../elastic/ElasticInferenceServiceTests.java | 26 +-- .../ElasticsearchInternalServiceTests.java | 129 +++--------- .../GoogleAiStudioServiceTests.java | 63 ++---- .../GoogleAiStudioCompletionModelTests.java | 10 +- .../GoogleAiStudioEmbeddingsModelTests.java | 13 +- .../GoogleVertexAiServiceTests.java | 30 +-- .../GoogleVertexAiEmbeddingsModelTests.java | 7 +- .../GoogleVertexAiRerankModelTests.java | 7 +- .../huggingface/HuggingFaceServiceTests.java | 84 ++------ .../elser/HuggingFaceElserModelTests.java | 7 +- .../HuggingFaceEmbeddingsModelTests.java | 13 +- .../ibmwatsonx/IbmWatsonxServiceTests.java | 20 +- .../IbmWatsonxEmbeddingsModelTests.java | 10 +- .../services/mistral/MistralServiceTests.java | 49 ++--- .../MistralEmbeddingModelTests.java | 7 +- .../services/openai/OpenAiServiceTests.java | 74 ++----- .../OpenAiChatCompletionModelTests.java | 4 +- .../OpenAiEmbeddingsModelTests.java | 19 +- 115 files changed, 677 insertions(+), 2005 deletions(-) delete mode 100644 server/src/main/java/org/elasticsearch/inference/EndpointVersions.java diff --git a/server/src/main/java/org/elasticsearch/inference/EndpointVersions.java b/server/src/main/java/org/elasticsearch/inference/EndpointVersions.java deleted file mode 100644 index 9e7bd8b3b230e..0000000000000 --- a/server/src/main/java/org/elasticsearch/inference/EndpointVersions.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -package org.elasticsearch.inference; - -public enum EndpointVersions { - FIRST_ENDPOINT_VERSION("2023-09-29"), - PARAMETERS_INTRODUCED_ENDPOINT_VERSION("2024-10-17"); - - private final String name; - - EndpointVersions(String s) { - name = s; - } - - public String toString() { - return this.name; - } -} diff --git a/server/src/main/java/org/elasticsearch/inference/InferenceService.java b/server/src/main/java/org/elasticsearch/inference/InferenceService.java index 950edaa828f10..f3a2baf06c102 100644 --- a/server/src/main/java/org/elasticsearch/inference/InferenceService.java +++ b/server/src/main/java/org/elasticsearch/inference/InferenceService.java @@ -39,16 +39,9 @@ default void init(Client client) {} * @param modelId Model Id * @param taskType The model task type * @param config Configuration options including the secrets - * @param endpointVersion * @param parsedModelListener A listener which will handle the resulting model or failure */ - void parseRequestConfig( - String modelId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion, - ActionListener parsedModelListener - ); + void parseRequestConfig(String modelId, TaskType taskType, Map config, ActionListener parsedModelListener); /** * Parse model configuration from {@code config map} from persisted storage and return the parsed {@link Model}. This requires that @@ -61,16 +54,9 @@ void parseRequestConfig( * @param taskType The model task type * @param config Configuration options * @param secrets Sensitive configuration options (e.g. api key) - * @param endpointVersion * @return The parsed {@link Model} */ - Model parsePersistedConfigWithSecrets( - String modelId, - TaskType taskType, - Map config, - Map secrets, - EndpointVersions endpointVersion - ); + Model parsePersistedConfigWithSecrets(String modelId, TaskType taskType, Map config, Map secrets); /** * Parse model configuration from {@code config map} from persisted storage and return the parsed {@link Model}. @@ -81,10 +67,9 @@ Model parsePersistedConfigWithSecrets( * @param modelId Model Id * @param taskType The model task type * @param config Configuration options - * @param endpointVersion * @return The parsed {@link Model} */ - Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion); + Model parsePersistedConfig(String modelId, TaskType taskType, Map config); /** * Perform inference on the model. diff --git a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java index 467c38bd92667..d59bc1b3f79bc 100644 --- a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java +++ b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java @@ -31,8 +31,6 @@ public class ModelConfigurations implements ToFilteredXContentObject, VersionedN public static final String TASK_SETTINGS = "task_settings"; public static final String PARAMETERS = "parameters"; public static final String CHUNKING_SETTINGS = "chunking_settings"; - public static final String INCLUDE_PARAMETERS = "include_parameters"; - public static final String ENDPOINT_VERSION_FIELD_NAME = "endpoint_version"; private static final String NAME = "inference_model"; public static ModelConfigurations of(Model model, TaskSettings taskSettings) { @@ -45,8 +43,7 @@ public static ModelConfigurations of(Model model, TaskSettings taskSettings) { model.getConfigurations().getService(), model.getServiceSettings(), taskSettings, - model.getConfigurations().getChunkingSettings(), - model.getConfigurations().getEndpointVersion() + model.getConfigurations().getChunkingSettings() ); } @@ -60,8 +57,7 @@ public static ModelConfigurations of(Model model, ServiceSettings serviceSetting model.getConfigurations().getService(), serviceSettings, model.getTaskSettings(), - model.getConfigurations().getChunkingSettings(), - model.getConfigurations().getEndpointVersion() + model.getConfigurations().getChunkingSettings() ); } @@ -71,19 +67,12 @@ public static ModelConfigurations of(Model model, ServiceSettings serviceSetting private final ServiceSettings serviceSettings; private final TaskSettings taskSettings; private final ChunkingSettings chunkingSettings; - private final EndpointVersions endpointVersion; /** * Allows no task settings to be defined. This will default to the {@link EmptyTaskSettings} object. */ - public ModelConfigurations( - String inferenceEntityId, - TaskType taskType, - String service, - ServiceSettings serviceSettings, - EndpointVersions endpointVersion - ) { - this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE, endpointVersion); + public ModelConfigurations(String inferenceEntityId, TaskType taskType, String service, ServiceSettings serviceSettings) { + this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE); } public ModelConfigurations( @@ -91,10 +80,9 @@ public ModelConfigurations( TaskType taskType, String service, ServiceSettings serviceSettings, - ChunkingSettings chunkingSettings, - EndpointVersions endpointVersion + ChunkingSettings chunkingSettings ) { - this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE, chunkingSettings, endpointVersion); + this(inferenceEntityId, taskType, service, serviceSettings, EmptyTaskSettings.INSTANCE, chunkingSettings); } public ModelConfigurations( @@ -102,15 +90,13 @@ public ModelConfigurations( TaskType taskType, String service, ServiceSettings serviceSettings, - TaskSettings taskSettings, - EndpointVersions endpointVersion + TaskSettings taskSettings ) { this.inferenceEntityId = Objects.requireNonNull(inferenceEntityId); this.taskType = Objects.requireNonNull(taskType); this.service = Objects.requireNonNull(service); this.serviceSettings = Objects.requireNonNull(serviceSettings); this.taskSettings = Objects.requireNonNull(taskSettings); - this.endpointVersion = endpointVersion; this.chunkingSettings = null; } @@ -120,8 +106,7 @@ public ModelConfigurations( String service, ServiceSettings serviceSettings, TaskSettings taskSettings, - ChunkingSettings chunkingSettings, - EndpointVersions endpointVersion + ChunkingSettings chunkingSettings ) { this.inferenceEntityId = Objects.requireNonNull(inferenceEntityId); this.taskType = Objects.requireNonNull(taskType); @@ -129,7 +114,6 @@ public ModelConfigurations( this.serviceSettings = Objects.requireNonNull(serviceSettings); this.taskSettings = Objects.requireNonNull(taskSettings); this.chunkingSettings = chunkingSettings; - this.endpointVersion = endpointVersion; } public ModelConfigurations(StreamInput in) throws IOException { @@ -141,9 +125,6 @@ public ModelConfigurations(StreamInput in) throws IOException { this.chunkingSettings = in.getTransportVersion().onOrAfter(TransportVersions.ML_INFERENCE_CHUNKING_SETTINGS) ? in.readOptionalNamedWriteable(ChunkingSettings.class) : null; - this.endpointVersion = in.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_API_PARAMATERS_INTRODUCED) - ? Objects.requireNonNullElse(in.readEnum(EndpointVersions.class), EndpointVersions.FIRST_ENDPOINT_VERSION) - : EndpointVersions.FIRST_ENDPOINT_VERSION; } @Override @@ -156,9 +137,6 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().onOrAfter(TransportVersions.ML_INFERENCE_CHUNKING_SETTINGS)) { out.writeOptionalNamedWriteable(chunkingSettings); } - if (out.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_API_PARAMATERS_INTRODUCED)) { - out.writeEnum(endpointVersion); // not nullable after 9.0 - } } public String getInferenceEntityId() { @@ -185,10 +163,6 @@ public ChunkingSettings getChunkingSettings() { return chunkingSettings; } - public EndpointVersions getEndpointVersion() { - return endpointVersion; - } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); @@ -204,11 +178,10 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } - if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters - builder.field(PARAMETERS, taskSettings); - } if (params.paramAsBoolean(FOR_INDEX, false)) { - builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); // only write endpoint version for index, not for REST + // Don't write parameter to index, but do write parameters the rest of the time + } else { + builder.field(PARAMETERS, taskSettings); } builder.endObject(); return builder; @@ -229,11 +202,10 @@ public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } - if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters - builder.field(PARAMETERS, taskSettings); - } if (params.paramAsBoolean(FOR_INDEX, false)) { - builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); + // Don't write parameter to index, but do write parameters the rest of the time + } else { + builder.field(PARAMETERS, taskSettings); } builder.endObject(); return builder; @@ -258,12 +230,11 @@ public boolean equals(Object o) { && taskType == model.taskType && Objects.equals(service, model.service) && Objects.equals(serviceSettings, model.serviceSettings) - && Objects.equals(taskSettings, model.taskSettings) - && Objects.equals(endpointVersion, model.endpointVersion); + && Objects.equals(taskSettings, model.taskSettings); } @Override public int hashCode() { - return Objects.hash(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); + return Objects.hash(inferenceEntityId, taskType, service, serviceSettings, taskSettings); } } diff --git a/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java b/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java index a6011bcb26cd1..30a7c6aa2bf9c 100644 --- a/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java +++ b/server/src/main/java/org/elasticsearch/inference/UnparsedModel.java @@ -20,6 +20,5 @@ public record UnparsedModel( TaskType taskType, String service, Map settings, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) {} 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 65bbae57094c1..11bdd3669fd7b 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 @@ -16,7 +16,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentHelper; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.rest.RestStatus; @@ -31,7 +30,6 @@ import java.util.Map; import java.util.Objects; -import static org.elasticsearch.inference.ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME; import static org.elasticsearch.inference.ModelConfigurations.TASK_SETTINGS; import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; @@ -90,13 +88,9 @@ public BytesReference getRewrittenContent() { ); } else if (newContent.containsKey(PARAMETERS)) { newContent.put(TASK_SETTINGS, newContent.get(PARAMETERS)); - newContent.put(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.PARAMETERS_INTRODUCED_ENDPOINT_VERSION); newContent.remove(PARAMETERS); - } else if (newContent.containsKey(TASK_SETTINGS)) { - newContent.put(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.FIRST_ENDPOINT_VERSION); - } else { - newContent.put(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.FIRST_ENDPOINT_VERSION); } + try (XContentBuilder builder = XContentFactory.contentBuilder(this.contentType)) { builder.map(newContent); this.rewrittenContent = BytesReference.bytes(builder); 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 85df139c15051..f0ef45beeb344 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 @@ -12,7 +12,6 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.XContentHelper; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xcontent.XContentBuilder; @@ -25,7 +24,6 @@ import java.util.Locale; import java.util.Map; -import static org.elasticsearch.inference.ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME; import static org.elasticsearch.inference.ModelConfigurations.TASK_SETTINGS; import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; @@ -117,6 +115,5 @@ public void testWithTaskSettings() throws IOException { assertNull(map.get(PARAMETERS)); assertEquals("elasticsearch", map.get("service")); assertEquals(serviceSettingsValues, map.get("service_settings")); - assertEquals(ENDPOINT_VERSION_FIELD_NAME, EndpointVersions.FIRST_ENDPOINT_VERSION); } } diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java index a902fc94a8320..1bde3704864d5 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java @@ -12,7 +12,6 @@ import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; @@ -60,8 +59,7 @@ public TestServiceModel parsePersistedConfigWithSecrets( String modelId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); var secretSettingsMap = (Map) secrets.remove(ModelSecrets.SECRET_SETTINGS); @@ -72,12 +70,12 @@ public TestServiceModel parsePersistedConfigWithSecrets( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - return new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion); + return new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings); } @Override @SuppressWarnings("unchecked") - public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion) { + public Model parsePersistedConfig(String modelId, TaskType taskType, Map config) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); var serviceSettings = getServiceSettingsFromMap(serviceSettingsMap); @@ -85,7 +83,7 @@ public Model parsePersistedConfig(String modelId, TaskType taskType, Map serviceSettingsMap); @@ -106,13 +104,9 @@ public TestServiceModel( String service, ServiceSettings serviceSettings, TestTaskSettings taskSettings, - TestSecretSettings secretSettings, - EndpointVersions endpointVersion + TestSecretSettings secretSettings ) { - super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), - new ModelSecrets(secretSettings) - ); + super(new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings)); } @Override 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 ca582ca06fd8b..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 @@ -18,7 +18,6 @@ import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -47,14 +46,13 @@ public List getInferenceServiceFactories() { } public static class TestDenseModel extends Model { - public TestDenseModel(String inferenceEntityId, TestServiceSettings serviceSettings, EndpointVersions endpointVersion) { + public TestDenseModel(String inferenceEntityId, TestServiceSettings serviceSettings) { super( new ModelConfigurations( inferenceEntityId, TaskType.TEXT_EMBEDDING, TestDenseInferenceServiceExtension.TestInferenceService.NAME, - serviceSettings, - endpointVersion + serviceSettings ), new ModelSecrets(new AbstractTestInferenceService.TestSecretSettings("api_key")) ); @@ -77,7 +75,6 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); @@ -87,9 +84,7 @@ public void parseRequestConfig( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - parsedModelListener.onResponse( - new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion) - ); + parsedModelListener.onResponse(new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings)); } @Override diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java index f7482779c7fd0..d8ee70986a57d 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java @@ -17,7 +17,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -43,9 +42,9 @@ public List getInferenceServiceFactories() { } public static class TestRerankingModel extends Model { - public TestRerankingModel(String inferenceEntityId, TestServiceSettings serviceSettings, EndpointVersions endpointVersion) { + public TestRerankingModel(String inferenceEntityId, TestServiceSettings serviceSettings) { super( - new ModelConfigurations(inferenceEntityId, TaskType.RERANK, TestInferenceService.NAME, serviceSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, TaskType.RERANK, TestInferenceService.NAME, serviceSettings), new ModelSecrets(new AbstractTestInferenceService.TestSecretSettings("api_key")) ); } @@ -67,7 +66,6 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); @@ -77,9 +75,7 @@ public void parseRequestConfig( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - parsedModelListener.onResponse( - new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion) - ); + parsedModelListener.onResponse(new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings)); } @Override diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java index 9939fb409665b..6eb0caad36261 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java @@ -17,7 +17,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -46,15 +45,9 @@ public List getInferenceServiceFactories() { } public static class TestSparseModel extends Model { - public TestSparseModel(String inferenceEntityId, TestServiceSettings serviceSettings, EndpointVersions endpointVersion) { + public TestSparseModel(String inferenceEntityId, TestServiceSettings serviceSettings) { super( - new ModelConfigurations( - inferenceEntityId, - TaskType.SPARSE_EMBEDDING, - TestInferenceService.NAME, - serviceSettings, - endpointVersion - ), + new ModelConfigurations(inferenceEntityId, TaskType.SPARSE_EMBEDDING, TestInferenceService.NAME, serviceSettings), new ModelSecrets(new AbstractTestInferenceService.TestSecretSettings("api_key")) ); } @@ -76,7 +69,6 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); @@ -86,9 +78,7 @@ public void parseRequestConfig( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - parsedModelListener.onResponse( - new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion) - ); + parsedModelListener.onResponse(new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings)); } @Override diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java index d99932d95c352..206aa1f3e5d28 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestStreamingCompletionServiceExtension.java @@ -19,7 +19,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -68,7 +67,6 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { var serviceSettingsMap = (Map) config.remove(ModelConfigurations.SERVICE_SETTINGS); @@ -78,9 +76,7 @@ public void parseRequestConfig( var taskSettingsMap = getTaskSettingsMap(config); var taskSettings = TestTaskSettings.fromMap(taskSettingsMap); - parsedModelListener.onResponse( - new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings, endpointVersion) - ); + parsedModelListener.onResponse(new TestServiceModel(modelId, taskType, name(), serviceSettings, taskSettings, secretSettings)); } @Override 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 f984bc35daefd..3c1323f3141bf 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 @@ -12,7 +12,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; @@ -127,8 +126,7 @@ public void testGetModel() throws Exception { modelHolder.get().inferenceEntityId(), modelHolder.get().taskType(), modelHolder.get().settings(), - modelHolder.get().secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + modelHolder.get().secrets() ); assertEquals(model, roundTripModel); } @@ -183,21 +181,11 @@ public void testDeleteModel() throws Exception { public void testGetModelsByTaskType() throws InterruptedException { var service = "foo"; var sparseAndTextEmbeddingModels = new ArrayList(); - sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) - ); - sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) - ); - sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) - ); - sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) - ); - sparseAndTextEmbeddingModels.add( - createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION) - ); + sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service)); + sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service)); + sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.SPARSE_EMBEDDING, service)); + sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service)); + sparseAndTextEmbeddingModels.add(createModel(randomAlphaOfLength(5), TaskType.TEXT_EMBEDDING, service)); for (var model : sparseAndTextEmbeddingModels) { AtomicReference putModelHolder = new AtomicReference<>(); @@ -241,12 +229,7 @@ public void testGetAllModels() throws InterruptedException { AtomicReference exceptionHolder = new AtomicReference<>(); for (int i = 0; i < modelCount; i++) { - var model = createModel( - randomAlphaOfLength(5), - randomFrom(TaskType.values()), - service, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = createModel(randomAlphaOfLength(5), randomFrom(TaskType.values()), service); createdModels.add(model); blockingCall(listener -> modelRegistry.storeModel(model, listener), putModelHolder, exceptionHolder); @@ -279,13 +262,7 @@ public void testGetModelWithSecrets() throws InterruptedException { AtomicReference putModelHolder = new AtomicReference<>(); AtomicReference exceptionHolder = new AtomicReference<>(); - var modelWithSecrets = createModelWithSecrets( - inferenceEntityId, - randomFrom(TaskType.values()), - service, - secret, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var modelWithSecrets = createModelWithSecrets(inferenceEntityId, randomFrom(TaskType.values()), service, secret); blockingCall(listener -> modelRegistry.storeModel(modelWithSecrets, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); assertNull(exceptionHolder.get()); @@ -313,10 +290,7 @@ public void testGetAllModels_WithDefaults() throws Exception { var defaultConfigs = new HashMap(); for (int i = 0; i < defaultModelCount; i++) { var id = "default-" + i; - defaultConfigs.put( - id, - createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret, EndpointVersions.FIRST_ENDPOINT_VERSION) - ); + defaultConfigs.put(id, createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret)); } defaultConfigs.values().forEach(modelRegistry::addDefaultConfiguration); @@ -326,7 +300,7 @@ public void testGetAllModels_WithDefaults() throws Exception { var createdModels = new HashMap(); for (int i = 0; i < configuredModelCount; i++) { var id = randomAlphaOfLength(5) + i; - var model = createModel(id, randomFrom(TaskType.values()), service, EndpointVersions.FIRST_ENDPOINT_VERSION); + var model = createModel(id, randomFrom(TaskType.values()), service); createdModels.put(id, model); blockingCall(listener -> modelRegistry.storeModel(model, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); @@ -365,10 +339,7 @@ public void testGetAllModels_OnlyDefaults() throws Exception { var defaultConfigs = new HashMap(); for (int i = 0; i < defaultModelCount; i++) { var id = "default-" + i; - defaultConfigs.put( - id, - createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret, EndpointVersions.FIRST_ENDPOINT_VERSION) - ); + defaultConfigs.put(id, createUnparsedConfig(id, randomFrom(TaskType.values()), service, secret)); } defaultConfigs.values().forEach(modelRegistry::addDefaultConfiguration); @@ -395,20 +366,8 @@ public void testGet_WithDefaults() throws InterruptedException { var service = "foo"; var secret = "abc"; - var defaultSparse = createUnparsedConfig( - "default-sparse", - TaskType.SPARSE_EMBEDDING, - service, - secret, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); - var defaultText = createUnparsedConfig( - "default-text", - TaskType.TEXT_EMBEDDING, - service, - secret, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var defaultSparse = createUnparsedConfig("default-sparse", TaskType.SPARSE_EMBEDDING, service, secret); + var defaultText = createUnparsedConfig("default-text", TaskType.TEXT_EMBEDDING, service, secret); modelRegistry.addDefaultConfiguration(defaultSparse); modelRegistry.addDefaultConfiguration(defaultText); @@ -416,18 +375,8 @@ public void testGet_WithDefaults() throws InterruptedException { AtomicReference putModelHolder = new AtomicReference<>(); AtomicReference exceptionHolder = new AtomicReference<>(); - var configured1 = createModel( - randomAlphaOfLength(5) + 1, - randomFrom(TaskType.values()), - service, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); - var configured2 = createModel( - randomAlphaOfLength(5) + 1, - randomFrom(TaskType.values()), - service, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var configured1 = createModel(randomAlphaOfLength(5) + 1, randomFrom(TaskType.values()), service); + var configured2 = createModel(randomAlphaOfLength(5) + 1, randomFrom(TaskType.values()), service); blockingCall(listener -> modelRegistry.storeModel(configured1, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); blockingCall(listener -> modelRegistry.storeModel(configured2, listener), putModelHolder, exceptionHolder); @@ -453,27 +402,9 @@ public void testGetByTaskType_WithDefaults() throws Exception { var service = "foo"; var secret = "abc"; - var defaultSparse = createUnparsedConfig( - "default-sparse", - TaskType.SPARSE_EMBEDDING, - service, - secret, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); - var defaultText = createUnparsedConfig( - "default-text", - TaskType.TEXT_EMBEDDING, - service, - secret, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); - var defaultChat = createUnparsedConfig( - "default-chat", - TaskType.COMPLETION, - service, - secret, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var defaultSparse = createUnparsedConfig("default-sparse", TaskType.SPARSE_EMBEDDING, service, secret); + var defaultText = createUnparsedConfig("default-text", TaskType.TEXT_EMBEDDING, service, secret); + var defaultChat = createUnparsedConfig("default-chat", TaskType.COMPLETION, service, secret); modelRegistry.addDefaultConfiguration(defaultSparse); modelRegistry.addDefaultConfiguration(defaultText); @@ -482,14 +413,9 @@ public void testGetByTaskType_WithDefaults() throws Exception { AtomicReference putModelHolder = new AtomicReference<>(); AtomicReference exceptionHolder = new AtomicReference<>(); - var configuredSparse = createModel( - "configured-sparse", - TaskType.SPARSE_EMBEDDING, - service, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); - var configuredText = createModel("configured-text", TaskType.TEXT_EMBEDDING, service, EndpointVersions.FIRST_ENDPOINT_VERSION); - var configuredRerank = createModel("configured-rerank", TaskType.RERANK, service, EndpointVersions.FIRST_ENDPOINT_VERSION); + var configuredSparse = createModel("configured-sparse", TaskType.SPARSE_EMBEDDING, service); + var configuredText = createModel("configured-text", TaskType.TEXT_EMBEDDING, service); + var configuredRerank = createModel("configured-rerank", TaskType.RERANK, service); blockingCall(listener -> modelRegistry.storeModel(configuredSparse, listener), putModelHolder, exceptionHolder); assertThat(putModelHolder.get(), is(true)); blockingCall(listener -> modelRegistry.storeModel(configuredText, listener), putModelHolder, exceptionHolder); @@ -557,8 +483,7 @@ private Model buildElserModelConfig(String inferenceEntityId, TaskType taskType) taskType, ElasticsearchInternalService.NAME, ElserInternalServiceSettingsTests.createRandom(), - ElserMlNodeTaskSettingsTests.createRandom(), - EndpointVersions.FIRST_ENDPOINT_VERSION + ElserMlNodeTaskSettingsTests.createRandom() ); default -> throw new IllegalArgumentException("task type " + taskType + " is not supported"); }; @@ -587,58 +512,24 @@ private static Model buildModelWithUnknownField(String inferenceEntityId) { TaskType.SPARSE_EMBEDDING, ElasticsearchInternalService.NAME, ElserInternalServiceSettingsTests.createRandom(), - ElserMlNodeTaskSettingsTests.createRandom(), - EndpointVersions.FIRST_ENDPOINT_VERSION + ElserMlNodeTaskSettingsTests.createRandom() ) ); } - public static Model createModel(String inferenceEntityId, TaskType taskType, String service, EndpointVersions endpointVersion) { - return new Model( - new ModelConfigurations( - inferenceEntityId, - taskType, - service, - new TestModelOfAnyKind.TestModelServiceSettings(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ) - ); + public static Model createModel(String inferenceEntityId, TaskType taskType, String services) { + return new Model(new ModelConfigurations(inferenceEntityId, taskType, service, new TestModelOfAnyKind.TestModelServiceSettings())); } - public static Model createModelWithSecrets( - String inferenceEntityId, - TaskType taskType, - String service, - String secret, - EndpointVersions endpointVersion - ) { + public static Model createModelWithSecrets(String inferenceEntityId, TaskType taskType, String service, String secret) { return new Model( - new ModelConfigurations( - inferenceEntityId, - taskType, - service, - new TestModelOfAnyKind.TestModelServiceSettings(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ), + new ModelConfigurations(inferenceEntityId, taskType, service, new TestModelOfAnyKind.TestModelServiceSettings()), new ModelSecrets(new TestModelOfAnyKind.TestSecretSettings(secret)) ); } - public static UnparsedModel createUnparsedConfig( - String inferenceEntityId, - TaskType taskType, - String service, - String secret, - EndpointVersions endpointVersion - ) { - return new UnparsedModel( - inferenceEntityId, - taskType, - service, - Map.of("a", "b"), - Map.of("secret", secret), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + public static UnparsedModel createUnparsedConfig(String inferenceEntityId, TaskType taskType, String service, String secret) { + return new UnparsedModel(inferenceEntityId, taskType, service, Map.of("a", "b"), Map.of("secret", secret)); } private static class TestModelOfAnyKind extends ModelConfigurations { @@ -728,8 +619,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws } } - TestModelOfAnyKind(String inferenceEntityId, TaskType taskType, String service, EndpointVersions endpointVersion) { - super(inferenceEntityId, taskType, service, new TestModelServiceSettings(), new TestTaskSettings(), endpointVersion); + TestModelOfAnyKind(String inferenceEntityId, TaskType taskType, String services) { + super(inferenceEntityId, taskType, service, new TestModelServiceSettings(), new TestTaskSettings()); } @Override @@ -753,10 +644,9 @@ private static class ModelWithUnknownField extends ModelConfigurations { TaskType taskType, String service, ServiceSettings serviceSettings, - TaskSettings taskSettings, - EndpointVersions endpointVersion + TaskSettings taskSettingss ) { - super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); + super(inferenceEntityId, taskType, service, serviceSettings, taskSettings); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java index 44c2d8f42a8fd..1c93494d78636 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceIndex.java @@ -27,7 +27,7 @@ private InferenceIndex() {} public static final String INDEX_ALIAS = ".inference-alias"; // Increment this version number when the mappings change - private static final int INDEX_MAPPING_VERSION = 3; + private static final int INDEX_MAPPING_VERSION = 2; public static Settings settings() { return Settings.builder() @@ -58,64 +58,6 @@ public static Settings settings() { * @return The index mappings */ public static XContentBuilder mappings() { - try { - var jsonBuilder = jsonBuilder().startObject().startObject(SINGLE_MAPPING_NAME); - { - jsonBuilder.startObject("_meta").field(SystemIndexDescriptor.VERSION_META_KEY, INDEX_MAPPING_VERSION).endObject(); - - jsonBuilder.field("dynamic", "strict"); - - jsonBuilder.startObject("properties"); - { - jsonBuilder.startObject("model_id").field("type", "keyword").endObject(); - - jsonBuilder.startObject("task_type").field("type", "keyword").endObject(); - - jsonBuilder.startObject("service").field("type", "keyword").endObject(); - - jsonBuilder.startObject("service_settings").field("dynamic", "false"); - { - jsonBuilder.startObject("properties").endObject(); - } - jsonBuilder.endObject(); - - jsonBuilder.startObject("task_settings").field("dynamic", "false"); - { - jsonBuilder.startObject("properties").endObject(); - } - jsonBuilder.endObject(); - - jsonBuilder.startObject("chunking_settings"); - { - jsonBuilder.field("dynamic", "false"); - jsonBuilder.startObject("properties"); - { - jsonBuilder.startObject("strategy").field("type", "keyword").endObject(); - } - jsonBuilder.endObject(); - } - jsonBuilder.endObject(); - - jsonBuilder.startObject("endpoint_version").field("dynamic", "false"); - { - jsonBuilder.startObject("properties"); - { - jsonBuilder.field("type", "keyword"); - } - jsonBuilder.endObject(); - } - jsonBuilder.endObject(); - } - jsonBuilder.endObject().endObject().endObject(); - } - - return jsonBuilder; - } catch (IOException e) { - throw new UncheckedIOException("Failed to build mappings for index " + INDEX_NAME, e); - } - } - - public static XContentBuilder mappingsV2() { try { return jsonBuilder().startObject() .startObject(SINGLE_MAPPING_NAME) diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java index 6e68d2c5a89e9..dbb9130ab91e1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java @@ -259,18 +259,6 @@ public List getNamedWriteables() { @Override public Collection getSystemIndexDescriptors(Settings settings) { - var inferenceIndexV2Descriptor = SystemIndexDescriptor.builder() - .setType(SystemIndexDescriptor.Type.INTERNAL_MANAGED) - .setIndexPattern(InferenceIndex.INDEX_PATTERN) - .setAliasName(InferenceIndex.INDEX_ALIAS) - .setPrimaryIndex(InferenceIndex.INDEX_NAME) - .setDescription("Contains inference service and model configuration") - .setMappings(InferenceIndex.mappingsV2()) - .setSettings(InferenceIndex.settings()) - .setVersionMetaKey("version") - .setOrigin(ClientHelper.INFERENCE_ORIGIN) - .build(); - var inferenceIndexV1Descriptor = SystemIndexDescriptor.builder() .setType(SystemIndexDescriptor.Type.INTERNAL_MANAGED) .setIndexPattern(InferenceIndex.INDEX_PATTERN) @@ -294,7 +282,7 @@ public Collection getSystemIndexDescriptors(Settings sett .setSettings(InferenceIndex.settings()) .setVersionMetaKey("version") .setOrigin(ClientHelper.INFERENCE_ORIGIN) - .setPriorSystemIndexDescriptors(List.of(inferenceIndexV1Descriptor, inferenceIndexV2Descriptor)) + .setPriorSystemIndexDescriptors(List.of(inferenceIndexV1Descriptor)) .build(), SystemIndexDescriptor.builder() .setType(SystemIndexDescriptor.Type.INTERNAL_MANAGED) diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java index 1a3447ba86305..5ee1e40869dbc 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java @@ -95,12 +95,7 @@ private void getSingleModel( } var model = service.get() - .parsePersistedConfig( - unparsedModel.inferenceEntityId(), - unparsedModel.taskType(), - unparsedModel.settings(), - unparsedModel.endpointVersion() - ); + .parsePersistedConfig(unparsedModel.inferenceEntityId(), unparsedModel.taskType(), unparsedModel.settings()); delegate.onResponse(new GetInferenceModelAction.Response(List.of(model.getConfigurations()))); })); } @@ -128,12 +123,7 @@ private GetInferenceModelAction.Response parseModels(List unparse } parsedModels.add( service.get() - .parsePersistedConfig( - unparsedModel.inferenceEntityId(), - unparsedModel.taskType(), - unparsedModel.settings(), - unparsedModel.endpointVersion() - ) + .parsePersistedConfig(unparsedModel.inferenceEntityId(), unparsedModel.taskType(), unparsedModel.settings()) .getConfigurations() ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceAction.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceAction.java index b50e3fbbaf638..e046e2aad463b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceAction.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceAction.java @@ -81,8 +81,7 @@ protected void doExecute(Task task, InferenceAction.Request request, ActionListe unparsedModel.inferenceEntityId(), unparsedModel.taskType(), unparsedModel.settings(), - unparsedModel.secrets(), - unparsedModel.endpointVersion() + unparsedModel.secrets() ); inferOnService(model, request, service.get(), delegate); }); 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 59436bbe0483c..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 @@ -23,7 +23,6 @@ import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.index.mapper.StrictDynamicMappingException; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.InferenceServiceRegistry; import org.elasticsearch.inference.Model; @@ -204,9 +203,7 @@ private void parseAndStoreModel( } }); - EndpointVersions endpointVersion = (EndpointVersions) config.remove(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME); - - service.parseRequestConfig(inferenceEntityId, taskType, config, endpointVersion, parsedModelListener); + service.parseRequestConfig(inferenceEntityId, taskType, config, parsedModelListener); } private void startInferenceEndpoint(InferenceService service, Model model, ActionListener listener) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java index bb42bf59252d3..a4eb94c2674d1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java @@ -224,8 +224,7 @@ public void onResponse(UnparsedModel unparsedModel) { inferenceId, unparsedModel.taskType(), unparsedModel.settings(), - unparsedModel.secrets(), - unparsedModel.endpointVersion() + unparsedModel.secrets() ) ); executeShardBulkInferenceAsync(inferenceId, provider, requests, onFinish); 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 03084c53f108a..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 @@ -29,7 +29,6 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.reindex.DeleteByQueryAction; import org.elasticsearch.index.reindex.DeleteByQueryRequest; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; @@ -54,7 +53,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; @@ -74,13 +72,8 @@ public static UnparsedModel unparsedModelFromMap(ModelConfigMap modelConfigMap) String service = ServiceUtils.removeStringOrThrowIfNull(modelConfigMap.config(), ModelConfigurations.SERVICE); String taskTypeStr = ServiceUtils.removeStringOrThrowIfNull(modelConfigMap.config(), TaskType.NAME); TaskType taskType = TaskType.fromString(taskTypeStr); - EndpointVersions endpointVersion = (EndpointVersions) Objects.requireNonNullElse( - modelConfigMap.config().remove(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME), - EndpointVersions.FIRST_ENDPOINT_VERSION // TODO in 9.0 change this to require the field, once we have updated all of the - // stored models - ); - return new UnparsedModel(inferenceEntityId, taskType, service, modelConfigMap.config(), modelConfigMap.secrets(), endpointVersion); + return new UnparsedModel(inferenceEntityId, taskType, service, modelConfigMap.config(), modelConfigMap.secrets()); } private static final String TASK_TYPE_FIELD = "task_type"; @@ -425,14 +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.FOR_INDEX, - Boolean.TRUE.toString(), - ModelConfigurations.INCLUDE_PARAMETERS, // we are going to continue to write the parameters field as `task_settings` - Boolean.FALSE.toString() - ) - ) + new ToXContent.MapParams(Map.of(ModelConfigurations.FOR_INDEX, Boolean.TRUE.toString())) ); var operation = allowOverwriting ? DocWriteRequest.OpType.INDEX : DocWriteRequest.OpType.CREATE; @@ -453,8 +439,7 @@ static UnparsedModel deepCopyDefaultConfig(UnparsedModel other) { other.taskType(), other.service(), copySettingsMap(other.settings()), - copySecretsMap(other.secrets()), - other.endpointVersion() + copySecretsMap(other.secrets()) ); } @@ -480,11 +465,6 @@ static Map copySettingsMap(Map other) { result.put(ModelConfigurations.CHUNKING_SETTINGS, copiedChunkSettings); } - var endpointVersion = (String) other.get(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME); - if (endpointVersion != null) { - result.put(ModelConfigurations.ENDPOINT_VERSION_FIELD_NAME, endpointVersion); - } - return result; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java index 775af606c8e3d..0bd0eee1aa9a1 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java @@ -15,7 +15,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -69,7 +68,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -83,8 +81,7 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -103,8 +100,7 @@ private static AlibabaCloudSearchModel createModelWithoutLoggingDeprecations( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -113,8 +109,7 @@ private static AlibabaCloudSearchModel createModelWithoutLoggingDeprecations( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @@ -125,8 +120,7 @@ private static AlibabaCloudSearchModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { case TEXT_EMBEDDING -> new AlibabaCloudSearchEmbeddingsModel( @@ -136,8 +130,7 @@ private static AlibabaCloudSearchModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); case SPARSE_EMBEDDING -> new AlibabaCloudSearchSparseModel( inferenceEntityId, @@ -146,8 +139,7 @@ private static AlibabaCloudSearchModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); case RERANK -> new AlibabaCloudSearchRerankModel( inferenceEntityId, @@ -156,8 +148,7 @@ private static AlibabaCloudSearchModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); case COMPLETION -> new AlibabaCloudSearchCompletionModel( inferenceEntityId, @@ -166,8 +157,7 @@ private static AlibabaCloudSearchModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -178,8 +168,7 @@ public AlibabaCloudSearchModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -191,18 +180,12 @@ public AlibabaCloudSearchModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @Override - public AlibabaCloudSearchModel parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public AlibabaCloudSearchModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -212,8 +195,7 @@ public AlibabaCloudSearchModel parsePersistedConfig( serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java index 3dd53e4a80a91..f5140981bfbe0 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.completion; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -37,8 +36,7 @@ public AlibabaCloudSearchCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( modelId, @@ -46,8 +44,7 @@ public AlibabaCloudSearchCompletionModel( service, AlibabaCloudSearchCompletionServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchCompletionTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -58,11 +55,10 @@ public AlibabaCloudSearchCompletionModel( String service, AlibabaCloudSearchCompletionServiceSettings serviceSettings, AlibabaCloudSearchCompletionTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java index d3f80fbe479fe..87e5e59ae3434 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -41,8 +40,7 @@ public AlibabaCloudSearchEmbeddingsModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( modelId, @@ -50,8 +48,7 @@ public AlibabaCloudSearchEmbeddingsModel( service, AlibabaCloudSearchEmbeddingsServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchEmbeddingsTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -62,11 +59,10 @@ public AlibabaCloudSearchEmbeddingsModel( String service, AlibabaCloudSearchEmbeddingsServiceSettings serviceSettings, AlibabaCloudSearchEmbeddingsTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java index 6a7ef1afece6d..a9152b6edd4c5 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.rerank; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -37,8 +36,7 @@ public AlibabaCloudSearchRerankModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( modelId, @@ -46,8 +44,7 @@ public AlibabaCloudSearchRerankModel( service, AlibabaCloudSearchRerankServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchRerankTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -58,11 +55,10 @@ public AlibabaCloudSearchRerankModel( String service, AlibabaCloudSearchRerankServiceSettings serviceSettings, AlibabaCloudSearchRerankTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java index aa8f322461f6f..b551ba389136b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.sparse; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -41,8 +40,7 @@ public AlibabaCloudSearchSparseModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( modelId, @@ -50,8 +48,7 @@ public AlibabaCloudSearchSparseModel( service, AlibabaCloudSearchSparseServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchSparseTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -62,11 +59,10 @@ public AlibabaCloudSearchSparseModel( String service, AlibabaCloudSearchSparseServiceSettings serviceSettings, AlibabaCloudSearchSparseTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java index 8d8ba4449af9d..bc0d10279ae44 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java @@ -16,7 +16,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -121,7 +120,6 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -135,8 +133,7 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -154,8 +151,7 @@ public Model parsePersistedConfigWithSecrets( String modelId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -168,13 +164,12 @@ public Model parsePersistedConfigWithSecrets( taskSettingsMap, secretSettingsMap, parsePersistedConfigErrorMsg(modelId, NAME), - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @Override - public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion) { + public Model parsePersistedConfig(String modelId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); @@ -185,8 +180,7 @@ public Model parsePersistedConfig(String modelId, TaskType taskType, Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { switch (taskType) { case TEXT_EMBEDDING -> { @@ -209,8 +202,7 @@ private static AmazonBedrockModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); checkProviderForTask(TaskType.TEXT_EMBEDDING, model.provider()); return model; @@ -223,8 +215,7 @@ private static AmazonBedrockModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); checkProviderForTask(TaskType.COMPLETION, model.provider()); checkChatCompletionProviderForTopKParameter(model); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java index 1172f7a498695..27dc607d671aa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModel.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.inference.services.amazonbedrock.completion; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -40,8 +39,7 @@ public AmazonBedrockChatCompletionModel( Map serviceSettings, Map taskSettings, Map secretSettings, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -49,8 +47,7 @@ public AmazonBedrockChatCompletionModel( name, AmazonBedrockChatCompletionServiceSettings.fromMap(serviceSettings, context), AmazonBedrockChatCompletionTaskSettings.fromMap(taskSettings), - AmazonBedrockSecretSettings.fromMap(secretSettings), - endpointVersion + AmazonBedrockSecretSettings.fromMap(secretSettings) ); } @@ -60,13 +57,9 @@ public AmazonBedrockChatCompletionModel( String service, AmazonBedrockChatCompletionServiceSettings serviceSettings, AmazonBedrockChatCompletionTaskSettings taskSettings, - AmazonBedrockSecretSettings secrets, - EndpointVersions endpointVersion + AmazonBedrockSecretSettings secrets ) { - super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), - new ModelSecrets(secrets) - ); + super(new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets)); } public AmazonBedrockChatCompletionModel(Model model, TaskSettings taskSettings) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java index 7f6c61130d298..0e3a954a03279 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModel.java @@ -9,7 +9,6 @@ import org.elasticsearch.common.ValidationException; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -44,8 +43,7 @@ public AmazonBedrockEmbeddingsModel( Map serviceSettings, Map taskSettings, Map secretSettings, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -53,8 +51,7 @@ public AmazonBedrockEmbeddingsModel( service, AmazonBedrockEmbeddingsServiceSettings.fromMap(serviceSettings, context), new EmptyTaskSettings(), - AmazonBedrockSecretSettings.fromMap(secretSettings), - endpointVersion + AmazonBedrockSecretSettings.fromMap(secretSettings) ); } @@ -64,11 +61,10 @@ public AmazonBedrockEmbeddingsModel( String service, AmazonBedrockEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, - AmazonBedrockSecretSettings secrets, - EndpointVersions endpointVersion + AmazonBedrockSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, new EmptyTaskSettings(), endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, new EmptyTaskSettings()), new ModelSecrets(secrets) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java index 83e9a41bdb604..07c45e7c6e710 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java @@ -15,7 +15,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -58,7 +57,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -72,8 +70,7 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -92,8 +89,7 @@ private static AnthropicModel createModelFromPersistent( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -102,8 +98,7 @@ private static AnthropicModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @@ -114,8 +109,7 @@ private static AnthropicModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { case COMPLETION -> new AnthropicChatCompletionModel( @@ -125,8 +119,7 @@ private static AnthropicModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -137,8 +130,7 @@ public AnthropicModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -150,18 +142,12 @@ public AnthropicModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @Override - public AnthropicModel parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public AnthropicModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); @@ -171,8 +157,7 @@ public AnthropicModel parsePersistedConfig( serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java index 35636ed325984..942cae8960daf 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionModel.java @@ -9,7 +9,6 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -46,8 +45,7 @@ public AnthropicChatCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -55,8 +53,7 @@ public AnthropicChatCompletionModel( service, AnthropicChatCompletionServiceSettings.fromMap(serviceSettings, context), AnthropicChatCompletionTaskSettings.fromMap(taskSettings, context), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -66,11 +63,10 @@ public AnthropicChatCompletionModel( String service, AnthropicChatCompletionServiceSettings serviceSettings, AnthropicChatCompletionTaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings, AnthropicChatCompletionModel::buildDefaultUri, @@ -86,11 +82,10 @@ public AnthropicChatCompletionModel( String url, AnthropicChatCompletionServiceSettings serviceSettings, AnthropicChatCompletionTaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings, () -> ServiceUtils.createUri(url), diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java index 5a39ab0ce4ae4..7981fb393a842 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java @@ -16,7 +16,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -110,7 +109,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -124,8 +122,7 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -143,8 +140,7 @@ public AzureAiStudioModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); @@ -156,18 +152,12 @@ public AzureAiStudioModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @Override - public Model parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); @@ -177,8 +167,7 @@ public Model parsePersistedConfig( serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @@ -199,8 +188,7 @@ private static AzureAiStudioModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { if (taskType == TaskType.TEXT_EMBEDDING) { @@ -211,8 +199,7 @@ private static AzureAiStudioModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); checkProviderAndEndpointTypeForTask( TaskType.TEXT_EMBEDDING, @@ -230,8 +217,7 @@ private static AzureAiStudioModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); checkProviderAndEndpointTypeForTask( TaskType.COMPLETION, @@ -250,8 +236,7 @@ private AzureAiStudioModel createModelFromPersistent( Map serviceSettings, Map taskSettings, Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -260,8 +245,7 @@ private AzureAiStudioModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java index 5a547a3cf70e9..5afb3aaed61ff 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.azureaistudio.completion; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -47,13 +46,9 @@ public AzureAiStudioChatCompletionModel( String service, AzureAiStudioChatCompletionServiceSettings serviceSettings, AzureAiStudioChatCompletionTaskSettings taskSettings, - DefaultSecretSettings secrets, - EndpointVersions endpointVersion + DefaultSecretSettings secrets ) { - super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), - new ModelSecrets(secrets) - ); + super(new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets)); } public AzureAiStudioChatCompletionModel( @@ -63,8 +58,7 @@ public AzureAiStudioChatCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -72,8 +66,7 @@ public AzureAiStudioChatCompletionModel( service, AzureAiStudioChatCompletionServiceSettings.fromMap(serviceSettings, context), AzureAiStudioChatCompletionTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java index 1a91174d4d576..a999b9f0312e6 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.azureaistudio.embeddings; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -45,13 +44,9 @@ public AzureAiStudioEmbeddingsModel( String service, AzureAiStudioEmbeddingsServiceSettings serviceSettings, AzureAiStudioEmbeddingsTaskSettings taskSettings, - DefaultSecretSettings secrets, - EndpointVersions endpointVersion + DefaultSecretSettings secrets ) { - super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), - new ModelSecrets(secrets) - ); + super(new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets)); } public AzureAiStudioEmbeddingsModel( @@ -61,8 +56,7 @@ public AzureAiStudioEmbeddingsModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -70,8 +64,7 @@ public AzureAiStudioEmbeddingsModel( service, AzureAiStudioEmbeddingsServiceSettings.fromMap(serviceSettings, context), AzureAiStudioEmbeddingsTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java index fbe31050433d5..96399bb954cd2 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java @@ -16,7 +16,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -65,7 +64,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -79,8 +77,7 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -99,8 +96,7 @@ private static AzureOpenAiModel createModelFromPersistent( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -109,8 +105,7 @@ private static AzureOpenAiModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @@ -121,8 +116,7 @@ private static AzureOpenAiModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { switch (taskType) { case TEXT_EMBEDDING -> { @@ -133,8 +127,7 @@ private static AzureOpenAiModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); } case COMPLETION -> { @@ -145,8 +138,7 @@ private static AzureOpenAiModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); } default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); @@ -158,8 +150,7 @@ public AzureOpenAiModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -171,18 +162,12 @@ public AzureOpenAiModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @Override - public AzureOpenAiModel parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public AzureOpenAiModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); @@ -192,8 +177,7 @@ public AzureOpenAiModel parsePersistedConfig( serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java index 65b39f7827949..c4146b2ba2d30 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.azureopenai.completion; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -40,8 +39,7 @@ public AzureOpenAiCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -49,8 +47,7 @@ public AzureOpenAiCompletionModel( service, AzureOpenAiCompletionServiceSettings.fromMap(serviceSettings, context), AzureOpenAiCompletionTaskSettings.fromMap(taskSettings), - AzureOpenAiSecretSettings.fromMap(secrets), - endpointVersion + AzureOpenAiSecretSettings.fromMap(secrets) ); } @@ -61,11 +58,10 @@ public AzureOpenAiCompletionModel( String service, AzureOpenAiCompletionServiceSettings serviceSettings, AzureOpenAiCompletionTaskSettings taskSettings, - @Nullable AzureOpenAiSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable AzureOpenAiSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java index 2a88fd4be6615..377bb33f58619 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.azureopenai.embeddings; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -40,8 +39,7 @@ public AzureOpenAiEmbeddingsModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -49,8 +47,7 @@ public AzureOpenAiEmbeddingsModel( service, AzureOpenAiEmbeddingsServiceSettings.fromMap(serviceSettings, context), AzureOpenAiEmbeddingsTaskSettings.fromMap(taskSettings), - AzureOpenAiSecretSettings.fromMap(secrets), - endpointVersion + AzureOpenAiSecretSettings.fromMap(secrets) ); } @@ -61,11 +58,10 @@ public AzureOpenAiEmbeddingsModel( String service, AzureOpenAiEmbeddingsServiceSettings serviceSettings, AzureOpenAiEmbeddingsTaskSettings taskSettings, - @Nullable AzureOpenAiSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable AzureOpenAiSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java index 5fe313efecc11..728a4ac137dff 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java @@ -15,7 +15,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -70,7 +69,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -84,8 +82,7 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -104,8 +101,7 @@ private static CohereModel createModelWithoutLoggingDeprecations( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -114,8 +110,7 @@ private static CohereModel createModelWithoutLoggingDeprecations( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @@ -126,8 +121,7 @@ private static CohereModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { case TEXT_EMBEDDING -> new CohereEmbeddingsModel( @@ -137,19 +131,9 @@ private static CohereModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion - ); - case RERANK -> new CohereRerankModel( - inferenceEntityId, - taskType, - NAME, - serviceSettings, - taskSettings, - secretSettings, - context, - endpointVersion + context ); + case RERANK -> new CohereRerankModel(inferenceEntityId, taskType, NAME, serviceSettings, taskSettings, secretSettings, context); case COMPLETION -> new CohereCompletionModel( inferenceEntityId, taskType, @@ -157,8 +141,7 @@ private static CohereModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -169,8 +152,7 @@ public CohereModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -182,18 +164,12 @@ public CohereModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @Override - public CohereModel parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public CohereModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -203,8 +179,7 @@ public CohereModel parsePersistedConfig( serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java index 3932d8578a1d2..bec4f5a0b5c85 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/completion/CohereCompletionModel.java @@ -9,7 +9,6 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -33,8 +32,7 @@ public CohereCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( modelId, @@ -42,8 +40,7 @@ public CohereCompletionModel( service, CohereCompletionServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -54,11 +51,10 @@ public CohereCompletionModel( String service, CohereCompletionServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings), secretSettings, serviceSettings diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java index acadb8808ca06..fea5226bf9c6f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.cohere.embeddings; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -35,8 +34,7 @@ public CohereEmbeddingsModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceId, @@ -44,8 +42,7 @@ public CohereEmbeddingsModel( service, CohereEmbeddingsServiceSettings.fromMap(serviceSettings, context), CohereEmbeddingsTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -56,11 +53,10 @@ public CohereEmbeddingsModel( String service, CohereEmbeddingsServiceSettings serviceSettings, CohereEmbeddingsTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings), secretSettings, serviceSettings.getCommonSettings() diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java index 4fd937b51c744..b84b98973bbe5 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.cohere.rerank; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -35,8 +34,7 @@ public CohereRerankModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( modelId, @@ -44,8 +42,7 @@ public CohereRerankModel( service, CohereRerankServiceSettings.fromMap(serviceSettings, context), CohereRerankTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -56,11 +53,10 @@ public CohereRerankModel( String service, CohereRerankServiceSettings serviceSettings, CohereRerankTaskSettings taskSettings, - @Nullable DefaultSecretSettings secretSettings, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings), secretSettings, serviceSettings diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java index a0ad1c7cb70b1..7cfbc272aac5a 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java @@ -16,7 +16,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -117,7 +116,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -132,8 +130,7 @@ public void parseRequestConfig( serviceSettingsMap, elasticInferenceServiceComponents, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -154,8 +151,7 @@ private static ElasticInferenceServiceModel createModel( @Nullable Map secretSettings, ElasticInferenceServiceComponents eisServiceComponents, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { case SPARSE_EMBEDDING -> new ElasticInferenceServiceSparseEmbeddingsModel( @@ -166,8 +162,7 @@ private static ElasticInferenceServiceModel createModel( taskSettings, secretSettings, eisServiceComponents, - context, - endpointVersion + context ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -178,8 +173,7 @@ public Model parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -191,18 +185,12 @@ public Model parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @Override - public Model parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); @@ -212,8 +200,7 @@ public Model parsePersistedConfig( serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @@ -228,8 +215,7 @@ private ElasticInferenceServiceModel createModelFromPersistent( Map serviceSettings, Map taskSettings, @Nullable Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -239,8 +225,7 @@ private ElasticInferenceServiceModel createModelFromPersistent( secretSettings, elasticInferenceServiceComponents, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java index e7643ed8b312f..bbbae736dbeb9 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModel.java @@ -10,7 +10,6 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptySecretSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.SecretSettings; @@ -37,8 +36,7 @@ public ElasticInferenceServiceSparseEmbeddingsModel( Map taskSettings, Map secrets, ElasticInferenceServiceComponents elasticInferenceServiceComponents, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -47,8 +45,7 @@ public ElasticInferenceServiceSparseEmbeddingsModel( ElasticInferenceServiceSparseEmbeddingsServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, EmptySecretSettings.INSTANCE, - elasticInferenceServiceComponents, - endpointVersion + elasticInferenceServiceComponents ); } @@ -72,11 +69,10 @@ public ElasticInferenceServiceSparseEmbeddingsModel( ElasticInferenceServiceSparseEmbeddingsServiceSettings serviceSettings, @Nullable TaskSettings taskSettings, @Nullable SecretSettings secretSettings, - ElasticInferenceServiceComponents elasticInferenceServiceComponents, - EndpointVersions endpointVersion + ElasticInferenceServiceComponents elasticInferenceServiceComponents ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings), serviceSettings, elasticInferenceServiceComponents diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java index cfc748ac06f9f..59203d00e589a 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandEmbeddingModel.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.inference.services.elasticsearch; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; public class CustomElandEmbeddingModel extends CustomElandModel { @@ -16,10 +15,9 @@ public CustomElandEmbeddingModel( String inferenceEntityId, TaskType taskType, String service, - CustomElandInternalTextEmbeddingServiceSettings serviceSettings, - EndpointVersions endpointVersion + CustomElandInternalTextEmbeddingServiceSettings serviceSettings ) { - super(inferenceEntityId, taskType, service, serviceSettings, endpointVersion); + super(inferenceEntityId, taskType, service, serviceSettings); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java index 15456ec2adcf1..83f22f08b620d 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandModel.java @@ -9,7 +9,6 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.TaskSettings; import org.elasticsearch.inference.TaskType; @@ -22,10 +21,9 @@ public CustomElandModel( String inferenceEntityId, TaskType taskType, String service, - ElasticsearchInternalServiceSettings internalServiceSettings, - EndpointVersions endpointVersion + ElasticsearchInternalServiceSettings internalServiceSettings ) { - super(inferenceEntityId, taskType, service, internalServiceSettings, endpointVersion); + super(inferenceEntityId, taskType, service, internalServiceSettings); } public CustomElandModel( @@ -33,10 +31,9 @@ public CustomElandModel( TaskType taskType, String service, ElasticsearchInternalServiceSettings internalServiceSettings, - TaskSettings taskSettings, - EndpointVersions endpointVersion + TaskSettings taskSettings ) { - super(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings, endpointVersion); + super(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java index 88d49c6597b97..63f4a3dbf8472 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankModel.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.inference.services.elasticsearch; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; public class CustomElandRerankModel extends CustomElandModel { @@ -17,10 +16,9 @@ public CustomElandRerankModel( TaskType taskType, String service, CustomElandInternalServiceSettings serviceSettings, - CustomElandRerankTaskSettings taskSettings, - EndpointVersions endpointVersion + CustomElandRerankTaskSettings taskSettings ) { - super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); + super(inferenceEntityId, taskType, service, serviceSettings, taskSettings); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java index f55934119b6cd..07d0cc14b2ac8 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalModel.java @@ -9,7 +9,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Strings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskSettings; @@ -27,10 +26,9 @@ public ElasticsearchInternalModel( String inferenceEntityId, TaskType taskType, String service, - ElasticsearchInternalServiceSettings internalServiceSettings, - EndpointVersions endpointVersion + ElasticsearchInternalServiceSettings internalServiceSettings ) { - super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings, endpointVersion)); + super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings)); this.internalServiceSettings = internalServiceSettings; } @@ -39,10 +37,9 @@ public ElasticsearchInternalModel( TaskType taskType, String service, ElasticsearchInternalServiceSettings internalServiceSettings, - TaskSettings taskSettings, - EndpointVersions endpointVersion + TaskSettings taskSettings ) { - super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings, endpointVersion)); + super(new ModelConfigurations(inferenceEntityId, taskType, service, internalServiceSettings, taskSettings)); this.internalServiceSettings = internalServiceSettings; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java index 06c316bb36f5f..9b4c0e50bdebe 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java @@ -19,7 +19,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceResults; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InferenceServiceResults; @@ -102,7 +101,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener modelListener ) { if (inferenceEntityId.equals(DEFAULT_ELSER_ID)) { @@ -136,15 +134,7 @@ public void parseRequestConfig( ); platformArch.accept( modelListener.delegateFailureAndWrap( - (delegate, arch) -> elserCase( - inferenceEntityId, - taskType, - config, - arch, - serviceSettingsMap, - modelListener, - endpointVersion - ) + (delegate, arch) -> elserCase(inferenceEntityId, taskType, config, arch, serviceSettingsMap, modelListener) ) ); } else { @@ -153,33 +143,17 @@ public void parseRequestConfig( } else if (MULTILINGUAL_E5_SMALL_VALID_IDS.contains(modelId)) { platformArch.accept( modelListener.delegateFailureAndWrap( - (delegate, arch) -> e5Case( - inferenceEntityId, - taskType, - config, - arch, - serviceSettingsMap, - modelListener, - endpointVersion - ) + (delegate, arch) -> e5Case(inferenceEntityId, taskType, config, arch, serviceSettingsMap, modelListener) ) ); } else if (ElserModels.isValidModel(modelId)) { platformArch.accept( modelListener.delegateFailureAndWrap( - (delegate, arch) -> elserCase( - inferenceEntityId, - taskType, - config, - arch, - serviceSettingsMap, - modelListener, - endpointVersion - ) + (delegate, arch) -> elserCase(inferenceEntityId, taskType, config, arch, serviceSettingsMap, modelListener) ) ); } else { - customElandCase(inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, modelListener, endpointVersion); + customElandCase(inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, modelListener); } } catch (Exception e) { modelListener.onFailure(e); @@ -191,8 +165,7 @@ private void customElandCase( TaskType taskType, Map serviceSettingsMap, Map taskSettingsMap, - ActionListener modelListener, - EndpointVersions endpointVersion + ActionListener modelListener ) { String modelId = (String) serviceSettingsMap.get(ElasticsearchInternalServiceSettings.MODEL_ID); var request = new GetTrainedModelsAction.Request(modelId); @@ -210,8 +183,7 @@ private void customElandCase( taskType, serviceSettingsMap, taskSettingsMap, - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(serviceSettingsMap, name()); @@ -229,8 +201,7 @@ private static CustomElandModel createCustomElandModel( TaskType taskType, Map serviceSettings, Map taskSettings, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { @@ -238,23 +209,20 @@ private static CustomElandModel createCustomElandModel( inferenceEntityId, taskType, NAME, - CustomElandInternalTextEmbeddingServiceSettings.fromMap(serviceSettings, context), - endpointVersion + CustomElandInternalTextEmbeddingServiceSettings.fromMap(serviceSettings, context) ); case SPARSE_EMBEDDING -> new CustomElandModel( inferenceEntityId, taskType, NAME, - elandServiceSettings(serviceSettings, context), - endpointVersion + elandServiceSettings(serviceSettings, context) ); case RERANK -> new CustomElandRerankModel( inferenceEntityId, taskType, NAME, elandServiceSettings(serviceSettings, context), - CustomElandRerankTaskSettings.fromMap(taskSettings), - endpointVersion + CustomElandRerankTaskSettings.fromMap(taskSettings) ); default -> throw new ElasticsearchStatusException(TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), RestStatus.BAD_REQUEST); }; @@ -278,8 +246,7 @@ private void e5Case( Map config, Set platformArchitectures, Map serviceSettingsMap, - ActionListener modelListener, - EndpointVersions endpointVersion + ActionListener modelListener ) { var esServiceSettingsBuilder = ElasticsearchInternalServiceSettings.fromRequestMap(serviceSettingsMap); @@ -307,8 +274,7 @@ private void e5Case( inferenceEntityId, taskType, NAME, - new MultilingualE5SmallInternalServiceSettings(esServiceSettingsBuilder.build()), - endpointVersion + new MultilingualE5SmallInternalServiceSettings(esServiceSettingsBuilder.build()) ) ); } @@ -333,8 +299,7 @@ private void elserCase( Map config, Set platformArchitectures, Map serviceSettingsMap, - ActionListener modelListener, - EndpointVersions endpointVersion + ActionListener modelListener ) { var esServiceSettingsBuilder = ElasticsearchInternalServiceSettings.fromRequestMap(serviceSettingsMap); final String defaultModelId = selectDefaultModelVariantBasedOnClusterArchitecture( @@ -390,8 +355,7 @@ private void elserCase( taskType, NAME, new ElserInternalServiceSettings(esServiceSettingsBuilder.build()), - ElserMlNodeTaskSettings.DEFAULT, - endpointVersion + ElserMlNodeTaskSettings.DEFAULT ) ); } @@ -414,19 +378,13 @@ public Model parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { - return parsePersistedConfig(inferenceEntityId, taskType, config, endpointVersion); + return parsePersistedConfig(inferenceEntityId, taskType, config); } @Override - public Model parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMap(config, ModelConfigurations.TASK_SETTINGS); @@ -440,8 +398,7 @@ public Model parsePersistedConfig( inferenceEntityId, taskType, NAME, - new MultilingualE5SmallInternalServiceSettings(ElasticsearchInternalServiceSettings.fromPersistedMap(serviceSettingsMap)), - endpointVersion + new MultilingualE5SmallInternalServiceSettings(ElasticsearchInternalServiceSettings.fromPersistedMap(serviceSettingsMap)) ); } else if (ElserModels.isValidModel(modelId)) { return new ElserInternalModel( @@ -449,8 +406,7 @@ public Model parsePersistedConfig( taskType, NAME, new ElserInternalServiceSettings(ElasticsearchInternalServiceSettings.fromPersistedMap(serviceSettingsMap)), - ElserMlNodeTaskSettings.DEFAULT, - endpointVersion + ElserMlNodeTaskSettings.DEFAULT ); } else { return createCustomElandModel( @@ -458,8 +414,7 @@ public Model parsePersistedConfig( taskType, serviceSettingsMap, taskSettingsMap, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } } @@ -475,8 +430,7 @@ public void checkModelConfig(Model model, ActionListener listener) { elandModel.getServiceSettings().modelId(), elandModel.getTaskType(), elandModel.getConfigurations().getService(), - elandModel.getServiceSettings(), - elandModel.getConfigurations().getEndpointVersion() + elandModel.getServiceSettings() ); ServiceUtils.getEmbeddingSize( @@ -504,8 +458,7 @@ private static CustomElandEmbeddingModel updateModelWithEmbeddingDetails(CustomE model.getInferenceEntityId(), model.getTaskType(), model.getConfigurations().getService(), - serviceSettings, - model.getConfigurations().getEndpointVersion() + serviceSettings ); } @@ -776,8 +729,7 @@ public List defaultConfigs() { TaskType.SPARSE_EMBEDDING, NAME, elserSettings, - Map.of(), // no secrets - EndpointVersions.FIRST_ENDPOINT_VERSION + Map.of() // no secrets ) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java index 1da1db89bfe04..827eb178f7633 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserInternalModel.java @@ -9,7 +9,6 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.TaskType; import org.elasticsearch.xpack.core.ml.action.CreateTrainedModelAssignmentAction; @@ -22,10 +21,9 @@ public ElserInternalModel( TaskType taskType, String service, ElserInternalServiceSettings serviceSettings, - ElserMlNodeTaskSettings taskSettings, - EndpointVersions endpointVersion + ElserMlNodeTaskSettings taskSettings ) { - super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion); + super(inferenceEntityId, taskType, service, serviceSettings, taskSettings); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java index 7328e7d269859..59e5e9c1550c5 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/MultilingualE5SmallModel.java @@ -9,7 +9,6 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.TaskType; import org.elasticsearch.xpack.core.ml.action.CreateTrainedModelAssignmentAction; @@ -21,10 +20,9 @@ public MultilingualE5SmallModel( String inferenceEntityId, TaskType taskType, String service, - MultilingualE5SmallInternalServiceSettings serviceSettings, - EndpointVersions endpointVersion + MultilingualE5SmallInternalServiceSettings serviceSettings ) { - super(inferenceEntityId, taskType, service, serviceSettings, endpointVersion); + super(inferenceEntityId, taskType, service, serviceSettings); } @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java index 029be839773f7..9a04edf138996 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java @@ -16,7 +16,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -69,7 +68,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -91,8 +89,7 @@ public void parseRequestConfig( chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -114,8 +111,7 @@ private static GoogleAiStudioModel createModel( ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { case COMPLETION -> new GoogleAiStudioCompletionModel( @@ -125,8 +121,7 @@ private static GoogleAiStudioModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); case TEXT_EMBEDDING -> new GoogleAiStudioEmbeddingsModel( inferenceEntityId, @@ -136,8 +131,7 @@ private static GoogleAiStudioModel createModel( taskSettings, chunkingSettings, secretSettings, - context, - endpointVersion + context ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -148,8 +142,7 @@ public GoogleAiStudioModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -167,8 +160,7 @@ public GoogleAiStudioModel parsePersistedConfigWithSecrets( taskSettingsMap, chunkingSettings, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @@ -179,8 +171,7 @@ private static GoogleAiStudioModel createModelFromPersistent( Map taskSettings, ChunkingSettings chunkingSettings, Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -190,18 +181,12 @@ private static GoogleAiStudioModel createModelFromPersistent( chunkingSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @Override - public Model parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -217,8 +202,7 @@ public Model parsePersistedConfig( taskSettingsMap, chunkingSettings, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java index 0ed6fa76c3486..8fa2ac0148716 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/completion/GoogleAiStudioCompletionModel.java @@ -10,7 +10,6 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -40,8 +39,7 @@ public GoogleAiStudioCompletionModel( Map serviceSettings, Map taskSettings, Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -49,8 +47,7 @@ public GoogleAiStudioCompletionModel( service, GoogleAiStudioCompletionServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -61,11 +58,10 @@ public GoogleAiStudioCompletionModel( String service, GoogleAiStudioCompletionServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); @@ -84,11 +80,10 @@ public GoogleAiStudioCompletionModel( String url, GoogleAiStudioCompletionServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java index 4e699a61e4645..5d46a8e129dff 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/embeddings/GoogleAiStudioEmbeddingsModel.java @@ -11,7 +11,6 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -42,8 +41,7 @@ public GoogleAiStudioEmbeddingsModel( Map taskSettings, ChunkingSettings chunkingSettings, Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -52,8 +50,7 @@ public GoogleAiStudioEmbeddingsModel( GoogleAiStudioEmbeddingsServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, chunkingSettings, - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -69,11 +66,10 @@ public GoogleAiStudioEmbeddingsModel(GoogleAiStudioEmbeddingsModel model, Google GoogleAiStudioEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, ChunkingSettings chunkingSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings), new ModelSecrets(secrets), serviceSettings ); @@ -92,11 +88,10 @@ public GoogleAiStudioEmbeddingsModel(GoogleAiStudioEmbeddingsModel model, Google String uri, GoogleAiStudioEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); @@ -116,11 +111,10 @@ public GoogleAiStudioEmbeddingsModel(GoogleAiStudioEmbeddingsModel model, Google GoogleAiStudioEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, ChunkingSettings chunkingsettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingsettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingsettings), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java index 308149f1aa7fb..d9d8850048564 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java @@ -16,7 +16,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -65,7 +64,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parseModelListener ) { try { @@ -79,8 +77,7 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -98,8 +95,7 @@ public Model parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -111,18 +107,12 @@ public Model parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @Override - public Model parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -132,8 +122,7 @@ public Model parsePersistedConfig( serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @@ -237,8 +226,7 @@ private static GoogleVertexAiModel createModelFromPersistent( Map serviceSettings, Map taskSettings, Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -247,8 +235,7 @@ private static GoogleVertexAiModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @@ -259,8 +246,7 @@ private static GoogleVertexAiModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { case TEXT_EMBEDDING -> new GoogleVertexAiEmbeddingsModel( @@ -270,8 +256,7 @@ private static GoogleVertexAiModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); case RERANK -> new GoogleVertexAiRerankModel( inferenceEntityId, @@ -280,8 +265,7 @@ private static GoogleVertexAiModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java index 6a645845ed7e2..99110045fc3da 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java @@ -9,7 +9,6 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -37,8 +36,7 @@ public GoogleVertexAiEmbeddingsModel( Map serviceSettings, Map taskSettings, Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -46,8 +44,7 @@ public GoogleVertexAiEmbeddingsModel( service, GoogleVertexAiEmbeddingsServiceSettings.fromMap(serviceSettings, context), GoogleVertexAiEmbeddingsTaskSettings.fromMap(taskSettings), - GoogleVertexAiSecretSettings.fromMap(secrets), - endpointVersion + GoogleVertexAiSecretSettings.fromMap(secrets) ); } @@ -62,11 +59,10 @@ public GoogleVertexAiEmbeddingsModel(GoogleVertexAiEmbeddingsModel model, Google String service, GoogleVertexAiEmbeddingsServiceSettings serviceSettings, GoogleVertexAiEmbeddingsTaskSettings taskSettings, - @Nullable GoogleVertexAiSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable GoogleVertexAiSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); @@ -85,11 +81,10 @@ protected GoogleVertexAiEmbeddingsModel( String uri, GoogleVertexAiEmbeddingsServiceSettings serviceSettings, GoogleVertexAiEmbeddingsTaskSettings taskSettings, - @Nullable GoogleVertexAiSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable GoogleVertexAiSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java index 96df873dab6d9..45fad977a2b6b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankModel.java @@ -9,7 +9,6 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -37,8 +36,7 @@ public GoogleVertexAiRerankModel( Map serviceSettings, Map taskSettings, Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -46,8 +44,7 @@ public GoogleVertexAiRerankModel( service, GoogleVertexAiRerankServiceSettings.fromMap(serviceSettings, context), GoogleVertexAiRerankTaskSettings.fromMap(taskSettings), - GoogleVertexAiSecretSettings.fromMap(secrets), - endpointVersion + GoogleVertexAiSecretSettings.fromMap(secrets) ); } @@ -62,11 +59,10 @@ public GoogleVertexAiRerankModel(GoogleVertexAiRerankModel model, GoogleVertexAi String service, GoogleVertexAiRerankServiceSettings serviceSettings, GoogleVertexAiRerankTaskSettings taskSettings, - @Nullable GoogleVertexAiSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable GoogleVertexAiSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); @@ -85,11 +81,10 @@ protected GoogleVertexAiRerankModel( String uri, GoogleVertexAiRerankServiceSettings serviceSettings, GoogleVertexAiRerankTaskSettings taskSettings, - @Nullable GoogleVertexAiSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable GoogleVertexAiSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java index b965cff96e1be..9f2615ac5c515 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceBaseService.java @@ -10,7 +10,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -52,7 +51,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -72,8 +70,7 @@ public void parseRequestConfig( chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, name()), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, name()); @@ -90,8 +87,7 @@ public HuggingFaceModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); @@ -108,18 +104,12 @@ public HuggingFaceModel parsePersistedConfigWithSecrets( chunkingSettings, secretSettingsMap, parsePersistedConfigErrorMsg(inferenceEntityId, name()), - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @Override - public HuggingFaceModel parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public HuggingFaceModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -134,8 +124,7 @@ public HuggingFaceModel parsePersistedConfig( chunkingSettings, null, parsePersistedConfigErrorMsg(inferenceEntityId, name()), - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @@ -146,8 +135,7 @@ protected abstract HuggingFaceModel createModel( ChunkingSettings chunkingSettings, Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ); @Override diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java index c88e65e88f53b..14af29bab9078 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceService.java @@ -16,7 +16,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.SimilarityMeasure; @@ -54,8 +53,7 @@ protected HuggingFaceModel createModel( ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { case TEXT_EMBEDDING -> new HuggingFaceEmbeddingsModel( @@ -65,18 +63,9 @@ protected HuggingFaceModel createModel( serviceSettings, chunkingSettings, secretSettings, - context, - endpointVersion - ); - case SPARSE_EMBEDDING -> new HuggingFaceElserModel( - inferenceEntityId, - taskType, - NAME, - serviceSettings, - secretSettings, - context, - endpointVersion + context ); + case SPARSE_EMBEDDING -> new HuggingFaceElserModel(inferenceEntityId, taskType, NAME, serviceSettings, secretSettings, context); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java index 429dd47ac3f2d..8132089d8dc99 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.huggingface.elser; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -27,16 +26,14 @@ public HuggingFaceElserModel( String service, Map serviceSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, taskType, service, HuggingFaceElserServiceSettings.fromMap(serviceSettings, context), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -45,11 +42,10 @@ public HuggingFaceElserModel( TaskType taskType, String service, HuggingFaceElserServiceSettings serviceSettings, - @Nullable DefaultSecretSettings secretSettings, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings), new ModelSecrets(secretSettings), serviceSettings, secretSettings diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java index 28cf779d57daa..a8de51c23831f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserService.java @@ -17,7 +17,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -61,19 +60,10 @@ protected HuggingFaceModel createModel( ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { - case SPARSE_EMBEDDING -> new HuggingFaceElserModel( - inferenceEntityId, - taskType, - NAME, - serviceSettings, - secretSettings, - context, - endpointVersion - ); + case SPARSE_EMBEDDING -> new HuggingFaceElserModel(inferenceEntityId, taskType, NAME, serviceSettings, secretSettings, context); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java index ea0a585a09f11..7c4d8094fc213 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/huggingface/embeddings/HuggingFaceEmbeddingsModel.java @@ -9,7 +9,6 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -30,8 +29,7 @@ public HuggingFaceEmbeddingsModel( Map serviceSettings, ChunkingSettings chunkingSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -39,8 +37,7 @@ public HuggingFaceEmbeddingsModel( service, HuggingFaceServiceSettings.fromMap(serviceSettings, context), chunkingSettings, - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -51,11 +48,10 @@ public HuggingFaceEmbeddingsModel( String service, HuggingFaceServiceSettings serviceSettings, ChunkingSettings chunkingSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, chunkingSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, chunkingSettings), new ModelSecrets(secrets), serviceSettings, secrets @@ -69,8 +65,7 @@ public HuggingFaceEmbeddingsModel(HuggingFaceEmbeddingsModel model, HuggingFaceS model.getConfigurations().getService(), serviceSettings, model.getConfigurations().getChunkingSettings(), - model.getSecretSettings(), - model.getConfigurations().getEndpointVersion() + model.getSecretSettings() ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java index fc1c109291edf..14be1a70b5daa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java @@ -15,7 +15,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -65,7 +64,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -79,8 +77,7 @@ public void parseRequestConfig( taskSettingsMap, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -101,8 +98,7 @@ private static IbmWatsonxModel createModel( Map taskSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { case TEXT_EMBEDDING -> new IbmWatsonxEmbeddingsModel( @@ -112,8 +108,7 @@ private static IbmWatsonxModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -124,8 +119,7 @@ public IbmWatsonxModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -137,8 +131,7 @@ public IbmWatsonxModel parsePersistedConfigWithSecrets( serviceSettingsMap, taskSettingsMap, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @@ -148,8 +141,7 @@ private static IbmWatsonxModel createModelFromPersistent( Map serviceSettings, Map taskSettings, Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -158,18 +150,12 @@ private static IbmWatsonxModel createModelFromPersistent( taskSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @Override - public Model parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -179,8 +165,7 @@ public Model parsePersistedConfig( serviceSettingsMap, taskSettingsMap, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java index 75ff0db028fa5..d60e31b5d41c0 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModel.java @@ -10,7 +10,6 @@ import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -42,8 +41,7 @@ public IbmWatsonxEmbeddingsModel( Map serviceSettings, Map taskSettings, Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -51,8 +49,7 @@ public IbmWatsonxEmbeddingsModel( service, IbmWatsonxEmbeddingsServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -67,11 +64,10 @@ public IbmWatsonxEmbeddingsModel(IbmWatsonxEmbeddingsModel model, IbmWatsonxEmbe String service, IbmWatsonxEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); @@ -90,11 +86,10 @@ public IbmWatsonxEmbeddingsModel(IbmWatsonxEmbeddingsModel model, IbmWatsonxEmbe String uri, IbmWatsonxEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java index e887a453c18ef..8af817d06fefa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/MistralService.java @@ -15,7 +15,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -123,7 +122,6 @@ public void parseRequestConfig( String modelId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -145,8 +143,7 @@ public void parseRequestConfig( chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -164,8 +161,7 @@ public Model parsePersistedConfigWithSecrets( String modelId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); @@ -183,13 +179,12 @@ public Model parsePersistedConfigWithSecrets( taskSettingsMap, chunkingSettings, secretSettingsMap, - parsePersistedConfigErrorMsg(modelId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(modelId, NAME) ); } @Override - public Model parsePersistedConfig(String modelId, TaskType taskType, Map config, EndpointVersions endpointVersion) { + public Model parsePersistedConfig(String modelId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); @@ -205,8 +200,7 @@ public Model parsePersistedConfig(String modelId, TaskType taskType, Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { if (taskType == TaskType.TEXT_EMBEDDING) { return new MistralEmbeddingsModel( @@ -235,8 +228,7 @@ private static MistralEmbeddingsModel createModel( taskSettings, chunkingSettings, secretSettings, - context, - endpointVersion + context ); } @@ -250,8 +242,7 @@ private MistralEmbeddingsModel createModelFromPersistent( Map taskSettings, ChunkingSettings chunkingSettings, Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -261,8 +252,7 @@ private MistralEmbeddingsModel createModelFromPersistent( chunkingSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java index 459d013b21c99..11f6c456b88cc 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingsModel.java @@ -10,7 +10,6 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -41,8 +40,7 @@ public MistralEmbeddingsModel( Map taskSettings, ChunkingSettings chunkingSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -51,8 +49,7 @@ public MistralEmbeddingsModel( MistralEmbeddingsServiceSettings.fromMap(serviceSettings, context), EmptyTaskSettings.INSTANCE, // no task settings for Mistral embeddings chunkingSettings, - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -68,19 +65,10 @@ public MistralEmbeddingsModel( MistralEmbeddingsServiceSettings serviceSettings, TaskSettings taskSettings, ChunkingSettings chunkingSettings, - DefaultSecretSettings secrets, - EndpointVersions endpointVersion + DefaultSecretSettings secrets ) { super( - new ModelConfigurations( - inferenceEntityId, - taskType, - service, - serviceSettings, - new EmptyTaskSettings(), - chunkingSettings, - endpointVersion - ), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, new EmptyTaskSettings(), chunkingSettings), new ModelSecrets(secrets) ); setPropertiesFromServiceSettings(serviceSettings); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java index 8138bb57b1087..fd5f7197475aa 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java @@ -16,7 +16,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -70,7 +69,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { try { @@ -94,8 +92,7 @@ public void parseRequestConfig( chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), - ConfigurationParseContext.REQUEST, - endpointVersion + ConfigurationParseContext.REQUEST ); throwIfNotEmptyMap(config, NAME); @@ -115,8 +112,7 @@ private static OpenAiModel createModelFromPersistent( Map taskSettings, ChunkingSettings chunkingSettings, @Nullable Map secretSettings, - String failureMessage, - EndpointVersions endpointVersion + String failureMessage ) { return createModel( inferenceEntityId, @@ -126,8 +122,7 @@ private static OpenAiModel createModelFromPersistent( chunkingSettings, secretSettings, failureMessage, - ConfigurationParseContext.PERSISTENT, - endpointVersion + ConfigurationParseContext.PERSISTENT ); } @@ -139,8 +134,7 @@ private static OpenAiModel createModel( ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { return switch (taskType) { case TEXT_EMBEDDING -> new OpenAiEmbeddingsModel( @@ -151,8 +145,7 @@ private static OpenAiModel createModel( taskSettings, chunkingSettings, secretSettings, - context, - endpointVersion + context ); case COMPLETION -> new OpenAiChatCompletionModel( inferenceEntityId, @@ -161,8 +154,7 @@ private static OpenAiModel createModel( serviceSettings, taskSettings, secretSettings, - context, - endpointVersion + context ); default -> throw new ElasticsearchStatusException(failureMessage, RestStatus.BAD_REQUEST); }; @@ -173,8 +165,7 @@ public OpenAiModel parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); @@ -194,18 +185,12 @@ public OpenAiModel parsePersistedConfigWithSecrets( taskSettingsMap, chunkingSettings, secretSettingsMap, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } @Override - public OpenAiModel parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public OpenAiModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); @@ -223,8 +208,7 @@ public OpenAiModel parsePersistedConfig( taskSettingsMap, chunkingSettings, null, - parsePersistedConfigErrorMsg(inferenceEntityId, NAME), - endpointVersion + parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java index 903a091256075..7ca93684bc680 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModel.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.openai.completion; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -38,8 +37,7 @@ public OpenAiChatCompletionModel( Map serviceSettings, Map taskSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -47,8 +45,7 @@ public OpenAiChatCompletionModel( service, OpenAiChatCompletionServiceSettings.fromMap(serviceSettings, context), OpenAiChatCompletionTaskSettings.fromMap(taskSettings), - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -58,11 +55,10 @@ public OpenAiChatCompletionModel( String service, OpenAiChatCompletionServiceSettings serviceSettings, OpenAiChatCompletionTaskSettings taskSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets), serviceSettings, secrets diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java index 68f9a00d16b22..5659c46050ad8 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModel.java @@ -9,7 +9,6 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -40,8 +39,7 @@ public OpenAiEmbeddingsModel( Map taskSettings, ChunkingSettings chunkingSettings, @Nullable Map secrets, - ConfigurationParseContext context, - EndpointVersions endpointVersion + ConfigurationParseContext context ) { this( inferenceEntityId, @@ -50,8 +48,7 @@ public OpenAiEmbeddingsModel( OpenAiEmbeddingsServiceSettings.fromMap(serviceSettings, context), OpenAiEmbeddingsTaskSettings.fromMap(taskSettings, context), chunkingSettings, - DefaultSecretSettings.fromMap(secrets), - endpointVersion + DefaultSecretSettings.fromMap(secrets) ); } @@ -63,11 +60,10 @@ public OpenAiEmbeddingsModel( OpenAiEmbeddingsServiceSettings serviceSettings, OpenAiEmbeddingsTaskSettings taskSettings, ChunkingSettings chunkingSettings, - @Nullable DefaultSecretSettings secrets, - EndpointVersions endpointVersion + @Nullable DefaultSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings), new ModelSecrets(secrets), serviceSettings, secrets diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java index d4c171d8836db..a5aab67d66c1d 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java @@ -9,7 +9,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ServiceSettings; import org.elasticsearch.inference.TaskSettings; @@ -31,8 +30,7 @@ public static ModelConfigurations createRandomInstance() { randomAlphaOfLength(6), randomServiceSettings(), randomTaskSettings(taskType), - ChunkingSettingsFeatureFlag.isEnabled() && randomBoolean() ? ChunkingSettingsTests.createRandomChunkingSettings() : null, - EndpointVersions.FIRST_ENDPOINT_VERSION + ChunkingSettingsFeatureFlag.isEnabled() && randomBoolean() ? ChunkingSettingsTests.createRandomChunkingSettings() : null ); } @@ -43,24 +41,21 @@ public static ModelConfigurations mutateTestInstance(ModelConfigurations instanc instance.getTaskType(), instance.getService(), instance.getServiceSettings(), - instance.getTaskSettings(), - instance.getEndpointVersion() + instance.getTaskSettings() ); case 1 -> new ModelConfigurations( instance.getInferenceEntityId(), TaskType.values()[(instance.getTaskType().ordinal() + 1) % TaskType.values().length], instance.getService(), instance.getServiceSettings(), - instance.getTaskSettings(), - instance.getEndpointVersion() + instance.getTaskSettings() ); case 2 -> new ModelConfigurations( instance.getInferenceEntityId(), instance.getTaskType(), instance.getService() + "bar", instance.getServiceSettings(), - instance.getTaskSettings(), - instance.getEndpointVersion() + instance.getTaskSettings() ); default -> throw new IllegalStateException(); } @@ -94,13 +89,4 @@ protected ModelConfigurations createTestInstance() { protected ModelConfigurations mutateInstance(ModelConfigurations instance) { return mutateTestInstance(instance); } - - // future-proof of accidental enum ordering change or extension for serialization - public void testEnsureEndpointVersionsOrdinalsOrder() { - EnumSerializationTestUtils.assertEnumSerialization( - EndpointVersions.class, - EndpointVersions.FIRST_ENDPOINT_VERSION, - EndpointVersions.PARAMETERS_INTRODUCED_ENDPOINT_VERSION - ); - } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java index 46f754b2dd9c4..5abb9000f4d04 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/Utils.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; @@ -94,8 +93,7 @@ public static ScalingExecutorBuilder inferenceUtilityPool() { public static void storeSparseModel(Client client) throws Exception { Model model = new TestSparseInferenceServiceExtension.TestSparseModel( TestSparseInferenceServiceExtension.TestInferenceService.NAME, - new TestSparseInferenceServiceExtension.TestServiceSettings("sparse_model", null, false), - EndpointVersions.FIRST_ENDPOINT_VERSION + new TestSparseInferenceServiceExtension.TestServiceSettings("sparse_model", null, false) ); storeModel(client, model); } @@ -108,8 +106,7 @@ public static void storeDenseModel( ) throws Exception { Model model = new TestDenseInferenceServiceExtension.TestDenseModel( TestDenseInferenceServiceExtension.TestInferenceService.NAME, - new TestDenseInferenceServiceExtension.TestServiceSettings("dense_model", dimensions, similarityMeasure, elementType), - EndpointVersions.FIRST_ENDPOINT_VERSION + new TestDenseInferenceServiceExtension.TestServiceSettings("dense_model", dimensions, similarityMeasure, elementType) ); storeModel(client, model); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java index 5e6bc848b38d0..cd3ccd0645db9 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java @@ -15,7 +15,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ServiceSettings; import org.elasticsearch.inference.TaskType; @@ -86,43 +85,37 @@ public void test() throws Exception { "model-001", TaskType.TEXT_EMBEDDING, "openai", - mock(ServiceSettings.class), - EndpointVersions.FIRST_ENDPOINT_VERSION + mock(ServiceSettings.class) ), new ModelConfigurations( "model-002", TaskType.TEXT_EMBEDDING, "openai", - mock(ServiceSettings.class), - EndpointVersions.FIRST_ENDPOINT_VERSION + mock(ServiceSettings.class) ), new ModelConfigurations( "model-003", TaskType.SPARSE_EMBEDDING, "hugging_face_elser", - mock(ServiceSettings.class), - EndpointVersions.FIRST_ENDPOINT_VERSION + mock(ServiceSettings.class) ), new ModelConfigurations( "model-004", TaskType.TEXT_EMBEDDING, "openai", - mock(ServiceSettings.class), - EndpointVersions.FIRST_ENDPOINT_VERSION + mock(ServiceSettings.class) ), new ModelConfigurations( "model-005", TaskType.SPARSE_EMBEDDING, "openai", - mock(ServiceSettings.class), - EndpointVersions.FIRST_ENDPOINT_VERSION + mock(ServiceSettings.class) ), new ModelConfigurations( "model-006", TaskType.SPARSE_EMBEDDING, "hugging_face_elser", - mock(ServiceSettings.class), - EndpointVersions.FIRST_ENDPOINT_VERSION + mock(ServiceSettings.class) ) ) ) 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 1552999c9dee1..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 @@ -22,7 +22,6 @@ import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.inference.ChunkedInferenceServiceResults; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.InferenceServiceRegistry; import org.elasticsearch.inference.Model; @@ -277,8 +276,8 @@ private static ShardBulkInferenceActionFilter createFilter(ThreadPool threadPool model.getTaskType(), model.getServiceSettings().model(), XContentHelper.convertToMap(JsonXContent.jsonXContent, Strings.toString(model.getTaskSettings()), false), - XContentHelper.convertToMap(JsonXContent.jsonXContent, Strings.toString(model.getSecretSettings()), false), - EndpointVersions.FIRST_ENDPOINT_VERSION + XContentHelper.convertToMap(JsonXContent.jsonXContent, Strings.toString(model.getSecretSettings()), false) + ) ); } else { @@ -318,7 +317,7 @@ private static ShardBulkInferenceActionFilter createFilter(ThreadPool threadPool String inferenceId = (String) invocationOnMock.getArguments()[0]; return modelMap.get(inferenceId); }; - doAnswer(modelAnswer).when(inferenceService).parsePersistedConfigWithSecrets(any(), any(), any(), any(), any()); + doAnswer(modelAnswer).when(inferenceService).parsePersistedConfigWithSecrets(any(), any(), any(), any()); InferenceServiceRegistry inferenceServiceRegistry = mock(InferenceServiceRegistry.class); when(inferenceServiceRegistry.getService(any())).thenReturn(Optional.of(inferenceService)); @@ -381,10 +380,9 @@ private static class StaticModel extends TestModel { String service, TestServiceSettings serviceSettings, TestTaskSettings taskSettings, - TestSecretSettings secretSettings, - EndpointVersions endpointVersion + TestSecretSettings secretSettings ) { - super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, secretSettings, endpointVersion); + super(inferenceEntityId, taskType, service, serviceSettings, taskSettings, secretSettings); this.resultMap = new HashMap<>(); } @@ -396,8 +394,7 @@ public static StaticModel createRandomInstance() { randomAlphaOfLength(10), testModel.getServiceSettings(), testModel.getTaskSettings(), - testModel.getSecretSettings(), - EndpointVersions.FIRST_ENDPOINT_VERSION + testModel.getSecretSettings() ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java index bb9a3bbf10cb1..fbd013341db94 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockRequest; @@ -476,8 +475,7 @@ public void testInfer_AzureOpenAiCompletion_WithOverriddenUser() throws IOExcept originalUser, apiKey, null, - "id", - EndpointVersions.FIRST_ENDPOINT_VERSION + "id" ); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); @@ -541,8 +539,7 @@ public void testInfer_AzureOpenAiCompletionModel_WithoutUser() throws IOExceptio null, apiKey, null, - "id", - EndpointVersions.FIRST_ENDPOINT_VERSION + "id" ); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); @@ -608,8 +605,7 @@ public void testInfer_AzureOpenAiCompletionModel_FailsFromInvalidResponseFormat( null, apiKey, null, - "id", - EndpointVersions.FIRST_ENDPOINT_VERSION + "id" ); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java index 4c64f14cad4f0..4c7683c882816 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiCompletionActionTests.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockResponse; @@ -195,16 +194,7 @@ private ExecutableAction createAction( String inferenceEntityId ) { try { - var model = createCompletionModel( - resourceName, - deploymentId, - apiVersion, - user, - apiKey, - null, - inferenceEntityId, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = createCompletionModel(resourceName, deploymentId, apiVersion, user, apiKey, null, inferenceEntityId); model.setUri(new URI(getUrl(webServer))); var requestCreator = new AzureOpenAiCompletionRequestManager(model, threadPool); var errorMessage = constructFailedToSendRequestMessage(model.getUri(), "Azure OpenAI completion"); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java index 855efe4632d83..f3ddf7f9299d9 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureaistudio/AzureAiStudioChatCompletionRequestTests.java @@ -10,7 +10,6 @@ import org.apache.http.HttpHeaders; import org.apache.http.client.methods.HttpPost; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.inference.external.request.HttpRequest; @@ -459,8 +458,7 @@ public static AzureAiStudioChatCompletionRequest createRequest( topP, doSample, maxNewTokens, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); return new AzureAiStudioChatCompletionRequest(model, List.of(input)); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java index b2abb4f267328..048d4ea16d56f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/azureopenai/completion/AzureOpenAiCompletionRequestTests.java @@ -9,7 +9,6 @@ import org.apache.http.HttpHeaders; import org.apache.http.client.methods.HttpPost; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xpack.inference.external.request.azureopenai.AzureOpenAiCompletionRequest; @@ -92,8 +91,7 @@ protected AzureOpenAiCompletionRequest createRequest( user, apiKey, entraId, - "id", - EndpointVersions.FIRST_ENDPOINT_VERSION + "id" ); return new AzureOpenAiCompletionRequest(List.of(input), completionModel); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java index 6131389263b49..49f3f9d48f187 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java @@ -12,7 +12,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -48,8 +47,7 @@ public static TestModel createRandomInstance(TaskType taskType) { randomAlphaOfLength(10), new TestModel.TestServiceSettings(randomAlphaOfLength(4), dimensions, similarity, elementType), new TestModel.TestTaskSettings(randomInt(3)), - new TestModel.TestSecretSettings(randomAlphaOfLength(4)), - EndpointVersions.FIRST_ENDPOINT_VERSION + new TestModel.TestSecretSettings(randomAlphaOfLength(4)) ); } @@ -59,11 +57,10 @@ public TestModel( String service, TestServiceSettings serviceSettings, TestTaskSettings taskSettings, - TestSecretSettings secretSettings, - EndpointVersions endpointVersion + TestSecretSettings secretSettings ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, endpointVersion), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secretSettings) ); } 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 2bc092b1684d9..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 @@ -22,7 +22,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; @@ -147,8 +146,8 @@ private void handleGetInferenceModelActionRequ request.getTaskType(), CohereService.NAME, new CohereRerankServiceSettings("uri", "model", null), - topN == null ? new EmptyTaskSettings() : new CohereRerankTaskSettings(topN, null, null), - EndpointVersions.FIRST_ENDPOINT_VERSION + topN == null ? new EmptyTaskSettings() : new CohereRerankTaskSettings(topN, null, null) + ) ) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java index c43f2dcefa042..de54d2ad6c0ac 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java @@ -22,7 +22,6 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.engine.VersionConflictEngineException; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.inference.UnparsedModel; import org.elasticsearch.search.SearchHit; @@ -301,8 +300,7 @@ public void testDeepCopyDefaultConfig() { randomFrom(TaskType.values()), "service-a", Map.of(), - Map.of(), - EndpointVersions.FIRST_ENDPOINT_VERSION + Map.of() ); var copied = ModelRegistry.deepCopyDefaultConfig(toCopy); assertThat(copied, not(sameInstance(toCopy))); @@ -331,8 +329,7 @@ public void testDeepCopyDefaultConfig() { randomFrom(TaskType.values()), "service-a", settings, - secretsMap, - EndpointVersions.FIRST_ENDPOINT_VERSION + secretsMap ); var copied = ModelRegistry.deepCopyDefaultConfig(toCopy); assertThat(copied, not(sameInstance(toCopy))); @@ -368,7 +365,7 @@ public void testDuplicateDefaultIds() { var id = "my-inference"; registry.addDefaultConfiguration( - new UnparsedModel(id, randomFrom(TaskType.values()), "service-a", Map.of(), Map.of(), EndpointVersions.FIRST_ENDPOINT_VERSION) + new UnparsedModel(id, randomFrom(TaskType.values()), "service-a", Map.of(), Map.of()) ); var ise = expectThrows( IllegalStateException.class, @@ -378,8 +375,7 @@ public void testDuplicateDefaultIds() { randomFrom(TaskType.values()), "service-b", Map.of(), - Map.of(), - EndpointVersions.FIRST_ENDPOINT_VERSION + Map.of() ) ) ); 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 4954186fae774..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 @@ -13,7 +13,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -138,7 +137,6 @@ public void parseRequestConfig( String inferenceEntityId, TaskType taskType, Map config, - EndpointVersions endpointVersion, ActionListener parsedModelListener ) { parsedModelListener.onResponse(null); @@ -149,19 +147,13 @@ public Model parsePersistedConfigWithSecrets( String inferenceEntityId, TaskType taskType, Map config, - Map secrets, - EndpointVersions endpointVersion + Map secretss ) { return null; } @Override - public Model parsePersistedConfig( - String inferenceEntityId, - TaskType taskType, - Map config, - EndpointVersions endpointVersion - ) { + public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { return null; } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java index 2fa3d76cf40c5..e8c34eec96171 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -95,7 +94,6 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModel() throws IOException AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -191,8 +189,7 @@ public void testChunkedInfer_Batches() throws IOException { serviceSettingsMap, taskSettingsMap, secretSettingsMap, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ) { public ExecutableAction accept( AlibabaCloudSearchActionVisitor visitor, 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 3556b54992931..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 @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.completion; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; @@ -48,8 +47,7 @@ public static AlibabaCloudSearchCompletionModel createModel( serviceSettings, taskSettings, secrets, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); } @@ -67,8 +65,7 @@ public static AlibabaCloudSearchCompletionModel createModel( AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, - secretSettings, - EndpointVersions.FIRST_ENDPOINT_VERSION + 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 da0614f3cbc32..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 @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; @@ -49,8 +48,7 @@ public static AlibabaCloudSearchEmbeddingsModel createModel( serviceSettings, taskSettings, secrets, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); } @@ -68,8 +66,7 @@ public static AlibabaCloudSearchEmbeddingsModel createModel( AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, - secretSettings, - EndpointVersions.FIRST_ENDPOINT_VERSION + secretSettings ); } } 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 59a5b481b4fef..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 @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.sparse; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; @@ -49,8 +48,7 @@ public static AlibabaCloudSearchSparseModel createModel( serviceSettings, taskSettings, secrets, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); } @@ -68,8 +66,7 @@ public static AlibabaCloudSearchSparseModel createModel( AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, - secretSettings, - EndpointVersions.FIRST_ENDPOINT_VERSION + secretSettings ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java index 136ec46714b98..088843669188b 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java @@ -16,7 +16,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -111,7 +110,6 @@ public void testParseRequestConfig_CreatesAnAmazonBedrockModel() throws IOExcept Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -135,7 +133,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -159,7 +156,6 @@ public void testCreateModel_ForEmbeddingsTask_InvalidProvider() throws IOExcepti Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -183,7 +179,6 @@ public void testCreateModel_TopKParameter_NotAvailable() throws IOException { getChatCompletionTaskSettingsMap(1.0, 0.5, 0.2, 128), getAmazonBedrockSecretSettingsMap("access", "secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -214,7 +209,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -241,7 +235,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -271,7 +264,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() "id", TaskType.COMPLETION, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -301,7 +293,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap "id", TaskType.COMPLETION, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -329,7 +320,6 @@ public void testParseRequestConfig_MovesModel() throws IOException { Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -353,7 +343,6 @@ public void testCreateModel_ForEmbeddingsTask_DimensionsIsNotAllowed() throws IO Map.of(), getAmazonBedrockSecretSettingsMap("access", "secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -370,8 +359,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnAmazonBedrockEmbeddings "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -399,8 +387,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ) ); @@ -423,8 +410,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -451,8 +437,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -479,8 +464,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -507,8 +491,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -536,8 +519,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); @@ -567,8 +549,7 @@ public void testParsePersistedConfig_CreatesAnAmazonBedrockEmbeddingsModel() thr var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -591,8 +572,7 @@ public void testParsePersistedConfig_CreatesAnAmazonBedrockChatCompletionModel() var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); @@ -622,8 +602,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro () -> service.parsePersistedConfig( "id", TaskType.SPARSE_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ) ); @@ -645,8 +624,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -671,8 +649,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -696,8 +673,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java index 7b700144f66ad..22173943ff432 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionModelTests.java @@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.amazonbedrock.AmazonBedrockProvider; @@ -215,8 +214,7 @@ public static AmazonBedrockChatCompletionModel createModel( "amazonbedrock", new AmazonBedrockChatCompletionServiceSettings(region, model, provider, rateLimitSettings), new AmazonBedrockChatCompletionTaskSettings(temperature, topP, topK, maxNewTokens), - new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)), - EndpointVersions.FIRST_ENDPOINT_VERSION + new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java index 78b8c775fc6ab..711e3cbb5a511 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/embeddings/AmazonBedrockEmbeddingsModelTests.java @@ -11,7 +11,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -76,8 +75,7 @@ public static AmazonBedrockEmbeddingsModel createModel( rateLimitSettings ), new EmptyTaskSettings(), - new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)), - EndpointVersions.FIRST_ENDPOINT_VERSION + new AmazonBedrockSecretSettings(new SecureString(accessKey), new SecureString(secretKey)) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java index ad66725a7269c..d7eeaca036082 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -108,7 +107,6 @@ public void testParseRequestConfig_CreatesACompletionModel() throws IOException new HashMap<>(Map.of(AnthropicServiceFields.MAX_TOKENS, 1)), getSecretSettingsMap(apiKey) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -129,7 +127,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -148,7 +145,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); } } @@ -167,7 +164,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); } } @@ -186,7 +183,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); } } @@ -205,7 +202,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [anthropic] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); } } @@ -224,8 +221,7 @@ public void testParsePersistedConfigWithSecrets_CreatesACompletionModel() throws "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -253,8 +249,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -284,8 +279,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -315,8 +309,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -346,8 +339,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -371,8 +363,7 @@ public void testParsePersistedConfig_CreatesACompletionModel() throws IOExceptio var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -397,8 +388,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -425,8 +415,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -450,8 +439,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); 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 3810743b9f4f7..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 @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.anthropic.completion; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings; @@ -53,8 +52,7 @@ public static AnthropicChatCompletionModel createChatCompletionModel(String url, url, new AnthropicChatCompletionServiceSettings(modelName, null), new AnthropicChatCompletionTaskSettings(maxTokens, null, null, null), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -66,8 +64,7 @@ public static AnthropicChatCompletionModel createChatCompletionModel(String apiK "service", new AnthropicChatCompletionServiceSettings(modelName, null), new AnthropicChatCompletionTaskSettings(maxTokens, null, null, null), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + 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 378d46855e6d5..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 @@ -18,7 +18,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -120,7 +119,6 @@ public void testParseRequestConfig_CreatesAnAzureAiStudioEmbeddingsModel() throw getEmbeddingsTaskSettingsMap("user"), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -148,7 +146,6 @@ public void testParseRequestConfig_CreatesAnAzureAiStudioChatCompletionModel() t getChatCompletionTaskSettingsMap(null, null, true, null), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -172,7 +169,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getChatCompletionTaskSettingsMap(null, null, true, null), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -198,13 +194,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig( - "id", - TaskType.COMPLETION, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); } } @@ -226,13 +216,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingServiceS } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -255,13 +239,7 @@ public void testParseRequestConfig_ThrowsWhenDimsSetByUserExistsInEmbeddingServi } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -287,13 +265,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingTaskSett } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -319,13 +291,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingSecretSe } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -351,13 +317,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInChatCompletionSer } ); - service.parseRequestConfig( - "id", - TaskType.COMPLETION, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); } } @@ -383,13 +343,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInChatCompletionTas } ); - service.parseRequestConfig( - "id", - TaskType.COMPLETION, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); } } @@ -415,13 +369,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInChatCompletionSec } ); - service.parseRequestConfig( - "id", - TaskType.COMPLETION, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); } } @@ -439,13 +387,7 @@ public void testParseRequestConfig_ThrowsWhenProviderIsNotValidForEmbeddings() t } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -466,13 +408,7 @@ public void testParseRequestConfig_ThrowsWhenEndpointTypeIsNotValidForEmbeddings } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -497,13 +433,7 @@ public void testParseRequestConfig_ThrowsWhenEndpointTypeIsNotValidForChatComple } ); - service.parseRequestConfig( - "id", - TaskType.COMPLETION, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); } } @@ -515,13 +445,7 @@ public void testParsePersistedConfig_CreatesAnAzureAiStudioEmbeddingsModel() thr getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -545,13 +469,7 @@ public void testParsePersistedConfig_CreatesAnAzureAiStudioChatCompletionModel() getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.COMPLETION, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.COMPLETION, config.config(), config.secrets()); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); @@ -584,7 +502,6 @@ public void testParsePersistedConfig_ThrowsUnsupportedModelType() throws IOExcep getChatCompletionTaskSettingsMap(null, null, true, null), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -600,13 +517,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfigWithSecrets( - "id", - TaskType.SPARSE_EMBEDDING, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ) + () -> service.parsePersistedConfigWithSecrets("id", TaskType.SPARSE_EMBEDDING, config.config(), config.secrets()) ); assertThat( @@ -624,13 +535,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); config.config().put("extra_key", "value"); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); } @@ -645,13 +550,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenExtraKeyExistsInEmbeddingSe var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); } @@ -666,13 +565,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); } @@ -687,13 +580,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); } @@ -707,13 +594,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInChatCompl var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.COMPLETION, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.COMPLETION, config.config(), config.secrets()); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); } @@ -727,13 +608,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInChatCompl var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.COMPLETION, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.COMPLETION, config.config(), config.secrets()); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); } @@ -747,13 +622,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInChatCompl secretSettings.put("extra_key", "value"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.COMPLETION, - config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.COMPLETION, config.config(), config.secrets()); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); } @@ -767,12 +636,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesEmbeddingsModel() thro Map.of() ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); @@ -795,7 +659,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesChatCompletionModel() Map.of() ); - var model = service.parsePersistedConfig("id", TaskType.COMPLETION, config.config(), EndpointVersions.FIRST_ENDPOINT_VERSION); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, config.config()); assertThat(model, instanceOf(AzureAiStudioChatCompletionModel.class)); @@ -915,8 +779,7 @@ public void testCheckModelConfig_WorksForChatCompletionsModel() throws IOExcepti null, null, null, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); PlainActionFuture listener = new PlainActionFuture<>(); @@ -936,8 +799,8 @@ public void testCheckModelConfig_WorksForChatCompletionsModel() throws IOExcepti null, null, AzureAiStudioChatCompletionTaskSettings.DEFAULT_MAX_NEW_TOKENS, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null + ) ) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java index bd3e5cea349a2..bd34a34285cf2 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionModelTests.java @@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.azureaistudio.AzureAiStudioEndpointType; @@ -36,8 +35,7 @@ public void testOverrideWith_OverridesWithoutValues() { 2.0, false, 512, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); var requestTaskSettingsMap = getTaskSettingsMap(null, null, null, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettingsMap); @@ -56,8 +54,7 @@ public void testOverrideWith_temperature() { null, null, null, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); var requestTaskSettings = getTaskSettingsMap(0.5, null, null, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -74,8 +71,7 @@ public void testOverrideWith_temperature() { null, null, null, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ) ) ); @@ -92,8 +88,7 @@ public void testOverrideWith_topP() { 0.8, null, null, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); var requestTaskSettings = getTaskSettingsMap(null, 0.5, null, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -110,8 +105,7 @@ public void testOverrideWith_topP() { 0.5, null, null, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ) ) ); @@ -128,8 +122,7 @@ public void testOverrideWith_doSample() { null, true, null, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); var requestTaskSettings = getTaskSettingsMap(null, null, false, null); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -146,8 +139,7 @@ public void testOverrideWith_doSample() { null, false, null, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ) ) ); @@ -164,8 +156,7 @@ public void testOverrideWith_maxNewTokens() { null, null, 512, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ); var requestTaskSettings = getTaskSettingsMap(null, null, null, 128); var overriddenModel = AzureAiStudioChatCompletionModel.of(model, requestTaskSettings); @@ -182,8 +173,7 @@ public void testOverrideWith_maxNewTokens() { null, null, 128, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION + null ) ) ); @@ -217,19 +207,7 @@ public static AzureAiStudioChatCompletionModel createModel( AzureAiStudioEndpointType endpointType, String apiKey ) { - return createModel( - id, - target, - provider, - endpointType, - apiKey, - null, - null, - null, - null, - null, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + return createModel(id, target, provider, endpointType, apiKey, null, null, null, null, null); } public static AzureAiStudioChatCompletionModel createModel( @@ -242,8 +220,7 @@ public static AzureAiStudioChatCompletionModel createModel( @Nullable Double topP, @Nullable Boolean doSample, @Nullable Integer maxNewTokens, - @Nullable RateLimitSettings rateLimitSettings, - EndpointVersions endpointVersion + @Nullable RateLimitSettings rateLimitSettings ) { return new AzureAiStudioChatCompletionModel( id, @@ -251,8 +228,7 @@ public static AzureAiStudioChatCompletionModel createModel( "azureaistudio", new AzureAiStudioChatCompletionServiceSettings(target, provider, endpointType, rateLimitSettings), new AzureAiStudioChatCompletionTaskSettings(temperature, topP, doSample, maxNewTokens), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - endpointVersion + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java index 4412c00fdfda7..5a450f03b4e01 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java @@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -133,8 +132,7 @@ public static AzureAiStudioEmbeddingsModel createModel( rateLimitSettings ), new AzureAiStudioEmbeddingsTaskSettings(user), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java index ed3600aca3a83..53a984392d650 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java @@ -18,7 +18,6 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -118,7 +117,6 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModel() throws IOExc getAzureOpenAiRequestTaskSettingsMap("user"), getAzureOpenAiSecretSettingsMap("secret", null) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -142,7 +140,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getAzureOpenAiRequestTaskSettingsMap("user"), getAzureOpenAiSecretSettingsMap("secret", null) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -172,7 +169,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -203,7 +199,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -234,7 +229,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -265,7 +259,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -292,7 +285,6 @@ public void testParseRequestConfig_MovesModel() throws IOException { getAzureOpenAiRequestTaskSettingsMap("user"), getAzureOpenAiSecretSettingsMap("secret", null) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -310,8 +302,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnAzureOpenAiEmbeddingsMo "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -341,8 +332,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ) ); @@ -366,8 +356,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -398,8 +387,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -428,8 +416,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -460,8 +447,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -492,8 +478,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -519,8 +504,7 @@ public void testParsePersistedConfig_CreatesAnAzureOpenAiEmbeddingsModel() throw var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -546,8 +530,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro () -> service.parsePersistedConfig( "id", TaskType.SPARSE_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ) ); @@ -569,8 +552,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -600,8 +582,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -628,8 +609,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); 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 6373d470da50c..438cfda602ab0 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 @@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.azureopenai.AzureOpenAiSecretSettings; @@ -43,8 +42,7 @@ public void testOverrideWith_UpdatedTaskSettings_OverridesUser() { user, apiKey, entraId, - inferenceEntityId, - EndpointVersions.FIRST_ENDPOINT_VERSION + inferenceEntityId ); var requestTaskSettingsMap = taskSettingsMap(userOverride); var overriddenModel = AzureOpenAiCompletionModel.of(model, requestTaskSettingsMap); @@ -59,8 +57,7 @@ public void testOverrideWith_UpdatedTaskSettings_OverridesUser() { userOverride, apiKey, entraId, - inferenceEntityId, - EndpointVersions.FIRST_ENDPOINT_VERSION + inferenceEntityId ) ) ); @@ -74,8 +71,7 @@ public void testOverrideWith_EmptyMap_OverridesNothing() { "user", "api key", "entra id", - "inference entity id", - EndpointVersions.FIRST_ENDPOINT_VERSION + "inference entity id" ); var requestTaskSettingsMap = Map.of(); @@ -92,8 +88,7 @@ public void testOverrideWith_NullMap_OverridesNothing() { "user", "api key", "entra id", - "inference entity id", - EndpointVersions.FIRST_ENDPOINT_VERSION + "inference entity id" ); var overriddenModel = AzureOpenAiCompletionModel.of(model, null); @@ -121,8 +116,7 @@ public void testOverrideWith_UpdatedServiceSettings_OverridesApiVersion() { user, apiKey, entraId, - inferenceEntityId, - EndpointVersions.FIRST_ENDPOINT_VERSION + inferenceEntityId ); var overriddenModel = new AzureOpenAiCompletionModel(model, updatedServiceSettings); @@ -136,8 +130,7 @@ public void testOverrideWith_UpdatedServiceSettings_OverridesApiVersion() { user, apiKey, entraId, - inferenceEntityId, - EndpointVersions.FIRST_ENDPOINT_VERSION + inferenceEntityId ) ) ); @@ -159,8 +152,7 @@ public void testBuildUriString() throws URISyntaxException { user, apiKey, entraId, - inferenceEntityId, - EndpointVersions.FIRST_ENDPOINT_VERSION + inferenceEntityId ); assertThat( @@ -177,8 +169,7 @@ public static AzureOpenAiCompletionModel createModelWithRandomValues() { randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10), - randomAlphaOfLength(10), - EndpointVersions.FIRST_ENDPOINT_VERSION + randomAlphaOfLength(10) ); } @@ -190,8 +181,7 @@ public static AzureOpenAiCompletionModel createCompletionModel( String user, @Nullable String apiKey, @Nullable String entraId, - String inferenceEntityId, - EndpointVersions endpointVersion + String inferenceEntityId ) { var secureApiKey = apiKey != null ? new SecureString(apiKey.toCharArray()) : null; var secureEntraId = entraId != null ? new SecureString(entraId.toCharArray()) : null; @@ -202,8 +192,7 @@ public static AzureOpenAiCompletionModel createCompletionModel( "service", new AzureOpenAiCompletionServiceSettings(resourceName, deploymentId, apiVersion, null), new AzureOpenAiCompletionTaskSettings(user), - new AzureOpenAiSecretSettings(secureApiKey, secureEntraId), - EndpointVersions.FIRST_ENDPOINT_VERSION + new AzureOpenAiSecretSettings(secureApiKey, secureEntraId) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java index 295d28db47146..1747155623a98 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsModelTests.java @@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -113,8 +112,7 @@ public static AzureOpenAiEmbeddingsModel createModel( "service", new AzureOpenAiEmbeddingsServiceSettings(resourceName, deploymentId, apiVersion, null, false, null, null, null), new AzureOpenAiEmbeddingsTaskSettings(user), - new AzureOpenAiSecretSettings(secureApiKey, secureEntraId), - EndpointVersions.FIRST_ENDPOINT_VERSION + new AzureOpenAiSecretSettings(secureApiKey, secureEntraId) ); } @@ -149,8 +147,7 @@ public static AzureOpenAiEmbeddingsModel createModel( null ), new AzureOpenAiEmbeddingsTaskSettings(user), - new AzureOpenAiSecretSettings(secureApiKey, secureEntraId), - EndpointVersions.FIRST_ENDPOINT_VERSION + new AzureOpenAiSecretSettings(secureApiKey, secureEntraId) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java index c680a12d94a9d..fc456fcd70c2f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java @@ -19,7 +19,6 @@ import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -123,7 +122,6 @@ public void testParseRequestConfig_CreatesACohereEmbeddingsModel() throws IOExce getTaskSettingsMap(InputType.INGEST, CohereTruncation.START), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); @@ -151,7 +149,6 @@ public void testParseRequestConfig_OptionalTaskSettings() throws IOException { CohereEmbeddingsServiceSettingsTests.getServiceSettingsMap("url", "model", CohereEmbeddingType.FLOAT), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); @@ -173,7 +170,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getTaskSettingsMapEmpty(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -199,7 +195,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); } } @@ -214,7 +210,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); } } @@ -233,7 +229,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); } } @@ -253,7 +249,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [cohere] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); } } @@ -276,7 +272,6 @@ public void testParseRequestConfig_CreatesACohereEmbeddingsModelWithoutUrl() thr getTaskSettingsMapEmpty(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); @@ -295,8 +290,7 @@ public void testParsePersistedConfigWithSecrets_CreatesACohereEmbeddingsModel() "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -323,8 +317,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ) ); @@ -347,8 +340,7 @@ public void testParsePersistedConfigWithSecrets_CreatesACohereEmbeddingsModelWit "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -373,8 +365,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -406,8 +397,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -432,8 +422,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -457,8 +446,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -485,8 +473,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -509,8 +496,7 @@ public void testParsePersistedConfig_CreatesACohereEmbeddingsModel() throws IOEx var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -535,8 +521,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro () -> service.parsePersistedConfig( "id", TaskType.SPARSE_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ) ); @@ -557,8 +542,7 @@ public void testParsePersistedConfig_CreatesACohereEmbeddingsModelWithoutUrl() t var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -583,8 +567,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -606,8 +589,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -632,8 +614,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); 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 ae92024a14367..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 @@ -10,7 +10,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.ConfigurationParseContext; @@ -31,8 +30,7 @@ public void testCreateModel_AlwaysWithEmptyTaskSettings() { new HashMap<>(Map.of()), new HashMap<>(Map.of("model", "overridden model")), null, - ConfigurationParseContext.PERSISTENT, - EndpointVersions.FIRST_ENDPOINT_VERSION + ConfigurationParseContext.PERSISTENT ); @@ -46,8 +44,7 @@ public static CohereCompletionModel createModel(String url, String apiKey, @Null "service", new CohereCompletionServiceSettings(url, model, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + 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 8a722651f55e0..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 @@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; @@ -223,8 +222,7 @@ public static CohereEmbeddingsModel createModel( Objects.requireNonNullElse(embeddingType, CohereEmbeddingType.FLOAT) ), taskSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -247,8 +245,7 @@ public static CohereEmbeddingsModel createModel( Objects.requireNonNullElse(embeddingType, CohereEmbeddingType.FLOAT) ), taskSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java index fdf8e033f98b8..c9f4234331221 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSparseEmbeddingsModelTests.java @@ -9,7 +9,6 @@ import org.elasticsearch.inference.EmptySecretSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.elasticsearch.ElserModels; @@ -28,8 +27,7 @@ public static ElasticInferenceServiceSparseEmbeddingsModel createModel(String ur new ElasticInferenceServiceSparseEmbeddingsServiceSettings(ElserModels.ELSER_V2_MODEL, maxInputTokens, null), EmptyTaskSettings.INSTANCE, EmptySecretSettings.INSTANCE, - new ElasticInferenceServiceComponents(url), - EndpointVersions.FIRST_ENDPOINT_VERSION + new ElasticInferenceServiceComponents(url) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java index 80279eee3eadc..d10c70c6f0f5e 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceTests.java @@ -17,7 +17,6 @@ import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.EmptySecretSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -104,7 +103,6 @@ public void testParseRequestConfig_CreatesASparseEmbeddingsModel() throws IOExce "id", TaskType.SPARSE_EMBEDDING, getRequestConfigMap(Map.of(ServiceFields.MODEL_ID, ElserModels.ELSER_V2_MODEL), Map.of(), Map.of()), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -121,7 +119,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti "id", TaskType.COMPLETION, getRequestConfigMap(Map.of(ServiceFields.MODEL_ID, ElserModels.ELSER_V2_MODEL), Map.of(), Map.of()), - EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -136,7 +133,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, failureListener); } } @@ -151,7 +148,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, failureListener); } } @@ -165,7 +162,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, failureListener); } } @@ -179,7 +176,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [elastic] service" ); - service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.SPARSE_EMBEDDING, config, failureListener); } } @@ -195,8 +192,7 @@ public void testParsePersistedConfigWithSecrets_CreatesASparseEmbeddingModel() t "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -221,8 +217,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -245,8 +240,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -272,8 +266,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); @@ -299,8 +292,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(ElasticInferenceServiceSparseEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java index eb7f0f030f42b..cd6da4c0ad8d8 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalServiceTests.java @@ -21,7 +21,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceResults; import org.elasticsearch.inference.InferenceServiceExtension; import org.elasticsearch.inference.InputType; @@ -119,7 +118,7 @@ public void testParseRequestConfig() { ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - service.parseRequestConfig(randomInferenceEntityId, taskType, config, EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener); + service.parseRequestConfig(randomInferenceEntityId, taskType, config, modelListener); } public void testParseRequestConfig_Misconfigured() { @@ -141,7 +140,7 @@ public void testParseRequestConfig_Misconfigured() { ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - service.parseRequestConfig(randomInferenceEntityId, taskType, config, EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener); + service.parseRequestConfig(randomInferenceEntityId, taskType, config, modelListener); } // Invalid config map @@ -163,7 +162,7 @@ public void testParseRequestConfig_Misconfigured() { ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - service.parseRequestConfig(randomInferenceEntityId, taskType, config, EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener); + service.parseRequestConfig(randomInferenceEntityId, taskType, config, modelListener); } } @@ -191,7 +190,6 @@ public void testParseRequestConfig_E5() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, - EndpointVersions.FIRST_ENDPOINT_VERSION, getE5ModelVerificationActionListener(e5ServiceSettings) ); } @@ -224,7 +222,6 @@ public void testParseRequestConfig_E5() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, - EndpointVersions.FIRST_ENDPOINT_VERSION, getE5ModelVerificationActionListener(e5ServiceSettings) ); } @@ -254,13 +251,7 @@ public void testParseRequestConfig_E5() { e -> assertThat(e, instanceOf(ElasticsearchStatusException.class)) ); - service.parseRequestConfig( - randomInferenceEntityId, - TaskType.TEXT_EMBEDDING, - settings, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelListener - ); + service.parseRequestConfig(randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings, modelListener); } } @@ -292,7 +283,6 @@ public void testParseRequestConfig_elser() { randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, getElserModelVerificationActionListener( elserServiceSettings, null, @@ -328,7 +318,6 @@ public void testParseRequestConfig_elser() { randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, getElserModelVerificationActionListener(elserServiceSettings, criticalWarning, warnWarning) ); assertWarnings(true, new DeprecationWarning(DeprecationLogger.CRITICAL, criticalWarning)); @@ -362,13 +351,7 @@ public void testParseRequestConfig_elser() { e -> assertThat(e, instanceOf(ElasticsearchStatusException.class)) ); - service.parseRequestConfig( - randomInferenceEntityId, - TaskType.SPARSE_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelListener - ); + service.parseRequestConfig(randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, config, modelListener); } } @@ -415,13 +398,7 @@ public void testParseRequestConfig_Rerank() { assertEquals(returnDocs, ((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); }, e -> { fail("Model parsing failed " + e.getMessage()); }); - service.parseRequestConfig( - randomInferenceEntityId, - TaskType.RERANK, - settings, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelListener - ); + service.parseRequestConfig(randomInferenceEntityId, TaskType.RERANK, settings, modelListener); } } @@ -463,13 +440,7 @@ public void testParseRequestConfig_Rerank_DefaultTaskSettings() { assertEquals(Boolean.TRUE, ((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); }, e -> { fail("Model parsing failed " + e.getMessage()); }); - service.parseRequestConfig( - randomInferenceEntityId, - TaskType.RERANK, - settings, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelListener - ); + service.parseRequestConfig(randomInferenceEntityId, TaskType.RERANK, settings, modelListener); } } @@ -508,13 +479,7 @@ public void testParseRequestConfig_SparseEmbedding() { assertThat(model.getServiceSettings(), instanceOf(CustomElandInternalServiceSettings.class)); }, e -> { fail("Model parsing failed " + e.getMessage()); }); - service.parseRequestConfig( - randomInferenceEntityId, - TaskType.SPARSE_EMBEDDING, - settings, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelListener - ); + service.parseRequestConfig(randomInferenceEntityId, TaskType.SPARSE_EMBEDDING, settings, modelListener); } private ActionListener getE5ModelVerificationActionListener(MultilingualE5SmallInternalServiceSettings e5ServiceSettings) { @@ -524,8 +489,7 @@ private ActionListener getE5ModelVerificationActionListener(MultilingualE randomInferenceEntityId, TaskType.TEXT_EMBEDDING, ElasticsearchInternalService.NAME, - e5ServiceSettings, - EndpointVersions.FIRST_ENDPOINT_VERSION + e5ServiceSettings ), model ); @@ -549,8 +513,7 @@ private ActionListener getElserModelVerificationActionListener( TaskType.SPARSE_EMBEDDING, NAME, elserServiceSettings, - ElserMlNodeTaskSettings.DEFAULT, - EndpointVersions.FIRST_ENDPOINT_VERSION + ElserMlNodeTaskSettings.DEFAULT ), model ); @@ -579,12 +542,7 @@ public void testParsePersistedConfig() { expectThrows( IllegalArgumentException.class, - () -> service.parsePersistedConfig( - randomInferenceEntityId, - TaskType.TEXT_EMBEDDING, - settings, - EndpointVersions.FIRST_ENDPOINT_VERSION - ) + () -> service.parsePersistedConfig(randomInferenceEntityId, TaskType.TEXT_EMBEDDING, settings) ); } @@ -612,8 +570,7 @@ public void testParsePersistedConfig() { CustomElandEmbeddingModel parsedModel = (CustomElandEmbeddingModel) service.parsePersistedConfig( randomInferenceEntityId, TaskType.TEXT_EMBEDDING, - settings, - EndpointVersions.FIRST_ENDPOINT_VERSION + settings ); var elandServiceSettings = new CustomElandInternalTextEmbeddingServiceSettings(1, 4, "invalid", null); assertEquals( @@ -621,8 +578,7 @@ public void testParsePersistedConfig() { randomInferenceEntityId, TaskType.TEXT_EMBEDDING, ElasticsearchInternalService.NAME, - elandServiceSettings, - EndpointVersions.FIRST_ENDPOINT_VERSION + elandServiceSettings ), parsedModel ); @@ -653,16 +609,14 @@ public void testParsePersistedConfig() { MultilingualE5SmallModel parsedModel = (MultilingualE5SmallModel) service.parsePersistedConfig( randomInferenceEntityId, TaskType.TEXT_EMBEDDING, - settings, - EndpointVersions.FIRST_ENDPOINT_VERSION + settings ); assertEquals( new MultilingualE5SmallModel( randomInferenceEntityId, TaskType.TEXT_EMBEDDING, ElasticsearchInternalService.NAME, - e5ServiceSettings, - EndpointVersions.FIRST_ENDPOINT_VERSION + e5ServiceSettings ), parsedModel ); @@ -681,10 +635,7 @@ public void testParsePersistedConfig() { settings.put("not_a_valid_config_setting", randomAlphaOfLength(10)); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - expectThrows( - IllegalArgumentException.class, - () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings, EndpointVersions.FIRST_ENDPOINT_VERSION) - ); + expectThrows(IllegalArgumentException.class, () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings)); } // Invalid service settings @@ -705,10 +656,7 @@ public void testParsePersistedConfig() { ) ); var taskType = randomFrom(TaskType.TEXT_EMBEDDING, TaskType.RERANK, TaskType.SPARSE_EMBEDDING); - expectThrows( - IllegalArgumentException.class, - () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings, EndpointVersions.FIRST_ENDPOINT_VERSION) - ); + expectThrows(IllegalArgumentException.class, () -> service.parsePersistedConfig(randomInferenceEntityId, taskType, settings)); } } @@ -733,8 +681,7 @@ public void testChunkInfer_e5() { "foo", TaskType.TEXT_EMBEDDING, "e5", - new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null), - EndpointVersions.FIRST_ENDPOINT_VERSION + new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null) ); var service = createService(client); @@ -822,8 +769,7 @@ public void testChunkInfer_Sparse() { "foo", TaskType.SPARSE_EMBEDDING, "elasticsearch", - new ElasticsearchInternalServiceSettings(1, 1, "model-id", null), - EndpointVersions.FIRST_ENDPOINT_VERSION + new ElasticsearchInternalServiceSettings(1, 1, "model-id", null) ); var service = createService(client); @@ -886,8 +832,7 @@ public void testChunkInferSetsTokenization() { "foo", TaskType.TEXT_EMBEDDING, "e5", - new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null), - EndpointVersions.FIRST_ENDPOINT_VERSION + new MultilingualE5SmallInternalServiceSettings(1, 1, "cross-platform", null) ); var service = createService(client); @@ -944,12 +889,7 @@ public void testParsePersistedConfig_Rerank() { new HashMap<>(Map.of(CustomElandRerankTaskSettings.RETURN_DOCUMENTS, returnDocs)) ); - var model = service.parsePersistedConfig( - randomInferenceEntityId, - TaskType.RERANK, - settings, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfig(randomInferenceEntityId, TaskType.RERANK, settings); assertThat(model.getTaskSettings(), instanceOf(CustomElandRerankTaskSettings.class)); assertEquals(returnDocs, ((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); } @@ -973,12 +913,7 @@ public void testParsePersistedConfig_Rerank() { ); settings.put(ElasticsearchInternalServiceSettings.MODEL_ID, "foo"); - var model = service.parsePersistedConfig( - randomInferenceEntityId, - TaskType.RERANK, - settings, - EndpointVersions.FIRST_ENDPOINT_VERSION - ); + var model = service.parsePersistedConfig(randomInferenceEntityId, TaskType.RERANK, settings); assertThat(model.getTaskSettings(), instanceOf(CustomElandRerankTaskSettings.class)); assertTrue(((CustomElandRerankTaskSettings) model.getTaskSettings()).returnDocuments()); } @@ -1017,7 +952,7 @@ public void testParseRequestConfigEland_PreservesTaskType() { CustomElandModel expectedModel = getCustomElandModel(taskType); PlainActionFuture listener = new PlainActionFuture<>(); - service.parseRequestConfig(randomInferenceEntityId, taskType, settings, EndpointVersions.FIRST_ENDPOINT_VERSION, listener); + service.parseRequestConfig(randomInferenceEntityId, taskType, settings, listener); var model = listener.actionGet(TimeValue.THIRTY_SECONDS); assertThat(model, is(expectedModel)); } @@ -1030,8 +965,7 @@ private CustomElandModel getCustomElandModel(TaskType taskType) { taskType, ElasticsearchInternalService.NAME, new CustomElandInternalServiceSettings(1, 4, "custom-model", null), - CustomElandRerankTaskSettings.DEFAULT_SETTINGS, - EndpointVersions.FIRST_ENDPOINT_VERSION + CustomElandRerankTaskSettings.DEFAULT_SETTINGS ); } else if (taskType == TaskType.TEXT_EMBEDDING) { var serviceSettings = new CustomElandInternalTextEmbeddingServiceSettings(1, 4, "custom-model", null); @@ -1040,16 +974,14 @@ private CustomElandModel getCustomElandModel(TaskType taskType) { randomInferenceEntityId, taskType, ElasticsearchInternalService.NAME, - serviceSettings, - EndpointVersions.FIRST_ENDPOINT_VERSION + serviceSettings ); } else if (taskType == TaskType.SPARSE_EMBEDDING) { expectedModel = new CustomElandModel( randomInferenceEntityId, taskType, ElasticsearchInternalService.NAME, - new CustomElandInternalServiceSettings(1, 4, "custom-model", null), - EndpointVersions.FIRST_ENDPOINT_VERSION + new CustomElandInternalServiceSettings(1, 4, "custom-model", null) ); } return expectedModel; @@ -1099,8 +1031,7 @@ public void testPutModel() { "my-e5", TaskType.TEXT_EMBEDDING, "e5", - new MultilingualE5SmallInternalServiceSettings(1, 1, ".multilingual-e5-small", null), - EndpointVersions.FIRST_ENDPOINT_VERSION + new MultilingualE5SmallInternalServiceSettings(1, 1, ".multilingual-e5-small", null) ); service.putModel(model, new ActionListener<>() { @@ -1151,8 +1082,7 @@ public void testParseRequestConfigEland_SetsDimensionsToOne() { randomInferenceEntityId, taskType, ElasticsearchInternalService.NAME, - serviceSettings, - EndpointVersions.FIRST_ENDPOINT_VERSION + serviceSettings ); PlainActionFuture listener = new PlainActionFuture<>(); @@ -1169,8 +1099,7 @@ public void testParseRequestConfigEland_SetsDimensionsToOne() { null, SimilarityMeasure.COSINE, DenseVectorFieldMapper.ElementType.FLOAT - ), - EndpointVersions.FIRST_ENDPOINT_VERSION + ) ), listener ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java index 4e9c298ee4de4..f8c04f6cd2690 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java @@ -19,7 +19,6 @@ import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -126,7 +125,6 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioCompletionModel() throw new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -153,7 +151,6 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioEmbeddingsModel() throw new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -182,7 +179,6 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin createRandomChunkingSettingsMap(), getSecretSettingsMap(apiKey) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -213,7 +209,6 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenChun createRandomChunkingSettingsMap(), getSecretSettingsMap(apiKey) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -243,7 +238,6 @@ public void testParseRequestConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenChun new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -264,7 +258,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -283,7 +276,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); } } @@ -298,7 +291,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); } } @@ -317,7 +310,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); } } @@ -336,7 +329,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googleaistudio] service" ); - service.parseRequestConfig("id", TaskType.COMPLETION, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.COMPLETION, config, failureListener); } } @@ -355,8 +348,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioCompletion "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -383,8 +375,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioEmbeddings "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -414,8 +405,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioEmbeddings "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -446,8 +436,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAGoogleAiStudioEmbeddings "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -477,8 +466,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChun "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -507,8 +495,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -538,8 +525,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -565,8 +551,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -596,8 +581,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.COMPLETION, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -618,8 +602,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioCompletionModel() thr var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -646,8 +629,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiEmbeddingsModelWithoutChunk var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -675,8 +657,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenCh var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -700,8 +681,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenCh var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -724,8 +704,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -749,8 +728,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -774,8 +752,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti var model = service.parsePersistedConfig( "id", TaskType.COMPLETION, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); 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 55bbf767faf81..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 @@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.ConfigurationParseContext; @@ -31,8 +30,7 @@ public void testCreateModel_AlwaysWithEmptyTaskSettings() { new HashMap<>(Map.of("model_id", "model")), new HashMap<>(Map.of()), null, - ConfigurationParseContext.PERSISTENT, - EndpointVersions.FIRST_ENDPOINT_VERSION + ConfigurationParseContext.PERSISTENT ); assertThat(model.getTaskSettings(), is(EmptyTaskSettings.INSTANCE)); @@ -52,8 +50,7 @@ public static GoogleAiStudioCompletionModel createModel(String model, String api "service", new GoogleAiStudioCompletionServiceSettings(model, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -65,8 +62,7 @@ public static GoogleAiStudioCompletionModel createModel(String model, String url url, new GoogleAiStudioCompletionServiceSettings(model, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + 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 9f4255bb4c9e0..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 @@ -11,7 +11,6 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -27,8 +26,7 @@ public static GoogleAiStudioEmbeddingsModel createModel(String model, String api url, new GoogleAiStudioEmbeddingsServiceSettings(model, null, null, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -41,8 +39,7 @@ public static GoogleAiStudioEmbeddingsModel createModel(String model, ChunkingSe new GoogleAiStudioEmbeddingsServiceSettings(model, null, null, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, chunkingSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -60,8 +57,7 @@ public static GoogleAiStudioEmbeddingsModel createModel( url, new GoogleAiStudioEmbeddingsServiceSettings(model, null, dimensions, similarityMeasure, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -79,8 +75,7 @@ public static GoogleAiStudioEmbeddingsModel createModel( new GoogleAiStudioEmbeddingsServiceSettings(model, tokenLimit, dimensions, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java index ad425b04bc3be..8aca5608f4638 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java @@ -10,7 +10,6 @@ import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; @@ -103,7 +102,6 @@ public void testParseRequestConfig_CreatesGoogleVertexAiEmbeddingsModel() throws new HashMap<>(Map.of()), getSecretSettingsMap(serviceAccountJson) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -135,7 +133,6 @@ public void testParseRequestConfig_CreatesGoogleVertexAiRerankModel() throws IOE new HashMap<>(Map.of()), getSecretSettingsMap(serviceAccountJson) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -165,7 +162,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("{}") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -193,7 +189,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); } } @@ -217,7 +213,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); } } @@ -245,7 +241,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); } } @@ -273,7 +269,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [googlevertexai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); } } @@ -310,8 +306,7 @@ public void testParsePersistedConfigWithSecrets_CreatesGoogleVertexAiEmbeddingsM "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -346,8 +341,7 @@ public void testParsePersistedConfigWithSecrets_CreatesGoogleVertexAiRerankModel "id", TaskType.RERANK, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleVertexAiRerankModel.class)); @@ -393,8 +387,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -445,8 +438,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -497,8 +489,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); @@ -549,8 +540,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); 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 f4f849ba6ff2a..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 @@ -10,7 +10,6 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -60,8 +59,7 @@ public static GoogleVertexAiEmbeddingsModel createModel( uri, new GoogleVertexAiEmbeddingsServiceSettings(location, projectId, modelId, false, null, null, null, null), new GoogleVertexAiEmbeddingsTaskSettings(Boolean.FALSE), - new GoogleVertexAiSecretSettings(new SecureString(serviceAccountJson.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new GoogleVertexAiSecretSettings(new SecureString(serviceAccountJson.toCharArray())) ); } @@ -82,8 +80,7 @@ public static GoogleVertexAiEmbeddingsModel createModel(String modelId, @Nullabl null ), new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate), - new GoogleVertexAiSecretSettings(new SecureString(randomAlphaOfLength(8).toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + 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 1193b9e671dcb..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 @@ -9,7 +9,6 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.googlevertexai.GoogleVertexAiSecretSettings; @@ -46,8 +45,7 @@ public static GoogleVertexAiRerankModel createModel(@Nullable String modelId, @N "service", new GoogleVertexAiRerankServiceSettings(randomAlphaOfLength(10), modelId, null), new GoogleVertexAiRerankTaskSettings(topN), - new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)), - EndpointVersions.FIRST_ENDPOINT_VERSION + new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)) ); } @@ -60,8 +58,7 @@ public static GoogleVertexAiRerankModel createModel(String url, @Nullable String url, new GoogleVertexAiRerankServiceSettings(randomAlphaOfLength(10), modelId, null), new GoogleVertexAiRerankTaskSettings(topN), - new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)), - EndpointVersions.FIRST_ENDPOINT_VERSION + new GoogleVertexAiSecretSettings(randomSecureStringOfLength(8)) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java index 9c1d556427aa6..68518d4bf6b69 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java @@ -18,7 +18,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -108,7 +107,6 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModel() throws IOException "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), getSecretSettingsMap("secret")), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -133,7 +131,6 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap(), getSecretSettingsMap("secret")), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -155,7 +152,6 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsP "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap(), getSecretSettingsMap("secret")), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -177,7 +173,6 @@ public void testParseRequestConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsN "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), getSecretSettingsMap("secret")), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -197,7 +192,6 @@ public void testParseRequestConfig_CreatesAnElserModel() throws IOException { "id", TaskType.SPARSE_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("url"), getSecretSettingsMap("secret")), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationActionListener ); } @@ -219,13 +213,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationActionListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationActionListener); } } @@ -247,13 +235,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationActionListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationActionListener); } } @@ -275,13 +257,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - EndpointVersions.FIRST_ENDPOINT_VERSION, - modelVerificationActionListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationActionListener); } } @@ -293,8 +269,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModel() throw "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -320,8 +295,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWithoutC "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -348,8 +322,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChun "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -371,8 +344,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChun "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -392,8 +364,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnElserModel() throws IOE "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceElserModel.class)); @@ -413,8 +384,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -436,8 +406,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -457,8 +426,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -480,8 +448,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -503,8 +470,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -522,8 +488,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModel() throws IOExcepti var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -543,8 +508,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWithoutChunkingSett var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -564,8 +528,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSetting var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -585,8 +548,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSetting var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -605,8 +567,7 @@ public void testParsePersistedConfig_CreatesAnElserModel() throws IOException { var model = service.parsePersistedConfig( "id", TaskType.SPARSE_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(HuggingFaceElserModel.class)); @@ -625,8 +586,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -647,8 +607,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -669,8 +628,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java index 27e1ddb43ee1b..d7a62256f8d9c 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/elser/HuggingFaceElserModelTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.inference.services.huggingface.elser; import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings; @@ -28,8 +27,7 @@ public static HuggingFaceElserModel createModel(String url, String apiKey) { TaskType.SPARSE_EMBEDDING, "service", new HuggingFaceElserServiceSettings(url), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -39,8 +37,7 @@ public static HuggingFaceElserModel createModel(String url, String apiKey, Strin TaskType.SPARSE_EMBEDDING, "service", new HuggingFaceElserServiceSettings(url), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } } 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 e4b7f643b9e42..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 @@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -33,8 +32,7 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey) "service", new HuggingFaceServiceSettings(url), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -45,8 +43,7 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey, "service", new HuggingFaceServiceSettings(createUri(url), null, null, tokenLimit, null), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -58,8 +55,7 @@ public static HuggingFaceEmbeddingsModel createModel(String url, String apiKey, "service", new HuggingFaceServiceSettings(createUri(url), null, dimensions, tokenLimit, null), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -77,8 +73,7 @@ public static HuggingFaceEmbeddingsModel createModel( "service", new HuggingFaceServiceSettings(createUri(url), similarityMeasure, dimensions, tokenLimit, null), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java index 33af0c1180d20..f8f08e6f880ab 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java @@ -18,7 +18,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -139,7 +138,6 @@ public void testParseRequestConfig_CreatesAIbmWatsonxEmbeddingsModel() throws IO new HashMap<>(Map.of()), getSecretSettingsMap(apiKey) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelListener ); } @@ -160,7 +158,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti new HashMap<>(Map.of()), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener ); } @@ -192,7 +189,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ElasticsearchStatusException.class, "Model configuration contains settings [{extra_key=value}] unknown to the [watsonxai] service" ); - service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, EndpointVersions.FIRST_ENDPOINT_VERSION, failureListener); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); } } @@ -219,8 +216,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAIbmWatsonxEmbeddingsMode "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -259,8 +255,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -301,8 +296,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -339,8 +333,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); @@ -384,8 +377,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(IbmWatsonxEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java index 5be17eba88327..93fd7e402a0de 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/embeddings/IbmWatsonxEmbeddingsModelTests.java @@ -10,7 +10,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -34,8 +33,7 @@ public static IbmWatsonxEmbeddingsModel createModel( url, new IbmWatsonxEmbeddingsServiceSettings(model, projectId, uri, apiVersion, null, null, SimilarityMeasure.DOT_PRODUCT, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -56,8 +54,7 @@ public static IbmWatsonxEmbeddingsModel createModel( url, new IbmWatsonxEmbeddingsServiceSettings(model, projectId, uri, apiVersion, null, dimensions, similarityMeasure, null), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -85,8 +82,7 @@ public static IbmWatsonxEmbeddingsModel createModel( null ), EmptyTaskSettings.INSTANCE, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java index 1be904f1724ef..5f0f549ca9e07 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java @@ -18,7 +18,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -117,7 +116,6 @@ public void testParseRequestConfig_CreatesAMistralEmbeddingsModel() throws IOExc getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -144,7 +142,6 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -173,7 +170,6 @@ public void testParseRequestConfig_CreatesAMistralEmbeddingsModelWhenChunkingSet createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -201,7 +197,6 @@ public void testParseRequestConfig_CreatesAMistralEmbeddingsModelWhenChunkingSet getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -225,7 +220,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -255,7 +249,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -287,7 +280,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingTaskSett "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -319,7 +311,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingSecretSe "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -337,8 +328,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModel() throws IOE "id", TaskType.TEXT_EMBEDDING, config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.secrets() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -365,8 +355,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWithoutChunki "id", TaskType.TEXT_EMBEDDING, config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.secrets() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -395,8 +384,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWhenChunkingS "id", TaskType.TEXT_EMBEDDING, config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.secrets() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -424,8 +412,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWhenChunkingS "id", TaskType.TEXT_EMBEDDING, config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.secrets() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -457,7 +444,6 @@ public void testParsePersistedConfig_ThrowsUnsupportedModelType() throws IOExcep getEmbeddingsTaskSettingsMap(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -477,8 +463,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM "id", TaskType.SPARSE_EMBEDDING, config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.secrets() ) ); @@ -501,8 +486,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() "id", TaskType.TEXT_EMBEDDING, config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.secrets() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -522,8 +506,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenExtraKeyExistsInEmbeddingSe "id", TaskType.TEXT_EMBEDDING, config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.secrets() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -543,8 +526,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding "id", TaskType.TEXT_EMBEDDING, config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.secrets() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -564,8 +546,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding "id", TaskType.TEXT_EMBEDDING, config.config(), - config.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.secrets() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -583,8 +564,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesEmbeddingsModel() thro var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - config.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.config() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -610,8 +590,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWitho var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - config.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.config() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -638,8 +617,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWhenC var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - config.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.config() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -665,8 +643,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWhenC var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - config.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + config.config() ); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java index 1197ec830bc6b..6f8b40fd7f19c 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/embeddings/MistralEmbeddingModelTests.java @@ -11,7 +11,6 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.EmptyTaskSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -40,8 +39,7 @@ public static MistralEmbeddingsModel createModel( new MistralEmbeddingsServiceSettings(model, dimensions, maxTokens, similarity, rateLimitSettings), EmptyTaskSettings.INSTANCE, chunkingSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -61,8 +59,7 @@ public static MistralEmbeddingsModel createModel( new MistralEmbeddingsServiceSettings(model, dimensions, maxTokens, similarity, rateLimitSettings), EmptyTaskSettings.INSTANCE, null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java index 922989abed57c..3d4d0fd62494a 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java @@ -19,7 +19,6 @@ import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -126,7 +125,6 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModel() throws IOExc getTaskSettingsMap("user"), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -161,7 +159,6 @@ public void testParseRequestConfig_CreatesAnOpenAiChatCompletionsModel() throws getTaskSettingsMap(user), getSecretSettingsMap(secret) ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -185,7 +182,6 @@ public void testParseRequestConfig_ThrowsUnsupportedModelType() throws IOExcepti getTaskSettingsMap("user"), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -215,7 +211,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -239,7 +234,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -263,7 +257,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -287,7 +280,6 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap "id", TaskType.TEXT_EMBEDDING, config, - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -310,7 +302,6 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModelWithoutUserUrlO "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("model", null, null), getTaskSettingsMap(null), getSecretSettingsMap("secret")), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -337,7 +328,6 @@ public void testParseRequestConfig_CreatesAnOpenAiChatCompletionsModelWithoutUse "id", TaskType.COMPLETION, getRequestConfigMap(getServiceSettingsMap(model, null, null), getTaskSettingsMap(null), getSecretSettingsMap(secret)), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -364,7 +354,6 @@ public void testParseRequestConfig_MovesModel() throws IOException { getTaskSettingsMap("user"), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -391,7 +380,6 @@ public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkin createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -422,7 +410,6 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingSet createRandomChunkingSettingsMap(), getSecretSettingsMap("secret") ), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -448,7 +435,6 @@ public void testParseRequestConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingSet "id", TaskType.TEXT_EMBEDDING, getRequestConfigMap(getServiceSettingsMap("model", null, null), getTaskSettingsMap(null), getSecretSettingsMap("secret")), - EndpointVersions.FIRST_ENDPOINT_VERSION, modelVerificationListener ); } @@ -466,8 +452,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModel() "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -495,8 +480,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM "id", TaskType.SPARSE_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ) ); @@ -519,8 +503,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWi "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -549,8 +532,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWi "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -580,8 +562,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWh "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -610,8 +591,7 @@ public void testParsePersistedConfigWithSecrets_CreatesAnOpenAiEmbeddingsModelWh "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -639,8 +619,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -670,8 +649,7 @@ public void testParsePersistedConfigWithSecrets_DoesNotThrowWhenAnExtraKeyExists "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -698,8 +676,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -725,8 +702,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInSe "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -755,8 +731,7 @@ public void testParsePersistedConfigWithSecrets_NotThrowWhenAnExtraKeyExistsInTa "id", TaskType.TEXT_EMBEDDING, persistedConfig.config(), - persistedConfig.secrets(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.secrets() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -780,8 +755,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModel() throws IOE var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -804,8 +778,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro () -> service.parsePersistedConfig( "id", TaskType.SPARSE_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ) ); @@ -826,8 +799,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWithoutUserUr var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -854,8 +826,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWithoutChunki var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -883,8 +854,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingS var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -911,8 +881,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingS var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -938,8 +907,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -963,8 +931,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -988,8 +955,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( var model = service.parsePersistedConfig( "id", TaskType.TEXT_EMBEDDING, - persistedConfig.config(), - EndpointVersions.FIRST_ENDPOINT_VERSION + persistedConfig.config() ); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java index fca68f3d27d30..ab1786f0a5843 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionModelTests.java @@ -9,7 +9,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings; @@ -60,8 +59,7 @@ public static OpenAiChatCompletionModel createChatCompletionModel( "service", new OpenAiChatCompletionServiceSettings(modelName, url, org, null, null), new OpenAiChatCompletionTaskSettings(user), - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java index c8731385ca50e..0e9179792b92b 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsModelTests.java @@ -10,7 +10,6 @@ import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.ChunkingSettings; -import org.elasticsearch.inference.EndpointVersions; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -64,8 +63,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, 1536, null, false, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -84,8 +82,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, 1536, null, false, null), new OpenAiEmbeddingsTaskSettings(user), chunkingSettings, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -103,8 +100,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, 1536, null, false, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -123,8 +119,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, 1536, tokenLimit, false, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -144,8 +139,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, SimilarityMeasure.DOT_PRODUCT, dimensions, tokenLimit, false, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } @@ -167,8 +161,7 @@ public static OpenAiEmbeddingsModel createModel( new OpenAiEmbeddingsServiceSettings(modelName, url, org, similarityMeasure, dimensions, tokenLimit, dimensionsSetByUser, null), new OpenAiEmbeddingsTaskSettings(user), null, - new DefaultSecretSettings(new SecureString(apiKey.toCharArray())), - EndpointVersions.FIRST_ENDPOINT_VERSION + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } } From fc72d8b71d381663c779053248e154b5d26e51cb Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Mon, 7 Oct 2024 15:15:30 -0400 Subject: [PATCH 10/15] precommit --- .../action/PutInferenceModelAction.java | 2 +- .../action/PutInferenceModelActionTests.java | 2 +- .../integration/ModelRegistryIT.java | 6 +- .../inference/ModelConfigurationsTests.java | 1 - .../TransportInferenceUsageActionTests.java | 42 +------ .../AzureOpenAiActionCreatorTests.java | 30 +---- .../registry/ModelRegistryTests.java | 30 +---- .../AmazonBedrockServiceTests.java | 64 ++--------- .../anthropic/AnthropicServiceTests.java | 24 +--- .../azureopenai/AzureOpenAiServiceTests.java | 58 ++-------- .../AzureOpenAiCompletionModelTests.java | 54 +-------- .../services/cohere/CohereServiceTests.java | 36 +----- .../GoogleAiStudioServiceTests.java | 42 ++----- .../GoogleVertexAiServiceTests.java | 7 +- .../huggingface/HuggingFaceServiceTests.java | 48 ++------ .../services/mistral/MistralServiceTests.java | 108 +++--------------- .../services/openai/OpenAiServiceTests.java | 82 +++---------- 17 files changed, 97 insertions(+), 539 deletions(-) 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 11bdd3669fd7b..73ecbad304a90 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 @@ -30,8 +30,8 @@ import java.util.Map; import java.util.Objects; -import static org.elasticsearch.inference.ModelConfigurations.TASK_SETTINGS; import static org.elasticsearch.inference.ModelConfigurations.PARAMETERS; +import static org.elasticsearch.inference.ModelConfigurations.TASK_SETTINGS; public class PutInferenceModelAction extends ActionType { 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 f0ef45beeb344..85799e3ba8803 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 @@ -24,8 +24,8 @@ import java.util.Locale; import java.util.Map; -import static org.elasticsearch.inference.ModelConfigurations.TASK_SETTINGS; 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; 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 3c1323f3141bf..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 @@ -518,7 +518,7 @@ private static Model buildModelWithUnknownField(String inferenceEntityId) { } public static Model createModel(String inferenceEntityId, TaskType taskType, String services) { - return new Model(new ModelConfigurations(inferenceEntityId, taskType, service, new TestModelOfAnyKind.TestModelServiceSettings())); + return new Model(new ModelConfigurations(inferenceEntityId, taskType, services, new TestModelOfAnyKind.TestModelServiceSettings())); } public static Model createModelWithSecrets(String inferenceEntityId, TaskType taskType, String service, String secret) { @@ -619,7 +619,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws } } - TestModelOfAnyKind(String inferenceEntityId, TaskType taskType, String services) { + TestModelOfAnyKind(String inferenceEntityId, TaskType taskType, String service) { super(inferenceEntityId, taskType, service, new TestModelServiceSettings(), new TestTaskSettings()); } @@ -644,7 +644,7 @@ private static class ModelWithUnknownField extends ModelConfigurations { TaskType taskType, String service, ServiceSettings serviceSettings, - TaskSettings taskSettingss + TaskSettings taskSettings ) { super(inferenceEntityId, taskType, service, serviceSettings, taskSettings); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java index a5aab67d66c1d..03613901c7816 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/ModelConfigurationsTests.java @@ -14,7 +14,6 @@ import org.elasticsearch.inference.TaskSettings; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.AbstractWireSerializingTestCase; -import org.elasticsearch.test.EnumSerializationTestUtils; import org.elasticsearch.xpack.core.inference.ChunkingSettingsFeatureFlag; import org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests; import org.elasticsearch.xpack.inference.services.elasticsearch.ElserInternalServiceSettingsTests; diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java index cd3ccd0645db9..b0c59fe160be3 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageActionTests.java @@ -81,42 +81,12 @@ public void test() throws Exception { listener.onResponse( new GetInferenceModelAction.Response( List.of( - new ModelConfigurations( - "model-001", - TaskType.TEXT_EMBEDDING, - "openai", - mock(ServiceSettings.class) - ), - new ModelConfigurations( - "model-002", - TaskType.TEXT_EMBEDDING, - "openai", - mock(ServiceSettings.class) - ), - new ModelConfigurations( - "model-003", - TaskType.SPARSE_EMBEDDING, - "hugging_face_elser", - mock(ServiceSettings.class) - ), - new ModelConfigurations( - "model-004", - TaskType.TEXT_EMBEDDING, - "openai", - mock(ServiceSettings.class) - ), - new ModelConfigurations( - "model-005", - TaskType.SPARSE_EMBEDDING, - "openai", - mock(ServiceSettings.class) - ), - new ModelConfigurations( - "model-006", - TaskType.SPARSE_EMBEDDING, - "hugging_face_elser", - mock(ServiceSettings.class) - ) + new ModelConfigurations("model-001", TaskType.TEXT_EMBEDDING, "openai", mock(ServiceSettings.class)), + new ModelConfigurations("model-002", TaskType.TEXT_EMBEDDING, "openai", mock(ServiceSettings.class)), + new ModelConfigurations("model-003", TaskType.SPARSE_EMBEDDING, "hugging_face_elser", mock(ServiceSettings.class)), + new ModelConfigurations("model-004", TaskType.TEXT_EMBEDDING, "openai", mock(ServiceSettings.class)), + new ModelConfigurations("model-005", TaskType.SPARSE_EMBEDDING, "openai", mock(ServiceSettings.class)), + new ModelConfigurations("model-006", TaskType.SPARSE_EMBEDDING, "hugging_face_elser", mock(ServiceSettings.class)) ) ) ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java index fbd013341db94..45a2fb0954c79 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/azureopenai/AzureOpenAiActionCreatorTests.java @@ -468,15 +468,7 @@ public void testInfer_AzureOpenAiCompletion_WithOverriddenUser() throws IOExcept var apiKey = "api_key"; var completionInput = "some input"; - var model = createCompletionModel( - "resource", - "deployment", - "apiversion", - originalUser, - apiKey, - null, - "id" - ); + var model = createCompletionModel("resource", "deployment", "apiversion", originalUser, apiKey, null, "id"); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); var taskSettingsWithUserOverride = createRequestTaskSettingsMap(overriddenUser); @@ -532,15 +524,7 @@ public void testInfer_AzureOpenAiCompletionModel_WithoutUser() throws IOExceptio webServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseJson)); - var model = createCompletionModel( - "resource", - "deployment", - "apiversion", - null, - apiKey, - null, - "id" - ); + var model = createCompletionModel("resource", "deployment", "apiversion", null, apiKey, null, "id"); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); var requestTaskSettingsWithoutUser = createRequestTaskSettingsMap(null); @@ -598,15 +582,7 @@ public void testInfer_AzureOpenAiCompletionModel_FailsFromInvalidResponseFormat( webServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseJson)); - var model = createCompletionModel( - "resource", - "deployment", - "apiversion", - null, - apiKey, - null, - "id" - ); + var model = createCompletionModel("resource", "deployment", "apiversion", null, apiKey, null, "id"); model.setUri(new URI(getUrl(webServer))); var actionCreator = new AzureOpenAiActionCreator(sender, createWithEmptySettings(threadPool)); var requestTaskSettingsWithoutUser = createRequestTaskSettingsMap(userOverride); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java index de54d2ad6c0ac..75c370fd4d3fb 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/registry/ModelRegistryTests.java @@ -295,13 +295,7 @@ public void testStoreModel_ThrowsException_WhenFailureIsNotAVersionConflict() { @SuppressWarnings("unchecked") public void testDeepCopyDefaultConfig() { { - var toCopy = new UnparsedModel( - "tocopy", - randomFrom(TaskType.values()), - "service-a", - Map.of(), - Map.of() - ); + var toCopy = new UnparsedModel("tocopy", randomFrom(TaskType.values()), "service-a", Map.of(), Map.of()); var copied = ModelRegistry.deepCopyDefaultConfig(toCopy); assertThat(copied, not(sameInstance(toCopy))); assertThat(copied.taskType(), is(toCopy.taskType())); @@ -324,13 +318,7 @@ public void testDeepCopyDefaultConfig() { Map service = Map.of("num_threads", 1, "adaptive_allocations", Map.of("enabled", true)); Map settings = Map.of("chunking_settings", chunking, "service_settings", service, "task_settings", task); - var toCopy = new UnparsedModel( - "tocopy", - randomFrom(TaskType.values()), - "service-a", - settings, - secretsMap - ); + var toCopy = new UnparsedModel("tocopy", randomFrom(TaskType.values()), "service-a", settings, secretsMap); var copied = ModelRegistry.deepCopyDefaultConfig(toCopy); assertThat(copied, not(sameInstance(toCopy))); @@ -364,20 +352,10 @@ public void testDuplicateDefaultIds() { var id = "my-inference"; - registry.addDefaultConfiguration( - new UnparsedModel(id, randomFrom(TaskType.values()), "service-a", Map.of(), Map.of()) - ); + registry.addDefaultConfiguration(new UnparsedModel(id, randomFrom(TaskType.values()), "service-a", Map.of(), Map.of())); var ise = expectThrows( IllegalStateException.class, - () -> registry.addDefaultConfiguration( - new UnparsedModel( - id, - randomFrom(TaskType.values()), - "service-b", - Map.of(), - Map.of() - ) - ) + () -> registry.addDefaultConfiguration(new UnparsedModel(id, randomFrom(TaskType.values()), "service-b", Map.of(), Map.of())) ); assertThat( ise.getMessage(), diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java index 088843669188b..0b3cf533d818f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockServiceTests.java @@ -205,12 +205,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -231,12 +226,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ); }); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -260,12 +250,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ); }); - service.parseRequestConfig( - "id", - TaskType.COMPLETION, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); } } @@ -289,12 +274,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ); }); - service.parseRequestConfig( - "id", - TaskType.COMPLETION, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.COMPLETION, config, modelVerificationListener); } } @@ -546,11 +526,7 @@ public void testParsePersistedConfig_CreatesAnAmazonBedrockEmbeddingsModel() thr var persistedConfig = getPersistedConfigMap(settingsMap, new HashMap(Map.of()), secretSettingsMap); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -569,11 +545,7 @@ public void testParsePersistedConfig_CreatesAnAmazonBedrockChatCompletionModel() var secretSettingsMap = getAmazonBedrockSecretSettingsMap("access", "secret"); var persistedConfig = getPersistedConfigMap(settingsMap, taskSettingsMap, secretSettingsMap); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); @@ -599,11 +571,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfig( - "id", - TaskType.SPARSE_EMBEDDING, - persistedConfig.config() - ) + () -> service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()) ); assertThat( @@ -621,11 +589,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var persistedConfig = getPersistedConfigMap(settingsMap, new HashMap(Map.of()), secretSettingsMap); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -646,11 +610,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var persistedConfig = getPersistedConfigMap(settingsMap, new HashMap(Map.of()), secretSettingsMap); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(AmazonBedrockEmbeddingsModel.class)); @@ -670,11 +630,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( var secretSettingsMap = getAmazonBedrockSecretSettingsMap("access", "secret"); var persistedConfig = getPersistedConfigMap(settingsMap, taskSettingsMap, secretSettingsMap); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(AmazonBedrockChatCompletionModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java index d7eeaca036082..c502425b22ac3 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java @@ -360,11 +360,7 @@ public void testParsePersistedConfig_CreatesACompletionModel() throws IOExceptio AnthropicChatCompletionTaskSettingsTests.getChatCompletionTaskSettingsMap(1, 1.0, 2.1, 3) ); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -385,11 +381,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() ); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -412,11 +404,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe AnthropicChatCompletionTaskSettingsTests.getChatCompletionTaskSettingsMap(1, 1.0, 2.1, 3) ); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); @@ -436,11 +424,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), taskSettings); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(AnthropicChatCompletionModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java index 53a984392d650..098e41b72ea8f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiServiceTests.java @@ -165,12 +165,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -195,12 +190,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa ); }); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -225,12 +215,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() ); }); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -255,12 +240,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap ); }); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -501,11 +481,7 @@ public void testParsePersistedConfig_CreatesAnAzureOpenAiEmbeddingsModel() throw getAzureOpenAiRequestTaskSettingsMap("user") ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -527,11 +503,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfig( - "id", - TaskType.SPARSE_EMBEDDING, - persistedConfig.config() - ) + () -> service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()) ); assertThat( @@ -549,11 +521,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() ); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -579,11 +547,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var persistedConfig = getPersistedConfigMap(serviceSettingsMap, getAzureOpenAiRequestTaskSettingsMap("user")); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); @@ -606,11 +570,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( taskSettingsMap ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(AzureOpenAiEmbeddingsModel.class)); 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 438cfda602ab0..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 @@ -35,31 +35,13 @@ public void testOverrideWith_UpdatedTaskSettings_OverridesUser() { var user = "user"; var userOverride = "user override"; - var model = createCompletionModel( - resource, - deploymentId, - apiVersion, - user, - apiKey, - entraId, - inferenceEntityId - ); + var model = createCompletionModel(resource, deploymentId, apiVersion, user, apiKey, entraId, inferenceEntityId); var requestTaskSettingsMap = taskSettingsMap(userOverride); var overriddenModel = AzureOpenAiCompletionModel.of(model, requestTaskSettingsMap); assertThat( overriddenModel, - equalTo( - createCompletionModel( - resource, - deploymentId, - apiVersion, - userOverride, - apiKey, - entraId, - inferenceEntityId - ) - ) + equalTo(createCompletionModel(resource, deploymentId, apiVersion, userOverride, apiKey, entraId, inferenceEntityId)) ); } @@ -109,30 +91,12 @@ public void testOverrideWith_UpdatedServiceSettings_OverridesApiVersion() { var updatedServiceSettings = new AzureOpenAiCompletionServiceSettings(resource, deploymentId, updatedApiVersion, null); - var model = createCompletionModel( - resource, - deploymentId, - apiVersion, - user, - apiKey, - entraId, - inferenceEntityId - ); + var model = createCompletionModel(resource, deploymentId, apiVersion, user, apiKey, entraId, inferenceEntityId); var overriddenModel = new AzureOpenAiCompletionModel(model, updatedServiceSettings); assertThat( overriddenModel, - is( - createCompletionModel( - resource, - deploymentId, - updatedApiVersion, - user, - apiKey, - entraId, - inferenceEntityId - ) - ) + is(createCompletionModel(resource, deploymentId, updatedApiVersion, user, apiKey, entraId, inferenceEntityId)) ); } @@ -145,15 +109,7 @@ public void testBuildUriString() throws URISyntaxException { var inferenceEntityId = "inference entity id"; var apiVersion = "2024"; - var model = createCompletionModel( - resource, - deploymentId, - apiVersion, - user, - apiKey, - entraId, - inferenceEntityId - ); + var model = createCompletionModel(resource, deploymentId, apiVersion, user, apiKey, entraId, inferenceEntityId); assertThat( model.buildUriString().toString(), diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java index fc456fcd70c2f..22503108b5262 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java @@ -493,11 +493,7 @@ public void testParsePersistedConfig_CreatesACohereEmbeddingsModel() throws IOEx getTaskSettingsMap(null, CohereTruncation.NONE) ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -518,11 +514,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfig( - "id", - TaskType.SPARSE_EMBEDDING, - persistedConfig.config() - ) + () -> service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()) ); MatcherAssert.assertThat( @@ -539,11 +531,7 @@ public void testParsePersistedConfig_CreatesACohereEmbeddingsModelWithoutUrl() t getTaskSettingsMap(null, null) ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -564,11 +552,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() ); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -586,11 +570,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var persistedConfig = getPersistedConfigMap(serviceSettingsMap, getTaskSettingsMap(InputType.SEARCH, null)); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); @@ -611,11 +591,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( taskSettingsMap ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); MatcherAssert.assertThat(model, instanceOf(CohereEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java index f8c04f6cd2690..e8382876868c5 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioServiceTests.java @@ -599,11 +599,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioCompletionModel() thr try (var service = createGoogleAiStudioService()) { var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), getTaskSettingsMapEmpty()); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -626,11 +622,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiEmbeddingsModelWithoutChunk createRandomChunkingSettingsMap() ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -654,11 +646,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenCh createRandomChunkingSettingsMap() ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -678,11 +666,7 @@ public void testParsePersistedConfig_CreatesAGoogleAiStudioEmbeddingsModelWhenCh try (var service = createGoogleAiStudioService()) { var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), getTaskSettingsMapEmpty()); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(GoogleAiStudioEmbeddingsModel.class)); @@ -701,11 +685,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), getTaskSettingsMapEmpty()); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -725,11 +705,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe var persistedConfig = getPersistedConfigMap(serviceSettingsMap, getTaskSettingsMapEmpty()); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); @@ -749,11 +725,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti var persistedConfig = getPersistedConfigMap(new HashMap<>(Map.of(ServiceFields.MODEL_ID, modelId)), taskSettings); - var model = service.parsePersistedConfig( - "id", - TaskType.COMPLETION, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.COMPLETION, persistedConfig.config()); assertThat(model, instanceOf(GoogleAiStudioCompletionModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java index 8aca5608f4638..6a96d289a8190 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java @@ -337,12 +337,7 @@ public void testParsePersistedConfigWithSecrets_CreatesGoogleVertexAiRerankModel getSecretSettingsMap(serviceAccountJson) ); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.RERANK, - persistedConfig.config(), - persistedConfig.secrets() - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.RERANK, persistedConfig.config(), persistedConfig.secrets()); assertThat(model, instanceOf(GoogleVertexAiRerankModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java index 68518d4bf6b69..8659b811f948e 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/HuggingFaceServiceTests.java @@ -485,11 +485,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModel() throws IOExcepti try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url")); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -505,11 +501,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWithoutChunkingSett try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap()); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -525,11 +517,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSetting try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url"), createRandomChunkingSettingsMap()); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -545,11 +533,7 @@ public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSetting try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url")); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -564,11 +548,7 @@ public void testParsePersistedConfig_CreatesAnElserModel() throws IOException { try (var service = createHuggingFaceService()) { var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url"), new HashMap<>()); - var model = service.parsePersistedConfig( - "id", - TaskType.SPARSE_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(HuggingFaceElserModel.class)); @@ -583,11 +563,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url")); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -604,11 +580,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInServiceSe var persistedConfig = getPersistedConfigMap(serviceSettingsMap); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); @@ -625,11 +597,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInTaskSetti var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("url"), taskSettingsMap, null); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(HuggingFaceEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java index 5f0f549ca9e07..c4a91260d89a0 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/mistral/MistralServiceTests.java @@ -245,12 +245,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -276,12 +271,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingTaskSett } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -307,12 +297,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInEmbeddingSecretSe } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -324,12 +309,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModel() throws IOE getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets() - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -351,12 +331,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWithoutChunki getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets() - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -380,12 +355,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWhenChunkingS getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets() - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -408,12 +378,7 @@ public void testParsePersistedConfig_CreatesAMistralEmbeddingsModelWhenChunkingS getSecretSettingsMap("secret") ); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets() - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -459,12 +424,7 @@ public void testParsePersistedConfigWithSecrets_ThrowsErrorTryingToParseInvalidM var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfigWithSecrets( - "id", - TaskType.SPARSE_EMBEDDING, - config.config(), - config.secrets() - ) + () -> service.parsePersistedConfigWithSecrets("id", TaskType.SPARSE_EMBEDDING, config.config(), config.secrets()) ); assertThat( @@ -482,12 +442,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); config.config().put("extra_key", "value"); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets() - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); } @@ -502,12 +457,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenExtraKeyExistsInEmbeddingSe var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets() - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); } @@ -522,12 +472,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding var secretSettings = getSecretSettingsMap("secret"); var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets() - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); } @@ -542,12 +487,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInEmbedding var config = getPersistedConfigMap(serviceSettings, taskSettings, secretSettings); - var model = service.parsePersistedConfigWithSecrets( - "id", - TaskType.TEXT_EMBEDDING, - config.config(), - config.secrets() - ); + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); } @@ -561,11 +501,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesEmbeddingsModel() thro Map.of() ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - config.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -587,11 +523,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWitho Map.of() ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - config.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -614,11 +546,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWhenC Map.of() ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - config.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); @@ -640,11 +568,7 @@ public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWhenC Map.of() ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - config.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); assertThat(model, instanceOf(MistralEmbeddingsModel.class)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java index 3d4d0fd62494a..cf1438b334478 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java @@ -207,12 +207,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInConfig() throws I } ); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -230,12 +225,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInServiceSettingsMa assertThat(e.getMessage(), is("Model configuration contains settings [{extra_key=value}] unknown to the [openai] service")); }); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -253,12 +243,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInTaskSettingsMap() assertThat(e.getMessage(), is("Model configuration contains settings [{extra_key=value}] unknown to the [openai] service")); }); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -276,12 +261,7 @@ public void testParseRequestConfig_ThrowsWhenAnExtraKeyExistsInSecretSettingsMap assertThat(e.getMessage(), is("Model configuration contains settings [{extra_key=value}] unknown to the [openai] service")); }); - service.parseRequestConfig( - "id", - TaskType.TEXT_EMBEDDING, - config, - modelVerificationListener - ); + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); } } @@ -752,11 +732,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModel() throws IOE getTaskSettingsMap("user") ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -775,11 +751,7 @@ public void testParsePersistedConfig_ThrowsErrorTryingToParseInvalidModel() thro var thrownException = expectThrows( ElasticsearchStatusException.class, - () -> service.parsePersistedConfig( - "id", - TaskType.SPARSE_EMBEDDING, - persistedConfig.config() - ) + () -> service.parsePersistedConfig("id", TaskType.SPARSE_EMBEDDING, persistedConfig.config()) ); assertThat( @@ -796,11 +768,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWithoutUserUr getTaskSettingsMap(null) ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -823,11 +791,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWithoutChunki createRandomChunkingSettingsMap() ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -851,11 +815,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingS createRandomChunkingSettingsMap() ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -878,11 +838,7 @@ public void testParsePersistedConfig_CreatesAnOpenAiEmbeddingsModelWhenChunkingS getTaskSettingsMap(null) ); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -904,11 +860,7 @@ public void testParsePersistedConfig_DoesNotThrowWhenAnExtraKeyExistsInConfig() ); persistedConfig.config().put("extra_key", "value"); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -928,11 +880,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInServiceSettin var persistedConfig = getPersistedConfigMap(serviceSettingsMap, getTaskSettingsMap("user")); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); @@ -952,11 +900,7 @@ public void testParsePersistedConfig_NotThrowWhenAnExtraKeyExistsInTaskSettings( var persistedConfig = getPersistedConfigMap(getServiceSettingsMap("model", "url", "org", null, null, true), taskSettingsMap); - var model = service.parsePersistedConfig( - "id", - TaskType.TEXT_EMBEDDING, - persistedConfig.config() - ); + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); assertThat(model, instanceOf(OpenAiEmbeddingsModel.class)); From 7bcec6c62d8ba49fbaccd7129311b0e7305853e2 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Mon, 7 Oct 2024 17:26:45 -0400 Subject: [PATCH 11/15] Add deprecation warning and integration tests --- .../action/PutInferenceModelAction.java | 10 +++++ .../inference/InferenceBaseRestTest.java | 42 +++++++++++++++++ .../xpack/inference/InferenceCrudIT.java | 45 +++++++++++++++++++ .../inference/InferencePermissionsIT.java | 6 +++ .../inference/qa/mixed/BaseMixedTestCase.java | 6 ++- 5 files changed, 107 insertions(+), 2 deletions(-) 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 73ecbad304a90..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 @@ -15,6 +15,8 @@ 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; @@ -37,6 +39,7 @@ public class PutInferenceModelAction extends ActionType 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..e8a0f3d9d367c 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 @@ -10,6 +10,7 @@ package org.elasticsearch.xpack.inference; import org.apache.http.util.EntityUtils; +import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.client.ResponseException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.inference.TaskType; @@ -66,6 +67,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 +167,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); } From e13922473072afddfd772d36d8052a8f20c18085 Mon Sep 17 00:00:00 2001 From: Max Hniebergall <137079448+maxhniebergall@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:37:59 -0400 Subject: [PATCH 12/15] Update 114176.yaml --- docs/changelog/114176.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/changelog/114176.yaml b/docs/changelog/114176.yaml index 1c21f69a78494..9b8fac91d403d 100644 --- a/docs/changelog/114176.yaml +++ b/docs/changelog/114176.yaml @@ -1,11 +1,10 @@ pr: 114176 -summary: "[Inference API ] Add `endpoint_version` to deprecate task settings" +summary: "[Inference API] Deprecate task_settings, renamed to parameters" area: Machine Learning type: deprecation issues: [] deprecation: - title: "[Inference API ] Add `endpoint_version` to deprecate task settings" - area: Machine Learning - details: Please describe the details of this change for the release notes. You can - use asciidoc. - impact: Please describe the impact of this change to users + 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`. From 7d6ab968282837e7f42985835ef8f7a8e2a945b7 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Mon, 7 Oct 2024 17:47:23 -0400 Subject: [PATCH 13/15] spotless --- .../java/org/elasticsearch/xpack/inference/InferenceCrudIT.java | 1 - 1 file changed, 1 deletion(-) 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 e8a0f3d9d367c..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 @@ -10,7 +10,6 @@ package org.elasticsearch.xpack.inference; import org.apache.http.util.EntityUtils; -import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.client.ResponseException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.inference.TaskType; From 081a1a81b019b84c1479dd37335b6b424e2b4cdf Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Tue, 8 Oct 2024 08:07:37 -0400 Subject: [PATCH 14/15] Ignore depreaction warnings on put in inference tests --- .../core/inference/action/PutInferenceModelActionTests.java | 5 +++-- .../xpack/application/InferenceUpgradeTestCase.java | 4 ++++ .../xpack/ml/integration/InferenceBaseRestTest.java | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) 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 85799e3ba8803..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 @@ -73,7 +73,7 @@ public void testWithParameters() throws IOException { 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.getContent(), false, request.getContentType()).v2(); + 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")); @@ -99,7 +99,8 @@ public void testWithParametersAndTaskSettings() throws IOException { ); assertThrows( ElasticsearchStatusException.class, - () -> new PutInferenceModelAction.Request(TASK_TYPE, MODEL_ID, BytesReference.bytes(builder), XContentType.JSON).getContent() + () -> new PutInferenceModelAction.Request(TASK_TYPE, MODEL_ID, BytesReference.bytes(builder), XContentType.JSON) + .getRewrittenContent() ); } 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/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); } From d3d211aee6090da9ef929a7aaa2e9aadb56ab527 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Tue, 8 Oct 2024 08:40:12 -0400 Subject: [PATCH 15/15] spotless --- server/src/main/java/org/elasticsearch/TransportVersions.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index c8c555cf88d26..1402bc7e8244e 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -239,7 +239,6 @@ static TransportVersion def(int id) { 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, * ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _