- All Superinterfaces:
AutoCloseable
,Closeable
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
checkModelConfig
(Model model, ActionListener<Model> listener) Optionally test the new model configuration in the inference service.void
chunkedInfer
(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 tochunkingOptions
or the model defaults ifchunkingOptions
contains unset values.Defines the version required across all clusters to use this servicevoid
infer
(Model model, String query, List<String> input, Map<String, Object> taskSettings, InputType inputType, TimeValue timeout, ActionListener<InferenceServiceResults> listener) Perform inference on the model.default void
default boolean
Return true if this model is hosted in the local Elasticsearch clusterdefault void
isModelDownloaded
(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 map
from persisted storage and return the parsedModel
.parsePersistedConfigWithSecrets
(String modelId, TaskType taskType, Map<String, Object> config, Map<String, Object> secrets) Parse model configuration fromconfig map
from persisted storage and return the parsedModel
.void
parseRequestConfig
(String modelId, TaskType taskType, Map<String, Object> config, Set<String> platfromArchitectures, ActionListener<Model> parsedModelListener) Parse model configuration from theconfig map
from a request and return the parsedModel
.default void
putModel
(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).void
start
(Model model, ActionListener<Boolean> listener) Start or prepare the model for use.default void
stop
(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 map
from a request and return the parsedModel
. This requires that both the secrets and service settings be contained in theservice_settings
field. This function modifiesconfig map
, fields are removed from the map as they are read.If the map contains unrecognized configuration option an
ElasticsearchStatusException
is 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 map
from 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 map
from 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 tochunkingOptions
or the model defaults ifchunkingOptions
contains 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:
TransportVersion
specifying the version
-