Skip to content

Commit f87b3c4

Browse files
Implement OpenShift AI integration for chat completion, embeddings, and reranking (elastic#136624)
1 parent 118ce80 commit f87b3c4

File tree

45 files changed

+6501
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+6501
-1
lines changed

docs/changelog/136624.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 136624
2+
summary: Added OpenShift AI text_embedding, completion, chat_completion and rerank support to the Inference Plugin
3+
area: Machine Learning
4+
type: enhancement
5+
issues: []
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9218000
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
resharding_shard_summary_in_esql,9217000
1+
ml_inference_openshift_ai_added,9218000

x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceGetServicesIT.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public void testGetServicesWithoutTaskType() throws IOException {
7070
"llama",
7171
"mistral",
7272
"openai",
73+
"openshift_ai",
7374
"streaming_completion_test_service",
7475
"completion_test_service",
7576
"test_reranking_service",
@@ -116,6 +117,7 @@ public void testGetServicesWithTextEmbeddingTaskType() throws IOException {
116117
"llama",
117118
"mistral",
118119
"openai",
120+
"openshift_ai",
119121
"text_embedding_test_service",
120122
"voyageai",
121123
"watsonxai"
@@ -140,6 +142,7 @@ public void testGetServicesWithRerankTaskType() throws IOException {
140142
"elasticsearch",
141143
"googlevertexai",
142144
"jinaai",
145+
"openshift_ai",
143146
"test_reranking_service",
144147
"voyageai",
145148
"hugging_face",
@@ -167,6 +170,7 @@ public void testGetServicesWithCompletionTaskType() throws IOException {
167170
"googleaistudio",
168171
"googlevertexai",
169172
"openai",
173+
"openshift_ai",
170174
"streaming_completion_test_service",
171175
"completion_test_service",
172176
"hugging_face",
@@ -188,6 +192,7 @@ public void testGetServicesWithChatCompletionTaskType() throws IOException {
188192
"deepseek",
189193
"elastic",
190194
"openai",
195+
"openshift_ai",
191196
"streaming_completion_test_service",
192197
"hugging_face",
193198
"amazon_sagemaker",

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceNamedWriteablesProvider.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
import org.elasticsearch.xpack.inference.services.openai.completion.OpenAiChatCompletionTaskSettings;
116116
import org.elasticsearch.xpack.inference.services.openai.embeddings.OpenAiEmbeddingsServiceSettings;
117117
import org.elasticsearch.xpack.inference.services.openai.embeddings.OpenAiEmbeddingsTaskSettings;
118+
import org.elasticsearch.xpack.inference.services.openshiftai.completion.OpenShiftAiChatCompletionServiceSettings;
119+
import org.elasticsearch.xpack.inference.services.openshiftai.embeddings.OpenShiftAiEmbeddingsServiceSettings;
120+
import org.elasticsearch.xpack.inference.services.openshiftai.rerank.OpenShiftAiRerankServiceSettings;
121+
import org.elasticsearch.xpack.inference.services.openshiftai.rerank.OpenShiftAiRerankTaskSettings;
118122
import org.elasticsearch.xpack.inference.services.sagemaker.model.SageMakerModel;
119123
import org.elasticsearch.xpack.inference.services.sagemaker.schema.SageMakerSchemas;
120124
import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings;
@@ -172,6 +176,7 @@ public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
172176
addCustomNamedWriteables(namedWriteables);
173177
addLlamaNamedWriteables(namedWriteables);
174178
addAi21NamedWriteables(namedWriteables);
179+
addOpenShiftAiNamedWriteables(namedWriteables);
175180

176181
addUnifiedNamedWriteables(namedWriteables);
177182

@@ -446,6 +451,33 @@ private static void addOpenAiNamedWriteables(List<NamedWriteableRegistry.Entry>
446451
);
447452
}
448453

454+
private static void addOpenShiftAiNamedWriteables(List<NamedWriteableRegistry.Entry> namedWriteables) {
455+
namedWriteables.add(
456+
new NamedWriteableRegistry.Entry(
457+
ServiceSettings.class,
458+
OpenShiftAiEmbeddingsServiceSettings.NAME,
459+
OpenShiftAiEmbeddingsServiceSettings::new
460+
)
461+
);
462+
namedWriteables.add(
463+
new NamedWriteableRegistry.Entry(
464+
ServiceSettings.class,
465+
OpenShiftAiChatCompletionServiceSettings.NAME,
466+
OpenShiftAiChatCompletionServiceSettings::new
467+
)
468+
);
469+
namedWriteables.add(
470+
new NamedWriteableRegistry.Entry(
471+
ServiceSettings.class,
472+
OpenShiftAiRerankServiceSettings.NAME,
473+
OpenShiftAiRerankServiceSettings::new
474+
)
475+
);
476+
namedWriteables.add(
477+
new NamedWriteableRegistry.Entry(TaskSettings.class, OpenShiftAiRerankTaskSettings.NAME, OpenShiftAiRerankTaskSettings::new)
478+
);
479+
}
480+
449481
private static void addHuggingFaceNamedWriteables(List<NamedWriteableRegistry.Entry> namedWriteables) {
450482
namedWriteables.add(
451483
new NamedWriteableRegistry.Entry(

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
import org.elasticsearch.xpack.inference.services.llama.LlamaService;
165165
import org.elasticsearch.xpack.inference.services.mistral.MistralService;
166166
import org.elasticsearch.xpack.inference.services.openai.OpenAiService;
167+
import org.elasticsearch.xpack.inference.services.openshiftai.OpenShiftAiService;
167168
import org.elasticsearch.xpack.inference.services.sagemaker.SageMakerClient;
168169
import org.elasticsearch.xpack.inference.services.sagemaker.SageMakerService;
169170
import org.elasticsearch.xpack.inference.services.sagemaker.model.SageMakerConfiguration;
@@ -492,6 +493,7 @@ public List<InferenceServiceExtension.Factory> getInferenceServiceFactories() {
492493
context -> new DeepSeekService(httpFactory.get(), serviceComponents.get(), context),
493494
context -> new LlamaService(httpFactory.get(), serviceComponents.get(), context),
494495
context -> new Ai21Service(httpFactory.get(), serviceComponents.get(), context),
496+
context -> new OpenShiftAiService(httpFactory.get(), serviceComponents.get(), context),
495497
ElasticsearchInternalService::new,
496498
context -> new CustomService(httpFactory.get(), serviceComponents.get(), context)
497499
);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public final class ServiceFields {
1414

1515
public static final String SIMILARITY = "similarity";
1616
public static final String DIMENSIONS = "dimensions";
17+
public static final String DIMENSIONS_SET_BY_USER = "dimensions_set_by_user";
1718
// Typically we use this to define the maximum tokens for the input text (text being sent to an integration)
1819
public static final String MAX_INPUT_TOKENS = "max_input_tokens";
1920
public static final String URL = "url";
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.xpack.inference.services.openshiftai;
9+
10+
import org.elasticsearch.inference.ModelConfigurations;
11+
import org.elasticsearch.inference.ModelSecrets;
12+
import org.elasticsearch.inference.ServiceSettings;
13+
import org.elasticsearch.inference.TaskSettings;
14+
import org.elasticsearch.xpack.inference.external.action.ExecutableAction;
15+
import org.elasticsearch.xpack.inference.services.RateLimitGroupingModel;
16+
import org.elasticsearch.xpack.inference.services.openshiftai.action.OpenShiftAiActionVisitor;
17+
import org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettings;
18+
import org.elasticsearch.xpack.inference.services.settings.RateLimitSettings;
19+
20+
import java.util.Map;
21+
import java.util.Objects;
22+
23+
/**
24+
* Represents an OpenShift AI model that can be used for inference tasks.
25+
* This class extends RateLimitGroupingModel to handle rate limiting based on modelId and API key.
26+
*/
27+
public abstract class OpenShiftAiModel extends RateLimitGroupingModel {
28+
29+
protected OpenShiftAiModel(ModelConfigurations configurations, ModelSecrets secrets) {
30+
super(configurations, secrets);
31+
}
32+
33+
protected OpenShiftAiModel(RateLimitGroupingModel model, ServiceSettings serviceSettings) {
34+
super(model, serviceSettings);
35+
}
36+
37+
protected OpenShiftAiModel(RateLimitGroupingModel model, TaskSettings taskSettings) {
38+
super(model, taskSettings);
39+
}
40+
41+
@Override
42+
public RateLimitSettings rateLimitSettings() {
43+
return getServiceSettings().rateLimitSettings();
44+
}
45+
46+
@Override
47+
public int rateLimitGroupingHash() {
48+
return Objects.hash(getServiceSettings().uri(), getServiceSettings().modelId());
49+
}
50+
51+
@Override
52+
public OpenShiftAiServiceSettings getServiceSettings() {
53+
return (OpenShiftAiServiceSettings) super.getServiceSettings();
54+
}
55+
56+
@Override
57+
public DefaultSecretSettings getSecretSettings() {
58+
return (DefaultSecretSettings) super.getSecretSettings();
59+
}
60+
61+
/**
62+
* Accepts a visitor to create an executable action for this OpenShift AI model.
63+
*
64+
* @param creator the visitor that creates the executable action
65+
* @param taskSettings the task settings to be used for the executable action
66+
* @return an {@link ExecutableAction} specific to this OpenShift AI model
67+
*/
68+
public abstract ExecutableAction accept(OpenShiftAiActionVisitor creator, Map<String, Object> taskSettings);
69+
}

0 commit comments

Comments
 (0)