Skip to content

Commit 49138c1

Browse files
[ML] Including max_tokens through the Service API for Anthropic (#131113) (#131216)
* Adding max_tokens to get services API * Update docs/changelog/131113.yaml
1 parent c5ca2c2 commit 49138c1

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

docs/changelog/131113.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 131113
2+
summary: Including `max_tokens` through the Service API for Anthropic
3+
area: Machine Learning
4+
type: bug
5+
issues: []

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,19 @@ public static InferenceServiceConfiguration get() {
263263
.build()
264264
);
265265

266+
configurationMap.put(
267+
AnthropicServiceFields.MAX_TOKENS,
268+
new SettingsConfiguration.Builder(EnumSet.of(TaskType.COMPLETION)).setDescription(
269+
"The maximum number of tokens to generate before stopping."
270+
)
271+
.setLabel("Max Tokens")
272+
.setRequired(true)
273+
.setSensitive(false)
274+
.setUpdatable(false)
275+
.setType(SettingsConfigurationFieldType.INTEGER)
276+
.build()
277+
);
278+
266279
configurationMap.putAll(DefaultSecretSettings.toSettingsConfiguration(supportedTaskTypes));
267280
configurationMap.putAll(
268281
RateLimitSettings.toSettingsConfigurationWithDescription(

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,15 @@ public void testGetConfiguration() throws Exception {
650650
"updatable": false,
651651
"type": "str",
652652
"supported_task_types": ["completion"]
653+
},
654+
"max_tokens": {
655+
"description": "The maximum number of tokens to generate before stopping.",
656+
"label": "Max Tokens",
657+
"required": true,
658+
"sensitive": false,
659+
"updatable": false,
660+
"type": "int",
661+
"supported_task_types": ["completion"]
653662
}
654663
}
655664
}

0 commit comments

Comments
 (0)