mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 09:28:55 -04:00
Hides hugging_face_elser
service from the GET _inference/_services API
(#116664)
* Adding hideFromConfigurationApi flag * Update docs/changelog/116664.yaml
This commit is contained in:
parent
d2e5c43c9b
commit
65de0f0ca9
5 changed files with 36 additions and 15 deletions
6
docs/changelog/116664.yaml
Normal file
6
docs/changelog/116664.yaml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
pr: 116664
|
||||||
|
summary: Hides `hugging_face_elser` service from the `GET _inference/_services API`
|
||||||
|
area: Machine Learning
|
||||||
|
type: bug
|
||||||
|
issues:
|
||||||
|
- 116644
|
|
@ -74,6 +74,14 @@ public interface InferenceService extends Closeable {
|
||||||
|
|
||||||
InferenceServiceConfiguration getConfiguration();
|
InferenceServiceConfiguration getConfiguration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this service should be hidden from the API. Should be used for services
|
||||||
|
* that are not ready to be used.
|
||||||
|
*/
|
||||||
|
default Boolean hideFromConfigurationApi() {
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The task types supported by the service
|
* The task types supported by the service
|
||||||
* @return Set of supported.
|
* @return Set of supported.
|
||||||
|
|
|
@ -135,9 +135,9 @@ public class InferenceCrudIT extends InferenceBaseRestTest {
|
||||||
public void testGetServicesWithoutTaskType() throws IOException {
|
public void testGetServicesWithoutTaskType() throws IOException {
|
||||||
List<Object> services = getAllServices();
|
List<Object> services = getAllServices();
|
||||||
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
|
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
|
||||||
assertThat(services.size(), equalTo(19));
|
|
||||||
} else {
|
|
||||||
assertThat(services.size(), equalTo(18));
|
assertThat(services.size(), equalTo(18));
|
||||||
|
} else {
|
||||||
|
assertThat(services.size(), equalTo(17));
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] providers = new String[services.size()];
|
String[] providers = new String[services.size()];
|
||||||
|
@ -160,7 +160,6 @@ public class InferenceCrudIT extends InferenceBaseRestTest {
|
||||||
"googleaistudio",
|
"googleaistudio",
|
||||||
"googlevertexai",
|
"googlevertexai",
|
||||||
"hugging_face",
|
"hugging_face",
|
||||||
"hugging_face_elser",
|
|
||||||
"mistral",
|
"mistral",
|
||||||
"openai",
|
"openai",
|
||||||
"streaming_completion_test_service",
|
"streaming_completion_test_service",
|
||||||
|
@ -259,9 +258,9 @@ public class InferenceCrudIT extends InferenceBaseRestTest {
|
||||||
List<Object> services = getServices(TaskType.SPARSE_EMBEDDING);
|
List<Object> services = getServices(TaskType.SPARSE_EMBEDDING);
|
||||||
|
|
||||||
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
|
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
|
||||||
assertThat(services.size(), equalTo(6));
|
|
||||||
} else {
|
|
||||||
assertThat(services.size(), equalTo(5));
|
assertThat(services.size(), equalTo(5));
|
||||||
|
} else {
|
||||||
|
assertThat(services.size(), equalTo(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] providers = new String[services.size()];
|
String[] providers = new String[services.size()];
|
||||||
|
@ -272,9 +271,7 @@ public class InferenceCrudIT extends InferenceBaseRestTest {
|
||||||
|
|
||||||
Arrays.sort(providers);
|
Arrays.sort(providers);
|
||||||
|
|
||||||
var providerList = new ArrayList<>(
|
var providerList = new ArrayList<>(Arrays.asList("alibabacloud-ai-search", "elasticsearch", "hugging_face", "test_service"));
|
||||||
Arrays.asList("alibabacloud-ai-search", "elasticsearch", "hugging_face", "hugging_face_elser", "test_service")
|
|
||||||
);
|
|
||||||
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
|
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
|
||||||
providerList.add(1, "elastic");
|
providerList.add(1, "elastic");
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,10 @@ public class TransportGetInferenceServicesAction extends HandledTransportAction<
|
||||||
var filteredServices = serviceRegistry.getServices()
|
var filteredServices = serviceRegistry.getServices()
|
||||||
.entrySet()
|
.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(service -> service.getValue().supportedTaskTypes().contains(requestedTaskType))
|
.filter(
|
||||||
|
service -> service.getValue().hideFromConfigurationApi() == false
|
||||||
|
&& service.getValue().supportedTaskTypes().contains(requestedTaskType)
|
||||||
|
)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
getServiceConfigurationsForServices(filteredServices, listener.delegateFailureAndWrap((delegate, configurations) -> {
|
getServiceConfigurationsForServices(filteredServices, listener.delegateFailureAndWrap((delegate, configurations) -> {
|
||||||
|
@ -77,12 +80,14 @@ public class TransportGetInferenceServicesAction extends HandledTransportAction<
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getAllServiceConfigurations(ActionListener<GetInferenceServicesAction.Response> listener) {
|
private void getAllServiceConfigurations(ActionListener<GetInferenceServicesAction.Response> listener) {
|
||||||
getServiceConfigurationsForServices(
|
var availableServices = serviceRegistry.getServices()
|
||||||
serviceRegistry.getServices().entrySet(),
|
.entrySet()
|
||||||
listener.delegateFailureAndWrap((delegate, configurations) -> {
|
.stream()
|
||||||
delegate.onResponse(new GetInferenceServicesAction.Response(configurations));
|
.filter(service -> service.getValue().hideFromConfigurationApi() == false)
|
||||||
})
|
.collect(Collectors.toSet());
|
||||||
);
|
getServiceConfigurationsForServices(availableServices, listener.delegateFailureAndWrap((delegate, configurations) -> {
|
||||||
|
delegate.onResponse(new GetInferenceServicesAction.Response(configurations));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getServiceConfigurationsForServices(
|
private void getServiceConfigurationsForServices(
|
||||||
|
|
|
@ -125,6 +125,11 @@ public class HuggingFaceElserService extends HuggingFaceBaseService {
|
||||||
return Configuration.get();
|
return Configuration.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean hideFromConfigurationApi() {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumSet<TaskType> supportedTaskTypes() {
|
public EnumSet<TaskType> supportedTaskTypes() {
|
||||||
return supportedTaskTypes;
|
return supportedTaskTypes;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue