- All Superinterfaces:
AutoCloseable,Closeable
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidcheckModelConfig(Model model, ActionListener<Model> listener) Optionally test the new model configuration in the inference service.voidchunkedInfer(Model model, String query, List<String> input, Map<String, Object> taskSettings, InputType inputType, ChunkingOptions chunkingOptions, TimeValue timeout, ActionListener<List<ChunkedInferenceServiceResults>> listener) Chunk long text according tochunkingOptionsor the model defaults ifchunkingOptionscontains unset values.Defines the version required across all clusters to use this servicevoidinfer(Model model, String query, List<String> input, Map<String, Object> taskSettings, InputType inputType, TimeValue timeout, ActionListener<InferenceServiceResults> listener) Perform inference on the model.default voiddefault booleanReturn true if this model is hosted in the local Elasticsearch clusterdefault voidisModelDownloaded(Model model, ActionListener<Boolean> listener) Checks if the modelId has been downloaded to the local Elasticsearch cluster using the trained models API The default action does nothing except acknowledge the request (false).name()Parse model configuration fromconfig mapfrom persisted storage and return the parsedModel.parsePersistedConfigWithSecrets(String modelId, TaskType taskType, Map<String, Object> config, Map<String, Object> secrets) Parse model configuration fromconfig mapfrom persisted storage and return the parsedModel.voidparseRequestConfig(String modelId, TaskType taskType, Map<String, Object> config, Set<String> platfromArchitectures, ActionListener<Model> parsedModelListener) Parse model configuration from theconfig mapfrom a request and return the parsedModel.default voidputModel(Model modelVariant, ActionListener<Boolean> listener) Put the model definition (if applicable) The main purpose of this function is to download ELSER The default action does nothing except acknowledge the request (true).voidstart(Model model, ActionListener<Boolean> listener) Start or prepare the model for use.default voidstop(String modelId, ActionListener<Boolean> listener) Stop the model deployment.
-
Method Details
-
init
-
name
String name() -
parseRequestConfig
void parseRequestConfig(String modelId, TaskType taskType, Map<String, Object> config, Set<String> platfromArchitectures, ActionListener<Model> parsedModelListener) Parse model configuration from theconfig mapfrom a request and return the parsedModel. This requires that both the secrets and service settings be contained in theservice_settingsfield. This function modifiesconfig map, fields are removed from the map as they are read.If the map contains unrecognized configuration option an
ElasticsearchStatusExceptionis thrown.- Parameters:
modelId- Model IdtaskType- The model task typeconfig- Configuration options including the secretsplatfromArchitectures- The Set of platform architectures (OS name and hardware architecture) the cluster nodes and models are running on.parsedModelListener- A listener which will handle the resulting model or failure
-
parsePersistedConfigWithSecrets
Model parsePersistedConfigWithSecrets(String modelId, TaskType taskType, Map<String, Object> config, Map<String, Object> secrets) Parse model configuration fromconfig mapfrom persisted storage and return the parsedModel. This requires that secrets and service settings be in two separate maps. This function modifiesconfig map, fields are removed from the map as they are read. If the map contains unrecognized configuration options, no error is thrown.- Parameters:
modelId- Model IdtaskType- The model task typeconfig- Configuration optionssecrets- Sensitive configuration options (e.g. api key)- Returns:
- The parsed
Model
-
parsePersistedConfig
Parse model configuration fromconfig mapfrom persisted storage and return the parsedModel. This function modifiesconfig map, fields are removed from the map as they are read. If the map contains unrecognized configuration options, no error is thrown.- Parameters:
modelId- Model IdtaskType- The model task typeconfig- Configuration options- Returns:
- The parsed
Model
-
infer
void infer(Model model, @Nullable String query, List<String> input, Map<String, Object> taskSettings, InputType inputType, TimeValue timeout, ActionListener<InferenceServiceResults> listener) Perform inference on the model.- Parameters:
model- The modelquery- Inference query, mainly for re-rankinginput- Inference inputtaskSettings- Settings in the request to override the model's defaultsinputType- For search, ingest etctimeout- The timeout for the requestlistener- Inference result listener
-
chunkedInfer
void chunkedInfer(Model model, @Nullable String query, List<String> input, Map<String, Object> taskSettings, InputType inputType, ChunkingOptions chunkingOptions, TimeValue timeout, ActionListener<List<ChunkedInferenceServiceResults>> listener) Chunk long text according tochunkingOptionsor the model defaults ifchunkingOptionscontains unset values.- Parameters:
model- The modelquery- Inference query, mainly for re-rankinginput- Inference inputtaskSettings- Settings in the request to override the model's defaultsinputType- For search, ingest etcchunkingOptions- The window and span options to applytimeout- The timeout for the requestlistener- Chunked Inference result listener
-
start
Start or prepare the model for use.- Parameters:
model- The modellistener- The listener
-
stop
Stop the model deployment. The default action does nothing except acknowledge the request (true).- Parameters:
modelId- The ID of the model to be stoppedlistener- The listener
-
putModel
Put the model definition (if applicable) The main purpose of this function is to download ELSER The default action does nothing except acknowledge the request (true).- Parameters:
modelVariant- The configuration of the model variant to be downloadedlistener- The listener
-
isModelDownloaded
Checks if the modelId has been downloaded to the local Elasticsearch cluster using the trained models API The default action does nothing except acknowledge the request (false). Any internal services should Override this method.- Parameters:
model-listener- The listener
-
checkModelConfig
Optionally test the new model configuration in the inference service. This function should be called when the model is first created, the default action is to do nothing.- Parameters:
model- The new modellistener- The listener
-
isInClusterService
default boolean isInClusterService()Return true if this model is hosted in the local Elasticsearch cluster- Returns:
- True if in cluster
-
getMinimalSupportedVersion
TransportVersion getMinimalSupportedVersion()Defines the version required across all clusters to use this service- Returns:
TransportVersionspecifying the version
-