diff --git a/docs/changelog/131113.yaml b/docs/changelog/131113.yaml new file mode 100644 index 0000000000000..cca54f0a302f0 --- /dev/null +++ b/docs/changelog/131113.yaml @@ -0,0 +1,5 @@ +pr: 131113 +summary: Including `max_tokens` through the Service API for Anthropic +area: Machine Learning +type: bug +issues: [] 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 bec8908ab73f9..791518ccc9168 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 @@ -263,6 +263,19 @@ public static InferenceServiceConfiguration get() { .build() ); + configurationMap.put( + AnthropicServiceFields.MAX_TOKENS, + new SettingsConfiguration.Builder(EnumSet.of(TaskType.COMPLETION)).setDescription( + "The maximum number of tokens to generate before stopping." + ) + .setLabel("Max Tokens") + .setRequired(true) + .setSensitive(false) + .setUpdatable(false) + .setType(SettingsConfigurationFieldType.INTEGER) + .build() + ); + configurationMap.putAll(DefaultSecretSettings.toSettingsConfiguration(supportedTaskTypes)); configurationMap.putAll( RateLimitSettings.toSettingsConfigurationWithDescription( 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 75ce59b16a763..a3f0b01901009 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 @@ -650,6 +650,15 @@ public void testGetConfiguration() throws Exception { "updatable": false, "type": "str", "supported_task_types": ["completion"] + }, + "max_tokens": { + "description": "The maximum number of tokens to generate before stopping.", + "label": "Max Tokens", + "required": true, + "sensitive": false, + "updatable": false, + "type": "int", + "supported_task_types": ["completion"] } } }