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();
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return Set of supported.
|
||||
|
|
|
@ -135,9 +135,9 @@ public class InferenceCrudIT extends InferenceBaseRestTest {
|
|||
public void testGetServicesWithoutTaskType() throws IOException {
|
||||
List<Object> services = getAllServices();
|
||||
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
|
||||
assertThat(services.size(), equalTo(19));
|
||||
} else {
|
||||
assertThat(services.size(), equalTo(18));
|
||||
} else {
|
||||
assertThat(services.size(), equalTo(17));
|
||||
}
|
||||
|
||||
String[] providers = new String[services.size()];
|
||||
|
@ -160,7 +160,6 @@ public class InferenceCrudIT extends InferenceBaseRestTest {
|
|||
"googleaistudio",
|
||||
"googlevertexai",
|
||||
"hugging_face",
|
||||
"hugging_face_elser",
|
||||
"mistral",
|
||||
"openai",
|
||||
"streaming_completion_test_service",
|
||||
|
@ -259,9 +258,9 @@ public class InferenceCrudIT extends InferenceBaseRestTest {
|
|||
List<Object> services = getServices(TaskType.SPARSE_EMBEDDING);
|
||||
|
||||
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
|
||||
assertThat(services.size(), equalTo(6));
|
||||
} else {
|
||||
assertThat(services.size(), equalTo(5));
|
||||
} else {
|
||||
assertThat(services.size(), equalTo(4));
|
||||
}
|
||||
|
||||
String[] providers = new String[services.size()];
|
||||
|
@ -272,9 +271,7 @@ public class InferenceCrudIT extends InferenceBaseRestTest {
|
|||
|
||||
Arrays.sort(providers);
|
||||
|
||||
var providerList = new ArrayList<>(
|
||||
Arrays.asList("alibabacloud-ai-search", "elasticsearch", "hugging_face", "hugging_face_elser", "test_service")
|
||||
);
|
||||
var providerList = new ArrayList<>(Arrays.asList("alibabacloud-ai-search", "elasticsearch", "hugging_face", "test_service"));
|
||||
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
|
||||
providerList.add(1, "elastic");
|
||||
}
|
||||
|
|
|
@ -68,7 +68,10 @@ public class TransportGetInferenceServicesAction extends HandledTransportAction<
|
|||
var filteredServices = serviceRegistry.getServices()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(service -> service.getValue().supportedTaskTypes().contains(requestedTaskType))
|
||||
.filter(
|
||||
service -> service.getValue().hideFromConfigurationApi() == false
|
||||
&& service.getValue().supportedTaskTypes().contains(requestedTaskType)
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
getServiceConfigurationsForServices(filteredServices, listener.delegateFailureAndWrap((delegate, configurations) -> {
|
||||
|
@ -77,12 +80,14 @@ public class TransportGetInferenceServicesAction extends HandledTransportAction<
|
|||
}
|
||||
|
||||
private void getAllServiceConfigurations(ActionListener<GetInferenceServicesAction.Response> listener) {
|
||||
getServiceConfigurationsForServices(
|
||||
serviceRegistry.getServices().entrySet(),
|
||||
listener.delegateFailureAndWrap((delegate, configurations) -> {
|
||||
delegate.onResponse(new GetInferenceServicesAction.Response(configurations));
|
||||
})
|
||||
);
|
||||
var availableServices = serviceRegistry.getServices()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(service -> service.getValue().hideFromConfigurationApi() == false)
|
||||
.collect(Collectors.toSet());
|
||||
getServiceConfigurationsForServices(availableServices, listener.delegateFailureAndWrap((delegate, configurations) -> {
|
||||
delegate.onResponse(new GetInferenceServicesAction.Response(configurations));
|
||||
}));
|
||||
}
|
||||
|
||||
private void getServiceConfigurationsForServices(
|
||||
|
|
|
@ -125,6 +125,11 @@ public class HuggingFaceElserService extends HuggingFaceBaseService {
|
|||
return Configuration.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hideFromConfigurationApi() {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TaskType> supportedTaskTypes() {
|
||||
return supportedTaskTypes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue