Skip to content

Commit 063f9db

Browse files
[ML] Including max_tokens through the Service API for Anthropic (#131113) (#131218)
* Adding max_tokens to get services API * Update docs/changelog/131113.yaml
1 parent 5673530 commit 063f9db

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
@@ -267,6 +267,19 @@ public static InferenceServiceConfiguration get() {
267267
.build()
268268
);
269269

270+
configurationMap.put(
271+
AnthropicServiceFields.MAX_TOKENS,
272+
new SettingsConfiguration.Builder(EnumSet.of(TaskType.COMPLETION)).setDescription(
273+
"The maximum number of tokens to generate before stopping."
274+
)
275+
.setLabel("Max Tokens")
276+
.setRequired(true)
277+
.setSensitive(false)
278+
.setUpdatable(false)
279+
.setType(SettingsConfigurationFieldType.INTEGER)
280+
.build()
281+
);
282+
270283
configurationMap.putAll(DefaultSecretSettings.toSettingsConfiguration(supportedTaskTypes));
271284
configurationMap.putAll(
272285
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
@@ -628,6 +628,15 @@ public void testGetConfiguration() throws Exception {
628628
"updatable": false,
629629
"type": "str",
630630
"supported_task_types": ["completion"]
631+
},
632+
"max_tokens": {
633+
"description": "The maximum number of tokens to generate before stopping.",
634+
"label": "Max Tokens",
635+
"required": true,
636+
"sensitive": false,
637+
"updatable": false,
638+
"type": "int",
639+
"supported_task_types": ["completion"]
631640
}
632641
}
633642
}

0 commit comments

Comments
 (0)