From ced6ca7ce29300aa7029c4c4831db2987f206d0d Mon Sep 17 00:00:00 2001 From: Donal Evans Date: Thu, 8 Jan 2026 16:23:31 -0800 Subject: [PATCH 1/2] [Inference API] Include rerank in supported tasks for IBM watsonx integration (#140331) Closes #140328 (cherry picked from commit 201c582d40d29a57febd9a73009da91d203b4698) # Conflicts: # x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetServicesIT.java # x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxServiceTests.java --- docs/changelog/140331.yaml | 6 + .../api/inference.put_watsonx.json | 3 +- .../inference/InferenceGetServicesIT.java | 1 + .../ibmwatsonx/IbmWatsonxService.java | 2 +- .../ibmwatsonx/IbmWatsonxServiceTests.java | 106 +++++++++--------- 5 files changed, 63 insertions(+), 55 deletions(-) create mode 100644 docs/changelog/140331.yaml diff --git a/docs/changelog/140331.yaml b/docs/changelog/140331.yaml new file mode 100644 index 0000000000000..19568786d098e --- /dev/null +++ b/docs/changelog/140331.yaml @@ -0,0 +1,6 @@ +pr: 140331 +summary: "[Inference API] Include rerank in supported tasks for IBM watsonx integration" +area: Inference +type: bug +issues: + - 140328 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/inference.put_watsonx.json b/rest-api-spec/src/main/resources/rest-api-spec/api/inference.put_watsonx.json index 96daea8db6e00..156cd461b9c04 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/inference.put_watsonx.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/inference.put_watsonx.json @@ -28,7 +28,8 @@ "options": [ "text_embedding", "chat_completion", - "completion" + "completion", + "rerank" ] }, "watsonx_inference_id": { diff --git a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetServicesIT.java b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetServicesIT.java index ad0b55a209201..5b0756f442e13 100644 --- a/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetServicesIT.java +++ b/x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetServicesIT.java @@ -116,6 +116,7 @@ public void testGetServicesWithRerankTaskType() throws IOException { "elastic", "elasticsearch", "googlevertexai", + "watsonxai", "hugging_face", "jinaai", "test_reranking_service", 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 e502d830c6ee4..5f4c482b74109 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 class IbmWatsonxService extends SenderService { public static final String NAME = "watsonxai"; private static final String SERVICE_NAME = "IBM Watsonx"; - private static final EnumSet supportedTaskTypes = EnumSet.of(TaskType.TEXT_EMBEDDING); + private static final EnumSet supportedTaskTypes = EnumSet.of(TaskType.TEXT_EMBEDDING, TaskType.RERANK); public IbmWatsonxService(HttpRequestSender.Factory factory, ServiceComponents serviceComponents) { super(factory, serviceComponents); 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 8de469b4651f4..e4ce633d5edcb 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 @@ -938,59 +938,59 @@ private void testUpdateModelWithEmbeddingDetails_Successful(SimilarityMeasure si public void testGetConfiguration() throws Exception { try (var service = createIbmWatsonxService()) { String content = XContentHelper.stripWhitespace(""" - { - "service": "watsonxai", - "name": "IBM Watsonx", - "task_types": ["text_embedding"], - "configurations": { - "project_id": { - "description": "", - "label": "Project ID", - "required": true, - "sensitive": false, - "updatable": false, - "type": "str", - "supported_task_types": ["text_embedding"] - }, - "model_id": { - "description": "The name of the model to use for the inference task.", - "label": "Model ID", - "required": true, - "sensitive": false, - "updatable": false, - "type": "str", - "supported_task_types": ["text_embedding"] - }, - "api_version": { - "description": "The IBM Watsonx API version ID to use.", - "label": "API Version", - "required": true, - "sensitive": false, - "updatable": false, - "type": "str", - "supported_task_types": ["text_embedding"] - }, - "max_input_tokens": { - "description": "Allows you to specify the maximum number of tokens per input.", - "label": "Maximum Input Tokens", - "required": false, - "sensitive": false, - "updatable": false, - "type": "int", - "supported_task_types": ["text_embedding"] - }, - "url": { - "description": "", - "label": "URL", - "required": true, - "sensitive": false, - "updatable": false, - "type": "str", - "supported_task_types": ["text_embedding"] - } - } - } - """); + { + "service": "watsonxai", + "name": "IBM Watsonx", + "task_types": ["text_embedding", "rerank"], + "configurations": { + "project_id": { + "description": "", + "label": "Project ID", + "required": true, + "sensitive": false, + "updatable": false, + "type": "str", + "supported_task_types": ["text_embedding", "rerank"] + }, + "model_id": { + "description": "The name of the model to use for the inference task.", + "label": "Model ID", + "required": true, + "sensitive": false, + "updatable": false, + "type": "str", + "supported_task_types": ["text_embedding", "rerank"] + }, + "api_version": { + "description": "The IBM Watsonx API version ID to use.", + "label": "API Version", + "required": true, + "sensitive": false, + "updatable": false, + "type": "str", + "supported_task_types": ["text_embedding", "rerank"] + }, + "max_input_tokens": { + "description": "Allows you to specify the maximum number of tokens per input.", + "label": "Maximum Input Tokens", + "required": false, + "sensitive": false, + "updatable": false, + "type": "int", + "supported_task_types": ["text_embedding"] + }, + "url": { + "description": "", + "label": "URL", + "required": true, + "sensitive": false, + "updatable": false, + "type": "str", + "supported_task_types": ["text_embedding", "rerank"] + } + } + } + """); InferenceServiceConfiguration configuration = InferenceServiceConfiguration.fromXContentBytes( new BytesArray(content), XContentType.JSON From 570dc8d5d48c2eebf2b9cd505ac18ad5dd77e34c Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Fri, 9 Jan 2026 01:04:03 +0000 Subject: [PATCH 2/2] [CI] Auto commit changes from spotless --- .../ibmwatsonx/IbmWatsonxServiceTests.java | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) 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 e4ce633d5edcb..0cf30a591dde8 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 @@ -938,59 +938,59 @@ private void testUpdateModelWithEmbeddingDetails_Successful(SimilarityMeasure si public void testGetConfiguration() throws Exception { try (var service = createIbmWatsonxService()) { String content = XContentHelper.stripWhitespace(""" - { - "service": "watsonxai", - "name": "IBM Watsonx", - "task_types": ["text_embedding", "rerank"], - "configurations": { - "project_id": { - "description": "", - "label": "Project ID", - "required": true, - "sensitive": false, - "updatable": false, - "type": "str", - "supported_task_types": ["text_embedding", "rerank"] - }, - "model_id": { - "description": "The name of the model to use for the inference task.", - "label": "Model ID", - "required": true, - "sensitive": false, - "updatable": false, - "type": "str", - "supported_task_types": ["text_embedding", "rerank"] - }, - "api_version": { - "description": "The IBM Watsonx API version ID to use.", - "label": "API Version", - "required": true, - "sensitive": false, - "updatable": false, - "type": "str", - "supported_task_types": ["text_embedding", "rerank"] - }, - "max_input_tokens": { - "description": "Allows you to specify the maximum number of tokens per input.", - "label": "Maximum Input Tokens", - "required": false, - "sensitive": false, - "updatable": false, - "type": "int", - "supported_task_types": ["text_embedding"] - }, - "url": { - "description": "", - "label": "URL", - "required": true, - "sensitive": false, - "updatable": false, - "type": "str", - "supported_task_types": ["text_embedding", "rerank"] - } - } - } - """); + { + "service": "watsonxai", + "name": "IBM Watsonx", + "task_types": ["text_embedding", "rerank"], + "configurations": { + "project_id": { + "description": "", + "label": "Project ID", + "required": true, + "sensitive": false, + "updatable": false, + "type": "str", + "supported_task_types": ["text_embedding", "rerank"] + }, + "model_id": { + "description": "The name of the model to use for the inference task.", + "label": "Model ID", + "required": true, + "sensitive": false, + "updatable": false, + "type": "str", + "supported_task_types": ["text_embedding", "rerank"] + }, + "api_version": { + "description": "The IBM Watsonx API version ID to use.", + "label": "API Version", + "required": true, + "sensitive": false, + "updatable": false, + "type": "str", + "supported_task_types": ["text_embedding", "rerank"] + }, + "max_input_tokens": { + "description": "Allows you to specify the maximum number of tokens per input.", + "label": "Maximum Input Tokens", + "required": false, + "sensitive": false, + "updatable": false, + "type": "int", + "supported_task_types": ["text_embedding"] + }, + "url": { + "description": "", + "label": "URL", + "required": true, + "sensitive": false, + "updatable": false, + "type": "str", + "supported_task_types": ["text_embedding", "rerank"] + } + } + } + """); InferenceServiceConfiguration configuration = InferenceServiceConfiguration.fromXContentBytes( new BytesArray(content), XContentType.JSON