java.lang.Object
java.lang.Record
org.elasticsearch.inference.EmbeddingRequest
- Record Components:
inputs- The list ofInferenceStringGroupinputs to generate embeddings forinputType- TheInputTypeof the request
- All Implemented Interfaces:
Writeable,ToXContent,ToXContentFragment
public record EmbeddingRequest(List<InferenceStringGroup> inputs, InputType inputType)
extends Record
implements Writeable, ToXContentFragment
This class handles the parsing of inputs used by the
TaskType.EMBEDDING task type. The input for this task is specified using
a list of "content" objects, each of which specifies the InferenceString.DataType, InferenceString.DataFormat and the String value of the input. The
format field is optional, and if not specified will use the default InferenceString.DataFormat for the given InferenceString.DataType:
"input": [
{
"content": {"type": "image", "format": "base64", "value": "image data"},
},
{
"content": [
{"type": "text", "value": "text input"},
{"type": "image", "value": "image data"}
]
}
]
It is also possible to specify a single content object rather than a
list:
"input": {
"content": {"type": "text", "format": "text", "value": "text input"}
}
To preserve input compatibility with the existing TaskType.TEXT_EMBEDDING task, the input can also be specified as a single
String or a list of Strings, each of which will be parsed into a content object with InferenceString.DataType equal to
InferenceString.DataType.TEXT and InferenceString.DataFormat equal to InferenceString.DataFormat.TEXT:
"input": "singe text input"OR
"input": ["first text input", "second text input"]
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested 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.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionEmbeddingRequest(List<InferenceStringGroup> inputs, InputType inputType) Creates an instance of aEmbeddingRequestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.inputs()Returns the value of theinputsrecord component.Returns the value of theinputTyperecord component.static EmbeddingRequestof(List<InferenceStringGroup> contents) final StringtoString()Returns a string representation of this record class.toXContent(XContentBuilder builder, ToXContent.Params params) voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
PARSER
-
-
Constructor Details
-
EmbeddingRequest
Creates an instance of aEmbeddingRequestrecord class. -
EmbeddingRequest
- Throws:
IOException
-
-
Method Details
-
of
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin 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. -
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). -
inputs
Returns the value of theinputsrecord component.- Returns:
- the value of the
inputsrecord component
-
inputType
Returns the value of theinputTyperecord component.- Returns:
- the value of the
inputTyperecord component
-