Module org.elasticsearch.server
Package org.elasticsearch.inference
Record Class MinimalServiceSettings
java.lang.Object
java.lang.Record
org.elasticsearch.inference.MinimalServiceSettings
- Record Components:
taskType
- the type of task the inference model performs.dimensions
- the number of dimensions for the embeddings, applicable only forTaskType.TEXT_EMBEDDING
(nullable).similarity
- the similarity measure used for embeddings, applicable only forTaskType.TEXT_EMBEDDING
(nullable).elementType
- the type of elements in the embeddings, applicable only forTaskType.TEXT_EMBEDDING
(nullable).
- All Implemented Interfaces:
Diffable<MinimalServiceSettings>
,SimpleDiffable<MinimalServiceSettings>
,NamedWriteable
,VersionedNamedWriteable
,Writeable
,FilteredXContent
,ServiceSettings
,ToXContent
,ToXContentObject
public record MinimalServiceSettings(String service, TaskType taskType, Integer dimensions, SimilarityMeasure similarity, DenseVectorFieldMapper.ElementType elementType)
extends Record
implements ServiceSettings, SimpleDiffable<MinimalServiceSettings>
Defines the base settings required to configure an inference endpoint.
These settings are immutable and describe the input and output types that the endpoint will handle.
They capture the essential properties of an inference model, ensuring the endpoint is correctly configured.
Key properties include:
taskType
- Specifies the type of task the model performs, such as classification or text embeddings.dimensions
,similarity
, andelementType
- These settings are applicable only when thetaskType
isTaskType.TEXT_EMBEDDING
. They define the structure and behavior of embeddings.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.SimpleDiffable
SimpleDiffable.CompleteDiff<T extends Diffable<T>>
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
FieldsFields inherited from interface org.elasticsearch.cluster.SimpleDiffable
EMPTY
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
ConstructorsConstructorDescriptionMinimalServiceSettings
(String service, TaskType taskType, Integer dimensions, SimilarityMeasure similarity, DenseVectorFieldMapper.ElementType elementType) Creates an instance of aMinimalServiceSettings
record class.MinimalServiceSettings
(Model model) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the givenMinimalServiceSettings
is equivalent to the current definition.static MinimalServiceSettings
chatCompletion
(String serviceName) static MinimalServiceSettings
completion
(String serviceName) Returns the value of thedimensions
record component.Returns the value of theelementType
record component.final boolean
Indicates whether some other object is "equal to" this one.Returns aToXContentObject
that only writes the exposed fields.The minimal version of the recipient this object can be sent toReturns the name of the writeable objectfinal int
hashCode()
Returns a hash code value for this object.modelId()
The model to use in the inference endpoint (e.g.static MinimalServiceSettings
parse
(XContentParser parser) static Diff
<MinimalServiceSettings> static MinimalServiceSettings
service()
Returns the value of theservice
record component.Returns the value of thesimilarity
record component.static MinimalServiceSettings
sparseEmbedding
(String serviceName) taskType()
Returns the value of thetaskType
record component.static MinimalServiceSettings
textEmbedding
(String serviceName, int dimensions, SimilarityMeasure similarity, DenseVectorFieldMapper.ElementType elementType) toString()
Returns a string representation of this record class.toXContent
(XContentBuilder builder, ToXContent.Params params) void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.inference.ServiceSettings
dimensionsSetByUser
Methods inherited from interface org.elasticsearch.cluster.SimpleDiffable
diff
Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
-
SERVICE_FIELD
- See Also:
-
TASK_TYPE_FIELD
- See Also:
-
-
Constructor Details
-
MinimalServiceSettings
public MinimalServiceSettings(@Nullable String service, TaskType taskType, @Nullable Integer dimensions, @Nullable SimilarityMeasure similarity, @Nullable DenseVectorFieldMapper.ElementType elementType) Creates an instance of aMinimalServiceSettings
record class.- Parameters:
service
- the value for theservice
record componenttaskType
- the value for thetaskType
record componentdimensions
- the value for thedimensions
record componentsimilarity
- the value for thesimilarity
record componentelementType
- the value for theelementType
record component
-
MinimalServiceSettings
-
MinimalServiceSettings
- Throws:
IOException
-
-
Method Details
-
parse
- Throws:
IOException
-
textEmbedding
public static MinimalServiceSettings textEmbedding(String serviceName, int dimensions, SimilarityMeasure similarity, DenseVectorFieldMapper.ElementType elementType) -
sparseEmbedding
-
rerank
-
completion
-
chatCompletion
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
getWriteableName
Description copied from interface:VersionedNamedWriteable
Returns the name of the writeable object- Specified by:
getWriteableName
in interfaceNamedWriteable
- Specified by:
getWriteableName
in interfaceVersionedNamedWriteable
-
getMinimalSupportedVersion
Description copied from interface:VersionedNamedWriteable
The minimal version of the recipient this object can be sent to- Specified by:
getMinimalSupportedVersion
in interfaceVersionedNamedWriteable
-
getFilteredXContentObject
Description copied from interface:FilteredXContent
Returns aToXContentObject
that only writes the exposed fields. Any hidden fields are not written.- Specified by:
getFilteredXContentObject
in interfaceFilteredXContent
-
modelId
Description copied from interface:ServiceSettings
The model to use in the inference endpoint (e.g. text-embedding-ada-002). Sometimes the model is not defined in the service settings. This can happen for external providers (e.g. hugging face, azure ai studio) where the provider requires that the model be chosen when initializing a deployment within their service. In this situation, return null.- Specified by:
modelId
in interfaceServiceSettings
- Returns:
- the model used to perform inference or null if the model is not defined
-
readDiffFrom
- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
canMergeWith
Checks if the givenMinimalServiceSettings
is equivalent to the current definition. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
service
Returns the value of theservice
record component.- Returns:
- the value of the
service
record component
-
taskType
Returns the value of thetaskType
record component.- Returns:
- the value of the
taskType
record component
-
dimensions
Returns the value of thedimensions
record component.- Specified by:
dimensions
in interfaceServiceSettings
- Returns:
- the value of the
dimensions
record component
-
similarity
Returns the value of thesimilarity
record component.- Specified by:
similarity
in interfaceServiceSettings
- Returns:
- the value of the
similarity
record component
-
elementType
Returns the value of theelementType
record component.- Specified by:
elementType
in interfaceServiceSettings
- Returns:
- the value of the
elementType
record component
-