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 64fe42fbbc171..bfb3509a2cd46 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 @@ -267,6 +267,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 45a5c59302cf6..97c2ae8a58059 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 @@ -628,6 +628,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"] } } }